Clicks or holds down a mouse button, or turns the mouse wheel.

MouseClick [, WhichButton , X, Y, ClickCount, Speed, D|U, R]




The button to click: Left, Right, Middle (or just the first letter of each of these); or the fourth or fifth mouse button (X1 or X2), which is supported on Windows 2000/XP or later. For example: MouseClick, X1. In v1.0.30+, this parameter may be omitted, in which case it defaults to Left.

Rotate the mouse wheel: On Windows NT/2000/XP or later, specify WheelUp or WU to turn the wheel upward (away from you); specify WheelDown or WD to turn the wheel downward (toward you). In this case, ClickCount is the number of notches to turn the wheel.

X, Y The x/y coordinates to move the mouse to, prior to clicking, which can be expressions. Coordinates are relative to the active window unless CoordMode was used to change that. If omitted, the cursor's current position is used.
ClickCount The number of times to click the mouse, which can be an expression.  If omitted, the button is clicked once.
Speed The speed to move the mouse in the range 0 (fastest) to 100 (slowest), which can be an expression.  Note: a speed of 0 will move the mouse instantly.  If omitted, the default speed (as set by SetDefaultMouseSpeed or 2 otherwise) will be used.

If this parameter is omitted, each click will consist of a "down" event followed by an "up" event. Alternatively:
D = Press the mouse button down but do not release it (i.e. generate a down-event).
U = Release the mouse button (i.e. generate an up-event).

R If this parameter is the letter R, the X and Y coordinates will be treated as offsets from the current mouse position. In other words, the cursor will be moved from its current position by X pixels to the right (left if negative) and Y pixels down (up if negative).



To perform a shift-click or control-click, use the Send command before and after the operation as shown in these examples:

; Example #1:
Send, {Control down}
MouseClick, left, 55, 233
Send, {Control up}

; Example #2:
Send, {Shift down}
MouseClick, left, 55, 233
Send, {Shift up}

Some applications such as certain full-screen games may have trouble tracking the mouse if it moves too quickly. The speed parameter or SetDefaultMouseSpeed can be used to reduce the speed.

Not all applications obey a ClickCount higher than 1 for turning the mouse wheel. For those applications, use a Loop to turn the wheel more than one notch as in this example, which turns it 5 notches:
Loop, 5
     MouseClick, WheelUp

The BlockInput command can be used to prevent any physical mouse activity by the user from disrupting the simulated mouse events produced by the mouse commands.

There is an automatic delay after every click-down and click-up of the mouse (except for turning the mouse wheel in v1.0.26+). Use SetMouseDelay to change the length of the delay.



CoordMode, SetDefaultMouseSpeed, SetMouseDelay, MouseClickDrag, MouseGetPos, MouseMove, BlockInput



; Double click at the current mouse pos:
MouseClick, left
MouseClick, left

; Same as above:
MouseClick, left, , , 2

; Move to specified coordinates then right-click once:
MouseClick, right, 200, 300

; Here are two hotkeys that simulate the turning of the mouse wheel:
#up::MouseClick, WheelUp, , , 2  ; Turn it by two notches.
#down::MouseClick, WheelDown, , , 2