ExpertNoob Posted July 19, 2009 Share Posted July 19, 2009 How to list all child controls of a given window/GUI? Link to comment Share on other sites More sharing options...
Authenticity Posted July 19, 2009 Share Posted July 19, 2009 (edited) #include <Array.au3> #include <Constants.au3> #include <WinAPI.au3> Global $avChildren Run('calc.exe') WinWaitActive('Calculator') $hWnd = WinGetHandle('Calculator') WinListChildren($hWnd, $avChildren) _ArrayDisplay($avChildren) Exit Func WinListChildren($hWnd, ByRef $avArr) If UBound($avArr, 0) <> 2 Then Local $avTmp[10][2] = [[0]] $avArr = $avTmp EndIf Local $hChild = _WinAPI_GetWindow($hWnd, $GW_CHILD) While $hChild If $avArr[0][0]+1 > UBound($avArr, 1)-1 Then ReDim $avArr[$avArr[0][0]+10][2] $avArr[$avArr[0][0]+1][0] = $hChild $avArr[$avArr[0][0]+1][1] = _WinAPI_GetWindowText($hChild) $avArr[0][0] += 1 WinListChildren($hChild, $avArr) $hChild = _WinAPI_GetWindow($hChild, $GW_HWNDNEXT) WEnd ReDim $avArr[$avArr[0][0]+1][2] EndFunc Don't list all child controls of me Edited July 19, 2009 by Authenticity mLipok and tarretarretarre 1 1 Link to comment Share on other sites More sharing options...
ExpertNoob Posted July 19, 2009 Author Share Posted July 19, 2009 Exactly what I needed! Thank you Authenticity Link to comment Share on other sites More sharing options...
corgano Posted September 5, 2013 Share Posted September 5, 2013 I have multiple IE windows with file select dialogues open, and trying to determine which open file dialogue goes to which IE window That script outputs a lot of handles, which is cool, and I Can get the handle of the window using Au3InfoTool, but the handle of the dialogue does not appear on the list of children the script generates help? Or would it be easier to determine the child's parent window? 0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e Link to comment Share on other sites More sharing options...
corgano Posted September 5, 2013 Share Posted September 5, 2013 (edited) Alright, so looking backwards for the parent works rather well although this makes sense, usually things only have a couple parents.. Func _IE_GetFileSelectWindow($hIE) for $i = 1 to 99999 $child = WinGetHandle("[CLASS:#32770; INSTANCE:"&$i&"]","") if @error and $i > 10 then return 0 $parent = _WinAPI_GetParent($child) If $parent = $hIE Then Return $child Next EndFunc Code, for anyone who would like it. might come in useful Edited September 5, 2013 by corgano 0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e Link to comment Share on other sites More sharing options...
corgano Posted November 14, 2013 Share Posted November 14, 2013 ...and I'm back! While looking backwards from the child for the parent works on older IE versions, the new IE10 seems to break this :/. How can a child window not have $oIE as it's parent? I've tried using your sample a few posts up to list the children, and check if the handle of the dialog is on that list, but it isn't. Any ideas? #include <IE.au3> #include <WinAPI.au3> #include <Array.au3> #include <Constants.au3> ;go to google.com, go to images, click upload an image, click browse ;this should give you a nice file upload box you can test on $oIE = _IEAttach("Google Images") $hWnd = _IEPropertyGet($oIE, "hwnd") Global $avChildren WinListChildren($hWnd, $avChildren) _ArrayDisplay($avChildren) Exit Func WinListChildren($hWnd, ByRef $avArr) If UBound($avArr, 0) <> 2 Then Local $avTmp[10][2] = [[0]] $avArr = $avTmp EndIf Local $hChild = _WinAPI_GetWindow($hWnd, $GW_CHILD) While $hChild If $avArr[0][0]+1 > UBound($avArr, 1)-1 Then ReDim $avArr[$avArr[0][0]+10][2] $avArr[$avArr[0][0]+1][0] = $hChild $avArr[$avArr[0][0]+1][1] = _WinAPI_GetWindowText($hChild) $avArr[0][0] += 1 WinListChildren($hChild, $avArr) $hChild = _WinAPI_GetWindow($hChild, $GW_HWNDNEXT) WEnd ReDim $avArr[$avArr[0][0]+1][2] EndFunc 0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now