Sign in to follow this  
Followers 0
whanenbu

UIAutomation Example Issues

4 posts in this topic

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

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

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

Share this post


Link to post
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
Sign in to follow this  
Followers 0

  • Similar Content

    • SorryButImaNewbie
      By SorryButImaNewbie
      Hello,
      I'm developing again (everybody ruuun! )
      I would like to develope a script that goes through basicly every user control on a window, and log things that happens, and maybe do some screenshots. I did something like this before.
      My problem, which I would like to avoid this time (to improve my understanding and skill) , was that when I was unable to get a ControlID or handler or anything, I simply did some math and clicked on the coordinates it should have been (for example, maxing the window, and knowing the initial set up I was ablo to calculate given control position). I know that this is a bad solution for a number of reasons. 
      Now I got authorization to install autoIT here, and i started to the work, AU3Info was unable to find anything on the window (this could be a problem, since autoIT doesn't see anything on it then, if I understood the help file) So I got the SimpleSpy script (source:
      )
      I added a bit of code to the original to display ID as well, what I received is this:
      Mouse position is retrieved 115-207
      At least we have an element title: [ADD] class: [Button] ID: [50000] (<-- coded this to display ID here as well)
      Having the following values for all properties: 
      Title is: <ADD>    Class   := <Button>    controltype:= <UIA_ButtonControlTypeId>    ,<50000>    , (0000C350)    10;187;120;35
      *** Parent Information top down ***
      3: Title is: <Compass>    Class   := <Window>    controltype:= <UIA_WindowControlTypeId>    ,<50032>    , (0000C370)    -8;-8;1936;1056
      "Title:=Compass;controltype:=UIA_WindowControlTypeId;class:=Window""    
      2: Title is: <>    Class   := <MainView>    controltype:= <UIA_CustomControlTypeId>    ,<50025>    , (0000C369)    0;23;1920;1017
      "Title:=;controltype:=UIA_CustomControlTypeId;class:=MainView""    
      1: Title is: <>    Class   := <TileNavigationView>    controltype:= <UIA_CustomControlTypeId>    ,<50025>    , (0000C369)    0;23;1920;967
      "Title:=;controltype:=UIA_CustomControlTypeId;class:=TileNavigationView""    
      0: Title is: <>    Class   := <AreasView>    controltype:= <UIA_CustomControlTypeId>    ,<50025>    , (0000C369)    0;132;1920;858
      "Title:=;controltype:=UIA_CustomControlTypeId;class:=AreasView""
       
      so far I wrote this script:
      WinActivate('Test') ;It works!! :D first official interaction Sleep(1000) ;1 sec sleep to be sure ControlClick('Test', '', '50000') If @error Then MsgBox($MB_SYSTEMMODAL, 'Error', 'ControlClick error') EndIf Sleep(1000) MsgBox(1,"Tracer message", 'ControlClick has happened') ;MouseClick() ;ControlCommand() AutoIt activates the window, but the click on the given button doesnt happen (I tried to write 50000 without ' ' on ID).
      M'I doing the @error part correctly ? (no error Msg has been displayed), sorry I rarely use AutoIT and seems to forget less and less after each neglect, but still I'm far from a proffessional
       
      Any help or suggestion is welcome, thank you for your time and insight!
    • bobmcrae
      By bobmcrae
      I am experimenting with UIAWrappers.au3 from junkew to complete an application which presents absolutely no control information using AutoIT Window Info.  While I am able to complete the form successfully, I am not happy with the speed.  As a benchmark, the simple Send method occurs in far less than 1-second, but the UIAutomation approach takes 3-seconds.  I am wondering whether performance gains may be achieved by specifying the controls more precisely; but I am unsure how to do that.  I was able to speed things up a bit by setting $UIA_DefaultWaitTime=0.  The controls of interest are 5-levels deep, as show in the simplespy output below.  It seems I do get faster response by specifying the target/top-level window, as show in the code below.  Any ideas?
      #include "UIAWrappers.au3" _UIA_setVar("Global.Debug", False) _UIA_setVar("Global.Debug.File", False) _UIA_setVar("Global.Highlight", False) _UIA_setVar("DPN","Title:=NC-stat DPNCheck Communicator;controltype:=UIA_WindowControlTypeId;class:=Window") _UIA_action('DPN','setFocus') _UIA_setVar("DPN.firstName","AutomationId:=txtFirstName") _UIA_setVar("DPN.lastName", "AutomationId:=txtLastName") _UIA_Action('DPN.lastName','setvalue','last name') _UIA_setVar("DPN.ID", "AutomationId:=txtSubjectId") _UIA_setVar("DPN.DOB", "AutomationId:=PART_TextBox") _UIA_setVar("DPN.Ft", "AutomationId:=txtSubjectHeight") _UIA_setVar("DPN.In", "AutomationId:=txtSubjectHeight2") _UIA_Action('DPN.firstName','setvalue','first name') _UIA_Action('DPN.ID','setvalue','ID012345') _UIA_Action('DPN.DOB','setvalue','1/31/1932') _UIA_Action('DPN.Ft','setvalue','6') _UIA_Action('DPN.In','setvalue','1') SimpleSpy output:
      ;~ *** Standard code *** #include "UIAWrappers.au3" AutoItSetOption("MustDeclareVars", 1) Local $oP4=_UIA_getObjectByFindAll($UIA_oDesktop, "Title:=NC-stat DPNCheck Communicator;controltype:=UIA_WindowControlTypeId;class:=Window", $treescope_children) _UIA_Action($oP4,"setfocus") Local $oP3=_UIA_getObjectByFindAll($oP4, "Title:=;controltype:=UIA_PaneControlTypeId;class:=Frame", $treescope_children) Local $oP2=_UIA_getObjectByFindAll($oP3, "Title:=;controltype:=UIA_TabControlTypeId;class:=TabControl", $treescope_children) Local $oP1=_UIA_getObjectByFindAll($oP2, "Title:=Patient;controltype:=UIA_TabItemControlTypeId;class:=TabItem", $treescope_children) Local $oP0=_UIA_getObjectByFindAll($oP1, "Title:=;controltype:=UIA_PaneControlTypeId;class:=Frame", $treescope_children) ;~ First find the object in the parent before you can do something ;~$oUIElement=_UIA_getObjectByFindAll(".mainwindow", "title:=;ControlType:=UIA_EditControlTypeId", $treescope_subtree) Local $oUIElement=_UIA_getObjectByFindAll($oP0, "title:=;ControlType:=UIA_EditControlTypeId", $treescope_subtree) _UIA_action($oUIElement,"click")  
    • souldjer777
      By souldjer777
      Good Morning All,

      I'm using the latest UIA_V0_51 on XP and Windows 7 x64. I'm able to see focus, elements and all options under Windows XP for SimpleSpy - but not on Windows 7 x64. With Windows 7 x64 all I can focus on is the window frame. Very odd.     I've tried running simplespy "#AutoIt3Wrapper_UseX64=n" and the app under x32 on the Windows 7 x64 device. Please let me know what I am doing wrong. I believe this is a simple thing I am overlooking... Thank you AutoIT Gurus!!! YOU ARE THE BEST!!!
      Thanks