Jump to content
Sign in to follow this  

List Controls

Recommended Posts


Alright, so a twist on the code from _WinGetCtrlInfo(), . Eventually, Ill have it list the control class, ID, and names of the controls of the active window to a text file. We do alot of automations of drivers and software, and by making it easier for our install technicians to log this stuff will help me alot.

Im new to DLL's, and it's starting to become a headache for me. I keep getting blank as the result of $wintext. Im sure I just have something wrong in the DLLCall.

Anyone know DLL's well enough to give me a hand? Thanks in advance.

HotKeySet("!^s", "capture")

While 1

func capture()
Global $Array = _WinGetCtrlInfo(WingetTitle("[ACTIVE]"))
Global $sOne = '[0][0] = ' & $Array[0][0] & @CR, $sTwo
For $iCC = 1 To $Array[0][0]
    $sOne &= '[' & $iCC & '][0] = ' & $Array[$iCC][0] & @CR
    $sTwo &= '[' & $iCC & '][1] = ' & $Array[$iCC][1] & @CR
winactivate("Untitled - Notepad")
MsgBox(64, 'WinInfo', StringTrimRight($sOne, 1) & @CR & StringTrimRight($sTwo, 1))

Func _WinGetCtrlInfo($hWin)
    If IsString($hWin) Then $hWin = WinGetHandle($hWin)
    Local $sClassList = WinGetClassList($hWin), $iAdd = 1, $aDLL, $ctrl_hwnd, $sHold
    Local $aSplitClass = StringSplit(StringTrimRight($sClassList, 1), @LF), $aReturn[1][2]
    For $iCount = $aSplitClass[0] To 1 Step - 1
        Local $nCount = 0
        While 1
            $nCount += 1
            If ControlGetHandle($hWin, '', $aSplitClass[$iCount] & $nCount) = '' Then ExitLoop
            If Not StringInStr(Chr(1) & $sHold, Chr(1) & $aSplitClass[$iCount] & $nCount & Chr(1)) Then
                $sHold &= $aSplitClass[$iCount] & $nCount & Chr(1)
                $iAdd += 1
                ReDim $aReturn[$iAdd][2]
                $aReturn[$iAdd - 1][0] = $aSplitClass[$iCount] & $nCount

;something below here is wrong-------------------------------------------------------------------------------------------------------------------
                $aDLL = DllCall('User32.dll', 'int', 'GetDlgCtrlID', 'hwnd', ControlGetHandle($hWin, '', $aSplitClass[$iCount] & $nCount))       
                $DLLstr   = DllStructCreate("char var1[128]")
                $aDLL1 =  DLLCall("user32.dll","str","GetDlgItemText","hwnd",ControlGetHandle($hWin, '', $aSplitClass[$iCount] & $nCount),"int",$aDLL[0],"LPTSTR",DllStructGetPtr($DLLstr, "var1"))
                $wintext = DllStructGetData($DLLstr,1)
;something above here is wrong-------------------------------------------------------------------------------------------------------------------

                If @error = 0 Then
                    $aReturn[$iAdd - 1][1] = $wintext
                    $aReturn[$iAdd - 1][1] = @error
    $aReturn[0][0] = $iAdd - 1
    Return $aReturn

Share this post

Link to post
Share on other sites

Nevermind, Im dumb. ControlGetText () does exactly what I need.

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  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.