Small changes to double-click functions, add mouse location functions

This commit is contained in:
Bradlee Speice 2012-07-30 09:54:05 -04:00
parent 749788f733
commit ad3f4d6c5d
4 changed files with 65 additions and 20 deletions

View File

@ -192,8 +192,8 @@ Usage: \n\
\t-c, --center:\t\tInstead of matching the top-left corner of an image,\n\ \t-c, --center:\t\tInstead of matching the top-left corner of an image,\n\
\t\t\t\tmatch the center of the image.\n\ \t\t\t\tmatch the center of the image.\n\
\t-o, --sane-tolerance:\tSet the tolerance using a scale of 1-100,\n\ \t-o, --sane-tolerance:\tSet the tolerance using a scale of 1-100,\n\
\t-s, --string:\t\tCommand string - see below.\n\
\t-i, --timeout:\t\tSpecify the timeout to use when using the 'waitfor' function\n\ \t-i, --timeout:\t\tSpecify the timeout to use when using the 'waitfor' function\n\
\t-s, --string:\t\tCommand string - see below.\n\
\t\t\t\tPlease make sure to use the '-t' or '-o' options when using this.\n\ \t\t\t\tPlease make sure to use the '-t' or '-o' options when using this.\n\
\n\ \n\
This program works kind of like a mini-language. All options\n\ This program works kind of like a mini-language. All options\n\
@ -213,6 +213,7 @@ Available commands:\n\
\tmousejiggle:\tJiggle the mouse (helps to activate some widgets).\n\ \tmousejiggle:\tJiggle the mouse (helps to activate some widgets).\n\
\tmousescrollu:\tScroll the mouse wheel up.\n\ \tmousescrollu:\tScroll the mouse wheel up.\n\
\tmousescrolld:\tScroll the mouse wheel down.\n\ \tmousescrolld:\tScroll the mouse wheel down.\n\
\tmouselocation:\tReturn the location of the mouse.\n\
\tkeyclick:\tClick a keyboard button.\n\ \tkeyclick:\tClick a keyboard button.\n\
\tkeydown:\tPush and leave down a keyboard button.\n\ \tkeydown:\tPush and leave down a keyboard button.\n\
\tkeyup:\tRelease a keyboard button.\n\ \tkeyup:\tRelease a keyboard button.\n\
@ -306,6 +307,8 @@ void checkXTEEnabled ( Display *display )
* *
* \c mousescrolld: Scroll the mouse wheel down * \c mousescrolld: Scroll the mouse wheel down
* *
* \c mouselocation: Return the current location of the mouse
*
* \c keyclick: Click a keyboard button. * \c keyclick: Click a keyboard button.
* *
* \c keydown: Push and leave down a keyboard button. * \c keydown: Push and leave down a keyboard button.

View File

@ -372,7 +372,7 @@ XF86MonBrightnessDown
/** \page xtest_command_strings xte_commandString() Command Strings /** \page xtest_command_strings xte_commandString() Command Strings
This page describes the various command strings available for the \ref xte_commandString() function. This page describes the various command strings available for the \ref xte_commandString() function.
\section mouseclick Mouse Click \section mousefunctions Mouse Functions
\code 'mouseclick <button_number>' \endcode \code 'mouseclick <button_number>' \endcode
Click the mouse button \c <button_number> in-place. Click the mouse button \c <button_number> in-place.
@ -425,7 +425,11 @@ Scroll the mouse down 1 time - depending on window manager settings, etc., this
Scroll the mouse up 1 time - depending on window manager settings, etc., this may be multiple lines. Scroll the mouse up 1 time - depending on window manager settings, etc., this may be multiple lines.
\note This is a wrapper function for clicking button 5 on the mouse \note This is a wrapper function for clicking button 5 on the mouse
\section keyclick Key Button Click \section mouselocation Mouse Location
\code 'mouselocation' \endcode
Return the current location of the mouse pointer.
\section keyboard_functions Keyboard Functions
\code 'keyclick <key_name>' \endcode \code 'keyclick <key_name>' \endcode
Push and release a keyboard key. This can be a key like \c 'a', \c 'b', or something fancy like \c 'space'. Please see \ref xtest_key_strings for a full list of special keys. Push and release a keyboard key. This can be a key like \c 'a', \c 'b', or something fancy like \c 'space'. Please see \ref xtest_key_strings for a full list of special keys.
@ -622,7 +626,7 @@ Wait for an image to show up on screen. For example, this can be used to make su
* \param displayLocation The Display of which to scroll the mouse * \param displayLocation The Display of which to scroll the mouse
*/ */
/** \fn void void xte_mouseScrollDown ( Display *displayLocation ); /** \fn void xte_mouseScrollDown ( Display *displayLocation );
* \brief Scroll the mouse down * \brief Scroll the mouse down
* \details This moves the mouse scroll wheel down one rotation, which may be multiple lines. What this really does is click mouse button 5. * \details This moves the mouse scroll wheel down one rotation, which may be multiple lines. What this really does is click mouse button 5.
* \param displayLocation The Display of which to scroll the mouse * \param displayLocation The Display of which to scroll the mouse

View File

@ -1040,6 +1040,10 @@ cvaPoint xte_commandString ( Display *displayLocation, char *commandString, int
free(fileName); free(fileName);
} }
else if (IS_CMD( s_commandString, "mouselocation" ))
{
resultPoint = xte_mouseLocation( displayLocation );
}
/* Note that we will return (-1,-1) implicitly /* Note that we will return (-1,-1) implicitly
* if we don't recognize the argument */ * if we don't recognize the argument */

