Jump to content

UIAutomation check if OBJECT exists


Recommended Posts

I'm working on a script that does Auto-Log in for me. it looks like this :

#include "UIAWrappers.au3"

If ProcessExists("Advanced Dashboard.exe") Then
Else
    Run("C:\Program Files (x86)\Advanced Dashboard\Advanced Dashboard.exe")
EndIf

sleep(1000)

    Local $oP6=_UIA_getObjectByFindAll($UIA_oDesktop, "Title:=Advanced Dashboard", $treescope_children)

    Local $oP5=_UIA_getObjectByFindAll($oP6, "Title:=;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.34f5582_r9_ad1", $treescope_children)

    Local $oP4=_UIA_getObjectByFindAll($oP5, "Title:=;controltype:=UIA_PaneControlTypeId;class:=Shell Embedding", $treescope_children)

    Local $oP3=_UIA_getObjectByFindAll($oP4, "Title:=;controltype:=UIA_PaneControlTypeId;class:=Shell DocObject View", $treescope_children)

    Local $oP2=_UIA_getObjectByFindAll($oP3, "controltype:=UIA_PaneControlTypeId;class:=Internet Explorer_Server", $treescope_children)

    _UIA_Action($oP2,"setfocus")

Local $oP1=_UIA_getObjectByFindAll($oP2, "Title:=WebBroker Login;controltype:=UIA_PaneControlTypeId;class:=", $treescope_children)

Local $oP0=_UIA_getObjectByFindAll($oP1, "Title:=;controltype:=UIA_GroupControlTypeId;class:=", $treescope_children)

Local $oUIElement1=_UIA_getObjectByFindAll($oP0, "title:=Password;ControlType:=UIA_EditControlTypeId", $treescope_subtree)
;~_UIA_action($oUIElement,"highlight")
_UIA_action($oUIElement1,"click")
Send("*****")

Local $oUIElement2=_UIA_getObjectByFindAll($oP0, "title:=Login;ControlType:=UIA_ButtonControlTypeId", $treescope_subtree)
;~_UIA_action($oUIElement,"highlight")
_UIA_action($oUIElement2,"click")

Is there a way to check if "$oUIElement1" exists before I enter my password?

I want my script to wait for "$oUIElement1" object to be present in-order to to do a log-in and do not rely on Sleep(1000). Thank you in advance!

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

×
×
  • Create New...