Jump to content

Recommended Posts

Posted (edited)
#include <Array.au3>
#include <WinAPI.au3>


GetAllWindowsControls(WinGetHandle("Sem título - Bloco de Notas"))

Func GetAllWindowsControls($hCallersWindow, $bOnlyVisible=Default, $sStringIncludes=Default, $sClass=Default)
    If Not IsHWnd($hCallersWindow) Then
        ConsoleWrite("$hCallersWindow must be a handle...provided=[" & $hCallersWindow & "]" & @CRLF)
        Return False
    EndIf
    ; Get all list of controls
    If $bOnlyVisible = Default Then $bOnlyVisible = False
    If $sStringIncludes = Default Then $sStringIncludes = ""
    If $sClass = Default Then $sClass = ""
    $sClassList = WinGetClassList($hCallersWindow)

    ; Create array
    $aClassList = StringSplit($sClassList, @CRLF, 2)

    ; Sort array
    _ArraySort($aClassList)
    _ArrayDelete($aClassList, 0)

    ; Loop
    $iCurrentClass = ""
    $iCurrentCount = 1
    $iTotalCounter = 1

    If StringLen($sClass)>0 Then
        For $i = UBound($aClassList)-1 To 0 Step - 1
            If $aClassList[$i]<>$sClass Then
                _ArrayDelete($aClassList,$i)
            EndIf
        Next
    EndIf

    For $i = 0 To UBound($aClassList) - 1
        If $aClassList[$i] = $iCurrentClass Then
            $iCurrentCount += 1
        Else
            $iCurrentClass = $aClassList[$i]
            $iCurrentCount = 1
        EndIf

        $hControl = ControlGetHandle($hCallersWindow, "", "[CLASSNN:" & $iCurrentClass & $iCurrentCount & "]")
        $text = StringRegExpReplace(ControlGetText($hCallersWindow, "", $hControl), "[\n\r]", "{@CRLF}")
        $aPos = ControlGetPos($hCallersWindow, "", $hControl)
        $sControlID = _WinAPI_GetDlgCtrlID($hControl)
        $bIsVisible = ControlCommand($hCallersWindow, "", $hControl, "IsVisible")
        If $bOnlyVisible And Not $bIsVisible Then
            $iTotalCounter += 1
            ContinueLoop
        EndIf

        If StringLen($sStringIncludes) > 0 Then
            If Not StringInStr($text, $sStringIncludes) Then
                $iTotalCounter += 1
                ContinueLoop
            EndIf
        EndIf

        If IsArray($aPos) Then ConsoleWrite("Handle=" & StringFormat("%10s", $hControl) &@CRLF)

        If Not WinExists($hCallersWindow) Then ExitLoop
        $iTotalCounter += 1
    Next
EndFunc   ;==>GetAllWindowsControls

Using the script above to find the handle of hidden controls, the result is given here in $hControl:

If IsArray($aPos) Then ConsoleWrite("Handle=" & StringFormat("%10s", $hControl) &@CRLF)

 

Handle=0x00951400
Handle=0x00E812AA

 

How can i split those multiple values, into a single variable like 
$X = 0x00951400
$X2 = 0x00E812AA

I already tried: stringsplit, stringtrim, and many other things 😭

Edited by memerim
Posted (edited)

Just add them to an array instead of using ConsoleWrite otherwise you could use Assign/Eval to configure individual variables, but an array would be easier to manage.

Example:

#include <Array.au3>
#include <WinAPI.au3>

Global $aHandles[0]
GetAllWindowsControls(WinGetHandle("Sem título - Bloco de Notas"))
_ArrayDisplay($aHandles)

Func GetAllWindowsControls($hCallersWindow, $bOnlyVisible=Default, $sStringIncludes=Default, $sClass=Default)
   ...
   ;~ Replace: If IsArray($aPos) Then ConsoleWrite("Handle=" & StringFormat("%10s", $hControl) & @CRLF)
   If IsArray($aPos) Then _ArrayAdd($aHandles, StringFormat("%10s", $hControl))
   ...
EndFunc

 

Edited by Subz
Posted (edited)

or do both, and just keep making variables

*edit 2: found old scripts where folks are doing this, am now curious if it was ancillary or unnecessary

#include<array.au3>

local $aHandle[2]=["0x00951400" , "0x00E812AA"]

_ArrayDisplay($aHandle)

for $i = 0 to ubound($aHandle) - 1
   assign("x" & $i , $aHandle[$i])
Next

msgbox(0, '' , eval("x0") & @LF & eval("x1"))

 

Edited by iamtheky

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

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
×
×
  • Create New...