ControlGetIndex

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

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

Parameters

Control

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.

WinTitle

Type: String, Integer or Object

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

WinText

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.

ExcludeTitle

Type: String

Windows whose titles include this value will not be considered.

ExcludeText

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.

Remarks

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.

Related

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

Examples

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

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