Jump to content

Recommended Posts

Posted

Hi, I've searched and not come up with much. I would like to get the controlID of a text label based on what the text is. So, if I have several labels in a WindowsForm and one of them is "This Text String", I want to get the controlID of that particular label. I haven't found a way to get that, based on the text in the control. Any ideas out there?

I appreciate it.

Posted

More specifically I need to get the classnameNN from the text string. I did figure out to use ControlGetHandle to get the handle of the controlID, but now I need to get the classnameNN of that handle.

Posted

The classnameNN changes from machine to machine, installation to installation, for this particular dialog. I need to get the classnameNN of a particular label (the text in that label is always the same), so that I can reference another label (which has text that changes) and read its text.

Basically I'm trying to read the version number of an installed piece of software from a dialog that lists a bunch of Excel extensions.

Posted
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
 
    Global $avChildren
    Local $hWinHan = ControlGetHandle("Options", "", "[CLASS:WindowsForms10.Window.8.app.0.27c59a_r77_ad1; INSTANCE:2]")
    Sleep($sm_sleep)
    WinListChildren($hWinHan, $avChildren)
    Local $vValue = "Hyperion Strategic Planning"
    Sleep($sm_sleep)
    $ArrIndex = _ArraySearch($avChildren, $vValue)
    $ArrIndexVersion = $ArrIndex - 2
    Local $iStart_Row = $ArrIndexVersion
    $VersionString = _ArrayToString($avChildren, "|", $ArrIndexVersion, $ArrIndexVersion, "-", 1, 1)

    Global $buildno = $VersionString
    Sleep($sm_sleep)
    Local $LogMsg = "INFO: Installed version is " & $buildno & "."
    _FileWriteLog(@ScriptDir & $logfile, $LogMsg)

 

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
  • Recently Browsing   0 members

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