Sign in to follow this  
Followers 0
riki381

How to get all controls in a window

3 posts in this topic

Hi,

Im a newbie and i would appreciate any help.

My question is:

How can you get all controls in a window, if all you have is the window handle?

I have this exe window, but i dont know which controls were used in this application.

Thanks,

riki381

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

#include "Array.au3"
Opt("WinTitleMatchMode", 4)
$aArray = _WinGetControls('[class:Shell_TrayWnd]')
_ArrayDisplay($aArray)


Func _WinGetControls($Title, $Text="")
Local $WndControls, $aControls, $sLast="", $n=1
$WndControls = WinGetClassList($Title, $Text)
$aControls = StringSplit($WndControls, @CRLF)
Dim $aResult[$aControls[0]+1][2]
For $i = 1 To $aControls[0]
    If $aControls[$i] <> "" Then
        If $sLast = $aControls[$i] Then 
            $n+=1
        Else
            $n=1
        EndIf
        $aControls[$i] &= $n
        $sLast = StringTrimRight($aControls[$i],1)
    EndIf
    If $i < $aControls[0] Then 
        $aResult[$i][0] = $aControls[$i]
    Else ; last item in array
        $aResult[$i][0] = WinGetTitle($Title) ; return WinTitle
    EndIf
    $aResult[$i][1] = ControlGetHandle($Title, $Text, $aControls[$i])   
Next
$aResult[0][0] = "ClassnameNN"
$aResult[0][1] = "Handle"
Return $aResult
EndFunc

this should do the trick :)

Edited by iLoveAU3

Share this post


Link to post
Share on other sites

Thanks, this help me a lot

Share this post


Link to post
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
Sign in to follow this  
Followers 0