Control Functions

Functions for retrieving information about a control or for performing various operations on a control. Click on a function name for details.

Function Description
ControlAddItem Adds a new entry at the bottom of a list box, combo box, or drop-down list.
ControlChooseIndex Selects an entry in a list box, combo box, or drop-down list, or a tab control page, by index.
ControlChooseString Selects an entry in a list box, combo box, or drop-down list, or a tab control page, by string.
ControlClick Sends a mouse button or mouse wheel event to a window or control.
ControlDeleteItem Deletes an entry from a list box, combo box, or drop-down list by index.
ControlFindItem Searches for an entry in a list box, combo box, or drop-down list by string, and returns its index.
ControlFocus Sets keyboard focus to a control.
ControlGetChecked Returns 1 if a check box or radio button is checked, or 0 if unchecked.
ControlGetChoice Returns the text of the currently selected entry in a list box, combo box, or drop-down list.
ControlGetClassNN Returns the ClassNN (class name and sequence number) of a control.
ControlGetEnabled Returns 1 if a control is enabled, or 0 if disabled.
ControlGetFocus Retrieves which control of the target window has keyboard focus, if any.
ControlGetHwnd Returns the window handle (HWND) of a control.
ControlGetIndex Returns the index of the currently selected entry in a list box, combo box, or drop-down list, or the index of the active page in a tab control.
ControlGetItems Returns an array of entries from a list box, combo box, or drop-down list.
ControlGetPos Retrieves the position and size of a control.
ControlGetStyle
ControlGetExStyle
Returns an integer representing the style or extended style of a control.
ControlGetText Retrieves text from a control.
ControlGetVisible Returns 1 if a control is visible, or 0 if hidden.
ControlHide Hides a control.
ControlHideDropDown Hides the popup list of a combo box or drop-down list.
ControlMove Moves and/or resizes a control.
ControlSend
ControlSendText
Sends simulated keystrokes or text to a window or control.
ControlSetChecked Checks or unchecks a check box or radio button.
ControlSetEnabled Enables or disables a control.
ControlSetStyle
ControlSetExStyle
Changes the style or extended style of a control.
ControlSetText Changes the text of a control.
ControlShow Shows a control if it was previously hidden.
ControlShowDropDown Shows the popup list of a combo box or drop-down list.
EditGetCurrentCol Returns the column number in an edit control where the caret resides.
EditGetCurrentLine Returns the line number in an edit control where the caret resides.
EditGetLine Returns the text of a line in an edit control by line number.
EditGetLineCount Returns the number of lines in an edit control.
EditGetSelectedText Returns the selected text in an edit control.
EditPaste Pastes a string at the caret in an edit control.
ListViewGetContent Returns content data from a list-view control, such as rows, columns, or count values.

Error Handling

Typically one of the following errors may be thrown:

Remarks

Most of the functions listed here are intended for use with controls in a non-GUI window, i.e. a window that is not created with the Gui function. They work best with common or predefined Microsoft controls; some applications use custom or modified controls, in which case the functions might not work as expected. For GUI controls, it is usually more convenient to use their GuiControl object, assuming a suitable counterpart exists.

Functions which operate on individual controls have a parameter named ControlID which supports a few different ways to identify the control. See Control Identifiers for details.

To improve reliability, a delay is done automatically after each use of a Control function that changes a control (except for ControlSetStyle and ControlSetExStyle). That delay can be changed via SetControlDelay or by assigning a value to A_ControlDelay. For details, see SetControlDelay remarks.

To discover the ClassNN or HWND of the control that the mouse is currently hovering over, use MouseGetPos.

To retrieve an array of all controls in a window, use WinGetControls or WinGetControlsHwnd.

SetControlDelay, Win functions, GuiControl object (for controls created by the script)