Mouse click

Syntax

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

 

Parts

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

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

flags - combination of the following values. Default: 0.

1 coordinates are relative to the top-left corner of window's client area or, if window is 0 (constant), the work area.
2 when window is used, don't activate the window and don't generate error if the specified point does not belog to it.

Options: + button down (press); - button up (release).

 

Remarks

lef clicks left mouse button.

rig clicks right mouse button.

mid clicks middle mouse button.

dou double clicks left mouse button.

 

If the window does not exist or the specified point is not inside the window, is generated run-time error. For child windows, the point can be outside but must not be outside top-level parent window. If window is inactive or minimized, it is restored and activated.

 

Tips

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.

 

Examples

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