MouseClick

From AutoIt Wiki

Jump to: navigation, search

Performs a mouse click operation. Adapted from AutoIt docs.

Contents

Syntax

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

Parameters

buttonThe button click: "left", "right", "middle", "main", "menu", "primary", "secondary".
x, yThe xy-coordinates to move the mouse to. If no x and y coordiantes are given, the current position is used.(Optional)
clicksThe number of times to click the mouse.(Optional)
speedThe speed to move the mouse. Range 1 to 100. A speed of zero will move the mouse instantly. Default is 10.(Optional)

Return Value

Success: Returns 1.
Failure: Returns 0, the button is not in the list.

Example

; Double click at the current mouse pos
MouseClick("left")
MouseClick("left")

; Double click at 0,500
MouseClick("left", 0, 500, 2)

; SAFER VERSION of Double click at 0,500 - takes into account user's control panel settings
MouseClick("primary", 0, 500, 2)

Remarks

If the button is an empty string, the left button with be clicked.
If the user has swapped the left and right mouse buttons on the control panel, the behavior 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. The "Secondary" or "Menu" buttons will usually bring up the context menu.

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 Functions

MouseClickDrag MouseGetPos MouseMove

Personal tools