Jump to content

Get Control ID from $hWnd


Recommended Posts

I have this function to get a controls ClassName from it's handle

Func GetClassName($hWnd)
 $Rt = DllCall("User32.dll", "int", "GetClassNameW", "HWND", $hWnd, "wstr", "", "int", 5000)
 If @error Or $Rt[0] = 0 Then Return SetError(1, 0, 0)
 Return SetError(0, 0, $Rt[2])
EndFunc   ;==>GetClassName

I'm now looking for the function to get the controlID instead...my edit's are inside a group, and the autoit window info is only able to focus on the outer group, and not the inner edits.

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

found a li'l workaround:

$hwnd = WinGetHandle("my win")
WinActivate($hwnd)
For $i = 0 To 100000
ControlSetText($hwnd, "", $i, $i)
Next

enhanced a bit:

WinActivate($hwnd)
For $i = 0 To 100000
$control = ControlGetHandle ( $hwnd, "", $i )
If IsHWnd ( $control ) Then
$Class = GetClassName($control)
ControlGetText ( $hwnd, "", $control )
 
ConsoleWrite ( "Class=[" & $Class & "], Handle=[" & $control & "], ID=[" & $i & "], Text=[" & $text & "]" & @CRLF )

EndIf
; ControlSetText($hwnd, "", $i, $i)
Next
Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

You can use _WinAPI_GetDlgCtrlID() to get the control id from the handle.

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...