Sends a mouse click command to a given control.
ControlClick ( "title", "text", controlID [, button = "left" [, clicks = 1 [, x [, y]]]] )
Some controls will resist clicking unless they are the active window. Use the WinActivate() function to force the control's window to the top before using ControlClick().
Using 2 for the number of clicks will send a double-click message to the control - this can even be used to launch programs from an explorer control!
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 |
ControlCommand, MouseClick, WinActivate
#include "Extras\HelpFileInternals.au3"
Example()
Func Example()
; Run Notepad
Run ("notepad.exe")
; Wait 10 seconds for the Notepad window to appear.
Local $hWnd= WinWait ("[CLASS:Notepad]","",10)
; Send a mouse click to the edit control of Notepad using the handle returned by WinWait.
ControlClick ($hWnd,"",ControlGetFocus ($hWnd))
; Wait for 2 seconds.
Sleep (2000)
; Close the Notepad window using the handle returned by WinWait.
WinClose ($hWnd)
EndFunc ;==>Example