Mouse click


lef[+|-] [x y] [window] [flags]
rig[+|-] [x y] [window] [flags]
mid[+|-] [x y] [window] [flags]
dou [x y] [window] [flags]



x y - mouse pointer coordinates. If omitted, mouse pointer is not moved.

window - top-level or child window. If omitted or literal 0, coordinates are relative to the top-left corner of the screen.


1 Coordinates are relative to the top-left corner of window's client area. If window is literal 0 - to the work area.
2 Don't activate window. Not error if point x y does not belong to window or its top-level parent window.
4 QM 2.3.0. Finally return the mouse pointer to previous position.



+ button down (press).
- button up (release).



lef clicks the left mouse button.

rig clicks the right mouse button.

mid clicks the middle mouse button.

dou double clicks the left mouse button.


When window is used:


The speed depends on spe and opt slowmouse.



You can use function BlockInput to block keyboard and mouse input while macro is running. Place BlockInput 1 at the beginning. If you want to manually end macro when input is blocked, at first press Ctrl+Alt+Delete.


See also: MouseButtonX and other functions in the mouse category.



lef ;;mouse left button click
lef+ ;;mouse left button down
lef- ;;mouse left button up
lef 100 200 ;;mouse left button click at 100, 200 pixels of the screen
lef 50 30 "Notepad" ;;mouse left button click at 50, 30 pixels of "Notepad" window
lef 10 10 id(131 "Calc") ;;mouse left button click at 10, 10 pixels of button with id=131 in "Calc" window
lef 0.5 0.5 "Notepad" ;;mouse left button click at middle of"Notepad" window

 Click in "Notepad" window, x=100 (relative to "Notepad"), don't change y:
int w = win("Notepad")
lef 100 ym(0 w) w