Jump to content

Recommended Posts

Posted (edited)

Hi there, 

I'm new in AutoIt forms and using AutoIt to automate desktop application (able to automate the application normally but facing issue when I've to re-run the application twice within the same script...so need help in this please)

here is the steps then followed by the issue in a brief : 

1- run application . 

2- do some actions (click menus,activate windows,set texts..)

3- close the application. 

4- run the application again & access the same controls.

5- open the same windows again (like step 2)

6- perform some validations (by getting texts from some text boxes)

7- close the application again (and repeat 1-7 for 15 times in average )

The issue 

* all controls are accessible in the first run and actions done successfully on controls (for steps 1-3) BUT from the second run of the application from step-4 it's able to set focus only the main application window.

Note: only unique properties used to while mapping the controls. 

Error that appear in the console :

UIAWrappers.au3" (1673) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:
$x = Int($t[1] + ($t[3] / 2))
$x = Int($t[1] + (^ ERROR

 

Simple spy code  of one of the controls that has this strange issue(menubar&view menu Item): 

;~ *** Standard code maintainable ***
#include "UIAWrappers.au3"
AutoItSetOption("MustDeclareVars", 1)

_UIA_setVar("oP1","Title:=XXX;controltype:=UIA_WindowControlTypeId;class:=WindowsForms10.Window.8.app") ;main app form xxx
_UIA_setVar("oP2","Title:=menuStrip1;controltype:=UIA_MenuBarControlTypeId;class:=WindowsForms10.Window.8.app") ;menuStrip1

;~ $oUIElement=_UIA_getObjectByFindAll("View.mainwindow", "title:=View;ControlType:=UIA_MenuItemControlTypeId", $treescope_subtree)
_UIA_setVar("oUIElement","Title:=View;controltype:=UIA_MenuItemControlTypeId;class:=") ;ControlType:=UIA_MenuItemControlTypeId;classname:=")

;~ Actions split away from logical/technical definition above can come from configfiles 

;~_UIA_Action("oP1","highlight")
_UIA_Action("oP1","setfocus")
;~_UIA_Action("oP2","highlight")
_UIA_Action("oP2","setfocus")

_UIA_action("oUIElement","highlight")
;~_UIA_action("oUIElement","click")

 

 

Edited by Sayed
Posted (edited)

Thanks a lot @junkew for your reply. 

I tried to search the fourms about how to clear the array found the following in one of your replies before: 

Func UIAResetRTIVars()

    MsgBox("", "reset", "reset", 1)

    ;_ArrayDisplay($UIA_Vars)

    for $i=(ubound($uia_vars, 1)-1) to 0 step -1
        if stringleft($uia_vars[$i][0],stringlen($cRTI_Prefix))=$cRTI_Prefix Then
            _ArrayDelete($UIA_Vars,$i)
            ;_ArrayDelete($UIA_Vars,32)
        EndIf
    next
    MsgBox("", "reset", "Finished", 1)
EndFunc

 & I add it in my code and call this function at the end of the first run...seeing the msg boxs of reset,finished appear after the first run done.

BUT the issue now is the execution is terminated once launch the application in the second run....any advice about this strange issue ???

- also is this mean after clearing at the end of the first run , once the second run start it will declare the variables again -as I'm declaring the variable using setvar in the beginning before doing actions -???

Edited by Sayed
Posted (edited)

Probably its enough to comment this out in uiawrappers instead of IUAResetRTIVars. In future I will make this caching of runtime type information different anyway (if I keep it in at all)

;~      Add element to runtime information object reference
        If IsString($p1) Then
            _UIA_LOG("Storing in RTI as RTI." & $p1 & @CRLF, $UIA_Log_Wrapper)
            _UIA_setVar("RTI." & StringUpper($p1), $UIA_oUIElementFound)
        EndIf

these RTI vars are more important to stay in as that determines context where to search but also these can hamper your 2nd run

local $rtiElements[]= ["RTI.LASTELEMENT", "RTI.FOCUSEDELEMENT", "RTI.PARENT","RTI.FOCUSEDELEMENT", "RTI.SEARCHCONTEXT", "RTI.MAINWINDOW", "RTI.DESKTOP"]

 

Edited by junkew
  • 3 weeks later...
  • 3 years later...
Posted

Hi,

@Sayed can you please post your solution?

I have the same problem in 2nd run and comment this out was not the solution.

;~      Add element to runtime information object reference
        If IsString($p1) Then
            _UIA_LOG("Storing in RTI as RTI." & $p1 & @CRLF, $UIA_Log_Wrapper)
            _UIA_setVar("RTI." & StringUpper($p1), $UIA_oUIElementFound)
        EndIf

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
×
×
  • Create New...