# Function Reference

# MouseClick

Perform a mouse click operation.

MouseClick ( "button" [, x, y [, clicks = 1 [, speed = 10]]] )

## Parameters

button | The button to click: $MOUSE_CLICK_LEFT ("left") $MOUSE_CLICK_RIGHT ("right") $MOUSE_CLICK_MIDDLE ("middle") $MOUSE_CLICK_MAIN ("main") $MOUSE_CLICK_MENU ("menu") $MOUSE_CLICK_PRIMARY ("primary") $MOUSE_CLICK_SECONDARY ("secondary") Constants are defined in "AutoItConstants.au3".
x, y | [optional] The x/y coordinates to move the mouse to. If no x and y coords are given, the current position is used (default).
clicks | [optional] The number of times to click the mouse. Default is 1.
speed | [optional] the speed to move the mouse in the range 1 (fastest) to 100 (slowest). A speed of 0 will move the mouse instantly. Default speed is 10.

## Return Value

Success: | 1.
Failure: | 0, the button is not in the list or invalid parameter as x without y.

## Remarks

If the button is an empty string, the left button will be clicked.
If x or y equal to the Default keyword no move occurs in the corresponding coordinate.
If the user has swapped the left and right mouse buttons in the control panel, then the behaviour of the buttons is different. "Left" and "right" always click those buttons, whether the buttons are swapped or not. The "primary" or "main" button will be the main click, whether or not the buttons are swapped. The "secondary" or "menu" buttons will usually bring up the context menu, whether the buttons are swapped or not.

Button | Normal | Swapped
--- | --- | ---
"" | Left | Left
"left" | Left | Left
"middle" | Middle | Middle
"right" | Right | Right
"primary" | Left | Right
"main" | Left | Right
"secondary" | Right | Left
"menu" | Right | Left

## Related

ControlClick, MouseClickDelay (Option), MouseClickDrag, MouseCoordMode (Option), MouseDown, MouseGetPos, MouseMove, MouseUp, MouseWheel

## Example

    #include <AutoItConstants.au3>

    ; Double click at the current mouse position.
    MouseClick($MOUSE_CLICK_LEFT)
    MouseClick($MOUSE_CLICK_LEFT)

    ; Double click at the x, y position of 0, 500.
    MouseClick($MOUSE_CLICK_LEFT, 0, 500, 2)

    ; Double click at the x, y position of 0, 500. This is a better approach as it takes into account left/right handed users.
    MouseClick($MOUSE_CLICK_PRIMARY, 0, 500, 2)