Jump to content

Get property/status of control from _UIA_getObjectByFindAll


VBScab
 Share

Recommended Posts

I am trying to "test" the value of a variable that's returned by the function '_UIA_getObjectByFindAll' (see code below).

I was expecting it to be as simple as a Boolean test. However, the code just loops until the timer runs out, as my variable '$objKey_Finish' seemingly never gets set.

If I uncomment this line:

;_UIA_action($objKey_Finish,"click")

the button gets clicked but, even so, the loop isn't exited until the timer runs out.

BTW, I have to use the stuff from UIWrapper.au3 as the Window Info tool is unable to get the various window handles, class names, etc. from the application. As seasoned AutoIters will spot, the code in the loop is lifted pretty much straight from 'SimplySpy.au3', just with the variable names changed to suit my naming convention.

Here's my code:

#include "Include\APISysConstants.au3"
#include "Include\CUIAutomation2.au3"
#include "Include\EditConstants.au3"
#include "Include\GUIConstantsEx.au3"
#include "Include\GUIEdit.au3"
#include "Include\GUIMenu.au3"
#include "Include\ISimpleDOM.au3"
#include "Include\MSAccessibility.au3"
#include "Include\Misc.au3"
#include "Include\UIAWrappers.au3"
#include "Include\WinAPI.au3"
#include "Include\WinAPIProc.au3"
#include "Include\WinAPISys.au3"
#include "Include\WindowsConstants.au3"

AutoItSetOption("MustDeclareVars", 1)

Dim $strEXE = $CmdLine[1]
Dim $strWindowTitle = "OpenStudio built using CMake Setup"
Dim $intKeyCount = 5
Dim $intCount

Run($strEXE)
WaitForPopUp($strWindowTitle)
Exit

Func WaitForPopUp(ByRef $strWindowTitle)
    ; Wait for a window with the title "$strWindowTitle" to pop up
    ; then press the Enter key $intKeyCount times
    WinWait($strWindowTitle)

    Do
        Sleep(500)
        WinActivate($strWindowTitle)
        Send("{ENTER}")
        $intCount = $intCount + 1
    Until $intCount = $intKeyCount

    ; Wait 20 minutes for a window with the title "$strWindowTitle" to pop up
    ; then press the Finish key.

    Local $datStartTime = TimerInit()
    Local $objKey_Finish = False
    Local $objMainWindow
    Local $objKey_Finish_Parent
    Local $objKey_Finish

    While (TimerDiff($datStartTime) < (20 * 60000) And Not $objKey_Finish)
        Sleep(3000)

        WinActivate($strWindowTitle)

        ; Set $objMainWindow by finding the window with the title "OpenStudio built using CMake Setup"
        $objMainWindow=_UIA_getObjectByFindAll($UIA_oDesktop, "Title:=OpenStudio built using CMake Setup;controltype:=UIA_WindowControlTypeId;class:=Qt5QWindowIcon", $treescope_children)

        ; Change focus to that window
        _UIA_Action($objMainWindow,"setfocus")

        ; Set $objKey_Finish_Parent by finding the window with the title "Finish Enter"
        $objKey_Finish_Parent=_UIA_getObjectByFindAll($objMainWindow, "Title:=;controltype:=UIA_CustomControlTypeId;class:=", $treescope_children)

        ; Set objKey_Finish_Parent by finding the UI element in the parent's window list
        $objKey_Finish=_UIA_getObjectByFindAll($objKey_Finish_Parent, "title:=Finish Enter;ControlType:=UIA_ButtonControlTypeId", $treescope_subtree)

        ;_UIA_action($objKey_Finish,"click")
    Wend


    If ($objKey_Finish) Then
MsgBox($MB_OK,"3",$objKey_Finish)
        ; Now that we've found it, click it
        _UIA_action($objKey_Finish,"click")

ConsoleWrite("0")
        Return 0
    Else
ConsoleWrite("1")
        Return 1
    EndIf
EndFunc

 

Link to comment
Share on other sites

check on

isobj($objKey_Finish,"click"))

 

highlighting helps

_UIA_action($objKey_Finish,"highlight")
_uia_getPropertyValue($objKey_Finish,"<your property")

See UIWrapper source for details on the properties you can get

 

Edited by junkew
Link to comment
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
 Share

  • Recently Browsing   0 members

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