The ClassNN appears to have a consistent pattern:
WindowsForms10.COMBOBOX.app.0.#######_r9_ad##
But the NN varies, it is 14 or 11 (or possibly 4 or 1, I'm not certain if the class ends in 'ad1' or 'ad').
So this appears to be a problem, the number at the end is not consistent.
[EDIT:] The class appears to be as follows:
WindowsForms10.COMBOBOX.app.0.#######_r9_ad1
And so the ClassNN would be:
WindowsForms10.COMBOBOX.app.0.#######_r9_ad1# for the first 9 ComboBoxes
WindowsForms10.COMBOBOX.app.0.#######_r9_ad1## for the next 90
To explain what my script does, it gets the window handle for the active window, it retrieves all the ClassNNs for the window and stores them in a string. The string is LF-separated (linefeed characters between each ClassNN). It checks the start of each ClassNN that matches the string we're looking for, and counts them, and when it has found the 14th one, it breaks out of the loop. Then it receives the handle to the control (which may or may not be useful) and shows the results in a MsgBox.
- We have a problem if the NN varies, not just the class. You could try things like ControlGetPos. Or possibly if the controls are in a hierarchy, you can find a particular easily identifiable control, and retrieve its children. And check those children for the matching control.
- Here's an example of finding the children of a window, and then the children of one of the children.
Code: Select all
q:: ;internet explorer - list controls (for main window and for Find Bar)
;note: show the Find Bar by pressing Ctrl+F, before running the script
;note: the same controls may have different ClassNNs in each loop, since the NNs are relative to the main window/control
WinGet, hWnd, ID, A
;list Internet Explorer controls
vOutput := ""
WinGet, vCtlList, ControlList, % "ahk_id " hWnd
Loop, Parse, vCtlList, `n
{
vCtlClassNN := A_LoopField
ControlGet, hCtl, Hwnd,, % vCtlClassNN, % "ahk_id " hWnd
vOutput .= hCtl "`t" vCtlClassNN "`r`n"
}
MsgBox, % vOutput
;list Internet Explorer Find Bar controls
ControlGet, hCtl, Hwnd,, FindBarClass1, % "ahk_id " hWnd
vOutput := ""
WinGet, vCtlList, ControlList, % "ahk_id " hCtl
Loop, Parse, vCtlList, `n
{
vCtlClassNN := A_LoopField
ControlGet, hCtl, Hwnd,, % vCtlClassNN, % "ahk_id " hWnd
vOutput .= hCtl "`t" vCtlClassNN "`r`n"
}
MsgBox, % vOutput
Clipboard := vOutput
MsgBox, % "done"
return