Home > Language Reference > Windows Management Functions > ClickMouse

ClickMouse

The ClickMouse function simulates a mouse button click at the specified coordinates.

Usage

ClickMouse function should be used only if a control within the application cannot be clicked using Click function or SendKeys function (for sending a keyboard shortcut). ClickMouse function is pixel related and dependent on screen resolution.

Syntax

ClickMouse(left|right|middle, down|up|double, <x>, <y> [, absolute])

Parameters

left|right|middle, keyword, type of the mouse button to click. Midlle keyword is not generated by Recording mode.

down|up|double, keyword indicating the click action.

<x>,<y>, integer, coordinates of the pixel to click, relative to the topleft point of the current window (unless absolute keyword is specified).

absolute, optional keyword.  If absolute keyword is specified, <x>,<y> are relative to the topleft point of the full screen.

Return value

None.

Remarks

UseWindow statement is needed before a ClickMouse statement, the click is done within this window. If no window is specified previously by a UseWindow statement, an error message is displayed and script execution stops (unless #IgnoreErrors=1).

When a single click is recorded, two statements are generated :
ClickMouse(left,down,X,Y)
ClickMouse(left,up,X,Y)
If you have in a script just one ClickMouse line with Down or Up second parameter, the mouse is in an unstable status and subsequent lines will not replay correctly.

See also

Click

Example

'Launch notepad
Shell("notepad")
'Type some text
UseWindow("NOTEPAD.EXE|Edit|Untitled - Notepad|1",1)
 SendKeys("ClickMouse Test")
'Click somewhere within the text using Left button
 ClickMouse(Left,Down,46,13)
 ClickMouse(Left,Up,46,13)
'Click somewhere within the text using Right button - it opens the context menu, select Undo option in the context menu 
 ClickMouse(Right,Down,102,13)
 ClickMouse(Right,Up,102,13)
 ChooseMenu(Context,"&Undo")