Performs full range of mouse associated activities.
MousePlay(X-Y-coordinates, parent-window, child-window, buttons, delay)
(s) X-Y-coordinates space-delimited string with the final mouse x and y position, in virtual 1000x1000 units.
(s) parent-window name of parent window to move mouse relative to, or "" to specify the desktop.
(s) child-window name of child window (i.e., child of "parent-window") to move mouse relative to, or "" if the movement will be relative to "parent".
(i) buttons combination of one or more mouse buttons and keys to click and/or hold down (see below for list).
(f) delay amount of time to take for performing the mouse activity, in seconds. Can be a decimal number to indicate a fraction of a second.
(i) always 1.
MousePlay allows you to perform the full range of mouse associated activities with a single function.
You can simulate drag-and-drop operations by specifying the drop location in the "X-Y-coordinates" parameter and adding the @MPLAYLBUTTON constant to the "buttons" parameter. This tells MousePlay to move the mouse to the position x,y with the left mouse button down.
You can perform a mouse button click at a specific location by using one of the button click values in the "buttons" parameter.
MousePlay can move the mouse cursor relative to the upper left-hand corner of a window. To do this simply place a window name in the "parent window" parameter and optionally in the "child window" parameter. If you give MousePlay a child window name you must give it a parent name as well. When window names are present, MousePlay considers the upper left-hand corner of the parent or child window to be 0,0. It is, therefore, possible to give it a negative x or y value to move the mouse cursor to the left or above the window. If the window you specify is minimized, MousePlay will use its last un-minimized size for calculating mouse position.
MousePlay also accepts the WIL constants @SHIFT and @CTRL in the "buttons" parameter. You can combine these constants with a mouse button constant using the bitwise OR ('|') operator to duplicate holding down the Shift or Control key while performing a mouse drag-and-drop or button click.
You can use the "delay" parameter to control the amount of time MousePlay takes to perform an action. Sometimes it is necessary to slow down the mouse so that Windows will properly recognize the action. You may also want to slow things down to better track events or to just give your mouse activity a natural appearance. This parameter expects values in seconds, and only recognizes the first three digits to the right of the decimal point.
IntControl 35 can also be used to slow down mouse clicks. If the MousePlay delay is less than the IntControl specified time, MousePlay will take the amount of time indicated by the IntControl setting.
Table of possible values for the "buttons" parameter:
(Can be combined using the bitwise | (OR) operator.)
Constant |
Meaning |
@MPLAYLCLK |
Click left mouse button. |
@MPLAYRCLK |
Click right mouse button. |
@MPLAYMCLK |
Click middle mouse button. |
@MPLAYLDBLCK |
Double click left mouse button. |
@MPLAYRDBLCK |
Double click right mouse button. |
@MPLAYMDBLCK |
Double click middle mouse button. |
@MPLAYLBUTTON |
Hold down the left mouse button. |
@MPLAYRBUTTON |
Hold down the right mouse button. |
@MPLAYMBUTTON |
Hold down the middle mouse button. |
@SHIFT |
Hold down the shift key. |
@CTRL |
Hold down the control key. |
Note: The size and shape of displayed windows are usually based on a combination of screen resolution and the system font size. Thus the x and y coordinates may be different on each individual machine.
Note: These examples may not Run ON your system due To various configuration options. ; Example 1 ; Run Explorer as a maximized window DirChange(DirWindows(0)) RunZoom("explorer.exe", "") WinWaitExist("~Exploring",5) WinActivate("~Exploring") ; now click on the minimize button in the upper-right corner MousePlay("956 16", "~Exploring", "", @MPLAYLCLK, 5) Exit ; Example 2 ; Moves mouse cursor from lower left hand corner of the screen ; to the upper right hand corner of the screen MousePlay("0 1000", "", "", 0, 0.2) MousePlay("70 973", "", "", 0, 0.2) MousePlay("589 533", "", "", 0, 0.2) MousePlay("880 238", "", "", 0, 0.2) MousePlay("997 107", "", "", 0, 0.2) MousePlay("1000 0", "", "", 0, 0.2) Exit
IntControl 35, MouseClick, MouseClickBtn, MouseInfo, SendKey, SendKeysTo