Function ControlClick

  • Simulates a mouse click on a control. Unlike MouseClick, ControlClick 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 ControlClickByHandle to avoid potential issues with ambiguous window and control titles.

    Parameters

    • windowTitle: string

      The title of the window to access.

    • windowText: string

      Optional text found in the window.

    • controlId: string

      The control to interact with.

    • button: MouseButton = MouseButton.Left

      The mouse button to click. Default is MouseButton.Left.

    • clicks: number = 1

      The number of times to click the mouse. Default is 1.

    • x: number = AU3_INTDEFAULT

      The x position to click within the control. Default is the center.

    • y: number = AU3_INTDEFAULT

      The y position to click within the control. Default is the center.

    Returns number

    1 if success, 0 if failed.

    import { ControlClick } from '@ahmic/autoit-js';

    // Click the Notepad window's edit control.
    ControlClick('Untitled - Notepad', '', 'Edit1');

    // Right click the Notepad window's edit control.
    ControlClick('Untitled - Notepad', '', 'Edit1', MouseButton.Right);

    // Double click the Notepad window's edit control.
    ControlClick('Untitled - Notepad', '', 'Edit1', MouseButton.Left, 2);