Returns the index of the currently selected entry or tab in a ListBox, ComboBox or Tab control.

Index := ControlGetIndex(Control , WinTitle, WinText, ExcludeTitle, ExcludeText)



Type: String, Integer or Object

The control's ClassNN, text or HWND, or an object with a Hwnd property. For details, see The Control Parameter.


Type: String, Integer or Object

A window title or other criteria identifying the target window. See WinTitle.


Type: String

If present, this parameter must be a substring from a single text element of the target window (as revealed by the included Window Spy utility). Hidden text elements are detected if DetectHiddenText is ON.


Type: String

Windows whose titles include this value will not be considered.


Type: String

Windows whose text include this value will not be considered.

Return Value

Type: Integer

This function returns the index of the currently selected entry or tab. The first entry or tab is 1, the second is 2, etc. If no entry or tab is selected, the return value is 0.

Error Handling

An exception is thrown on failure, or if the window or control could not be found.


To instead discover how many tabs (pages) exist in a tab control, follow this example:

TabCount := SendMessage(0x1304,,, "SysTabControl321", WinTitle)  ; 0x1304 is TCM_GETITEMCOUNT.

Window titles and text are case sensitive. Hidden windows are not detected unless DetectHiddenWindows has been turned on.


ControlChooseIndex, ControlGetChoice, ControlChooseString, Value property (GuiControl object), Choose method (GuiControl object), Control functions


#1: Retrieves the active tab number of the first Tab control.

WhichTab := ControlGetIndex("SysTabControl321", "Some Window Title")
MsgBox "Tab #" WhichTab " is active."