The handle of the window to access.
The handle of the control to interact with.
The mouse button to click. Default is MouseButton.Left
.
The number of times to click the mouse. Default is 1.
The x position to click within the control. Default is the center.
The y position to click within the control. Default is the center.
1 if success, 0 if failed.
import { ControlClickByHandle, ControlGetHandle, MouseButton, WinGetHandle } from '@ahmic/autoit-js';
const windowHandle = WinGetHandle('Untitled - Notepad');
const controlHandle = ControlGetHandle(windowHandle, 'Edit1');
// Click the Notepad window's edit control.
ControlClickByHandle(windowHandle, controlHandle);
// Right click the Notepad window's edit control.
ControlClickByHandle(windowHandle, controlHandle, MouseButton.Right);
// Double click the Notepad window's edit control.
ControlClickByHandle(windowHandle, controlHandle, MouseButton.Left, 2);
Simulates a mouse click on a control. Unlike
MouseClick
,ControlClickByHandle
won't move the mouse cursor but is capable of clicking on controls that may be obscured by other windows.Where possible, you should prefer using this function over
ControlClick
to avoid potential issues with ambiguous window and control titles.