Jump to content

UIAutomation Example Issues


Recommended Posts

Have to start learning UIAutomation since I need to use MS EDGE or Chrome.  I downloaded Examples_V0_5.zip and UIA_V0_51.zip.

Compiled simplespy.au3 to get started.  Appears to work.  Did Ctrl+R and get error Line 15226 Error: Subscript used on non-accessible variable.  What am I doing wrong?

Example 1 tried to run.  It was missing CUIAutomation2.au3.  Moved it into folder from UIA.zip to Examples and now works.

Example 2 failed.  Added switch to case 0409 and "Start" and it worked.

Example 3 failed. Can't fix.

Code starting at Line 50. 

Consolewrite("Get the menu that is after the start button" & @crlf)

$oMenuStart=_UIA_getFirstObjectOfElement($UIA_oDesktop,"Start Menu", $treescope_children)  "I tried Start, Menu Start, and Start Menu, none seem to work." 
if isobj($oMenuStart) Then
    consolewrite("Menu start found" & @crlf)
Else
    consolewrite("I bet the text has to change to Start instead of Starten" & @crlf)
EndIf

 Console:

Get the menu that is after the start button
I bet the text has to change to Start instead of Starten
"C:\Users\xxxx\Autoit Scripts\UI Automation\EXAMPLES_V0_5\UIAWrappers.au3" (1726) : ==> Variable must be of type "Object".:
$t = $obj.Findfirst($treeScope, $oCondition, $UIA_pUIElement)
$t = $obj^ ERROR

 

Example 4 fails the same as in see below.

Code starting at Line 30

;~ Start the calculator and notepad
run("calc.exe")
run("notepad.exe")

$oCalc=_UIA_getFirstObjectOfElement($UIA_oDesktop,"class:=" & $cCalcClassname, $treescope_children)
$oNotepad=_UIA_getFirstObjectOfElement($UIA_oDesktop,"class:="& $cNotepadClassName, $treescope_children)

if isobj($oCalc) Then

;~ You can comment this out just there to get the names of whats available under the calc window
_UIA_DumpThemAll($oCalc,$treescope_subtree)

    $oButton=_UIA_getFirstObjectOfElement($oCalc,"name:=" & $cButton1, $treescope_subtree)
    $oInvokeP=_UIA_getpattern($oButton,$UIA_InvokePatternID)
    $oInvokeP.Invoke()
ConsoleWrite("I am hee" )
    $oButton=_UIA_getFirstObjectOfElement($oCalc,"name:=" & $cButtonAdd, $treescope_subtree)
    $oInvokeP=_UIA_getpattern($oButton,$UIA_InvokePatternID)
    $oInvokeP.Invoke()  This is where it fails

Console:

Example text is for dutch calculator so please change text to english or other language to identify controls
"C:\Users\xxxxxxxxxxx\Autoit Scripts\UI Automation\EXAMPLES_V0_5\ex4_calculator.au3" (44) : ==> Variable must be of type "Object".:
$oInvokeP.Invoke()
$oInvokeP^ ERROR

There must me something I am missing on why these codes are not working. XML file below of example 4.

 

 

20160404-232725402.XML

Link to comment
Share on other sites

OK, I will look.  Would this be the same for example 3 above?  The XML log indicated it was Start Menu.

 

Now I understand.  The buttons on the calculator need to match current system for it to work.

Edited by whanenbu
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...