View File

@ -71,7 +71,11 @@ err ()
click () click ()
{ {
if [ -n "$1" ]; then
eval $CVAINPUT -s 'mouseclick $1' >> $OUTFILE >> $OUTFILE
else
eval $CVAINPUT -s 'mouseclick 1' >> $OUTFILE >> $OUTFILE eval $CVAINPUT -s 'mouseclick 1' >> $OUTFILE >> $OUTFILE
fi
return $? return $?
} # ---------- end of function click ---------- } # ---------- end of function click ----------
@ -98,7 +102,11 @@ click_xy ()
out "click_xy: " $X_LOC $Y_LOC out "click_xy: " $X_LOC $Y_LOC
if [ -n "$3" ]; then
eval '$CVAINPUT -s "mousexy $X_LOC $Y_LOC" -s "mouseclick $3" >> $OUTFILE'
else
eval '$CVAINPUT -s "mousexy $X_LOC $Y_LOC" -s "mouseclick 1" >> $OUTFILE' eval '$CVAINPUT -s "mousexy $X_LOC $Y_LOC" -s "mouseclick 1" >> $OUTFILE'
fi
return $? return $?
} # ---------- end of function click_xy ---------- } # ---------- end of function click_xy ----------
@ -113,17 +121,26 @@ click_xy ()
clickr_xy () clickr_xy ()
{ {
if [ -z "$1" ]; then if [ -z "$1" ]; then
err "Did not specify an X increment..." out "Did not specify an X increment, assuming (0, 0)"
return 255 X_INC=0
Y_INC=0
else
X_INC=$1
fi fi
if [ -z "$2" ]; then if [ -z "$2" ]; then
err "Did not specify a Y increment..." out "Did not specify a Y increment, assuming ($X_INC, 0)"
return 255 else
Y_INC=$2
fi fi
out "clickr_xy: " $1 $2 out "clickr_xy: " $1 $2
if [ -n "$3" ]; then
eval '$CVAINPUT -s "mouserxy $1 $2" -s "mouseclick 1" >> $OUTFILE' eval '$CVAINPUT -s "mouserxy $1 $2" -s "mouseclick 1" >> $OUTFILE'
else
eval '$CVAINPUT -s "mouserxy $1 $2" -s "mouseclick 1" >> $OUTFILE'
fi
return $? return $?
} # ---------- end of function clickr_xy ---------- } # ---------- end of function clickr_xy ----------
@ -211,7 +228,11 @@ click_i ()
doubleclick () doubleclick ()
{ {
if [ -n "$1" ]; then
click $1 && click $1
else
click && click click && click
fi
} # ---------- end of function doubleclick ---------- } # ---------- end of function doubleclick ----------
#--- FUNCTION ---------------------------------------------------------------- #--- FUNCTION ----------------------------------------------------------------
@ -238,7 +259,11 @@ doubleclick_xy ()
out "doubleclick_xy $X_LOC $Y_LOC" out "doubleclick_xy $X_LOC $Y_LOC"
if [ -n "$3" ]; then
click_xy "$X_LOC" "$Y_LOC" "$3" && click "$3"
else
click_xy "$X_LOC" "$Y_LOC" && click click_xy "$X_LOC" "$Y_LOC" && click
fi
return $? return $?
} # ---------- end of function doubleclick_xy ---------- } # ---------- end of function doubleclick_xy ----------
@ -253,17 +278,26 @@ doubleclick_xy ()
doubleclickr_xy () doubleclickr_xy ()
{ {
if [ -z "$1" ]; then if [ -z "$1" ]; then
err "Did not specify an X increment..." out "Did not specify an X increment, assuming (0, 0)"
return 255 X_INC=0
Y_INC=0
else
X_INC=$1
fi fi
if [ -z "$2" ]; then if [ -z "$2" ]; then
err "Did not specify a Y increment..." out "Did not specify a Y increment, assuming ($X_INC, 0)"
return 255 else
Y_INC=$2
fi fi
out "doubleclickr_xy: $1 $2" out "doubleclickr_xy: $X_INC $Y_INC"
if [ -n "$3" ]; then
clickr_xy "$X_INC" "$Y_INC" "$3" && click "$3"
else
clickr_xy "$1" "$2" && click clickr_xy "$1" "$2" && click
fi
return $? return $?
} # ---------- end of function doubleclickr_xy ---------- } # ---------- end of function doubleclickr_xy ----------