Sign in to follow this  
Followers 0
dubi

UIAutomation of a (Sub)-window

16 posts in this topic

Hi,

Apologies for the long posting but I wanted to be complete with the information :-)

I have a window of an application (see attachement) from which I want to read the content and where I want to set the content. The output of simple spy looks as follows (ctrl-w in the black area):

Spoiler

Mouse position is retrieved 421-384
At least we have an element title: [] class: [Afx:6be0000:2b]

Having the following values for all properties:
Title is: <>    Class   := <Afx:6be0000:2b>    controltype:= <UIA_PaneControlTypeId>    ,<50033>    , (0000C371)    221;641;1022;601
*** Parent Information top down ***
5: Title is: <Investox - [testprojekt]>    Class   := <ThunderRT6MDIForm>    controltype:= <UIA_WindowControlTypeId>    ,<50032>    , (0000C370)    0;237;1868;1122
"Title:=Investox - [testprojekt];controltype:=UIA_WindowControlTypeId;class:=ThunderRT6MDIForm""    
4: Title is: <Handelssystem einstellen>    Class   := <ThunderRT6FormDC>    controltype:= <UIA_WindowControlTypeId>    ,<50032>    , (0000C370)    169;396;1319;901
"Title:=Handelssystem einstellen;controltype:=UIA_WindowControlTypeId;class:=ThunderRT6FormDC""    
3: Title is: <>    Class   := <ThunderRT6UserControlDC>    controltype:= <UIA_PaneControlTypeId>    ,<50033>    , (0000C371)    183;454;1289;823
"Title:=;controltype:=UIA_PaneControlTypeId;class:=ThunderRT6UserControlDC""    
2: Title is: <>    Class   := <ThunderRT6PictureBoxDC>    controltype:= <UIA_PaneControlTypeId>    ,<50033>    , (0000C371)    191;497;1084;772
"Title:=;controltype:=UIA_PaneControlTypeId;class:=ThunderRT6PictureBoxDC""    
1: Title is: <>    Class   := <ThunderRT6UserControlDC>    controltype:= <UIA_PaneControlTypeId>    ,<50033>    , (0000C371)    217;585;1030;660
"Title:=;controltype:=UIA_PaneControlTypeId;class:=ThunderRT6UserControlDC""    
0: Title is: <>    Class   := <ThunderRT6PictureBoxDC>    controltype:= <UIA_PaneControlTypeId>    ,<50033>    , (0000C371)    221;641;1022;601
"Title:=;controltype:=UIA_PaneControlTypeId;class:=ThunderRT6PictureBoxDC""    


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

_UIA_setVar("oP1","Title:=Investox - [testprojekt];controltype:=UIA_WindowControlTypeId;class:=ThunderRT6MDIForm")    ;Investox - [testprojekt]
_UIA_setVar("oP2","Title:=Handelssystem einstellen;controltype:=UIA_WindowControlTypeId;class:=ThunderRT6FormDC")    ;Handelssystem einstellen
_UIA_setVar("oP3","Title:=;controltype:=UIA_PaneControlTypeId;class:=ThunderRT6UserControlDC")    ;
_UIA_setVar("oP4","Title:=;controltype:=UIA_PaneControlTypeId;class:=ThunderRT6PictureBoxDC")    ;
_UIA_setVar("oP5","Title:=;controltype:=UIA_PaneControlTypeId;class:=ThunderRT6UserControlDC")    ;
_UIA_setVar("oP6","Title:=;controltype:=UIA_PaneControlTypeId;class:=ThunderRT6PictureBoxDC")    ;

_UIA_setVar(".mainwindow","title:=;classname:=Afx:6be0000:2b")

;~ 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("oP3","highlight")
_UIA_Action("oP3","setfocus")
;~_UIA_Action("oP4","highlight")
_UIA_Action("oP4","setfocus")
;~_UIA_Action("oP5","highlight")
_UIA_Action("oP5","setfocus")
;~_UIA_Action("oP6","highlight")
_UIA_Action("oP6","setfocus")

_UIA_action(".mainwindow","setfocus")


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

Local $oP5=_UIA_getObjectByFindAll($UIA_oDesktop, "Title:=Investox - [testprojekt];controltype:=UIA_WindowControlTypeId;class:=ThunderRT6MDIForm", $treescope_children)    
_UIA_Action($oP5,"setfocus")
Local $oP4=_UIA_getObjectByFindAll($oP5, "Title:=Handelssystem einstellen;controltype:=UIA_WindowControlTypeId;class:=ThunderRT6FormDC", $treescope_children)    
_UIA_Action($oP4,"setfocus")
Local $oP3=_UIA_getObjectByFindAll($oP4, "Title:=;controltype:=UIA_PaneControlTypeId;class:=ThunderRT6UserControlDC", $treescope_children)    
_UIA_Action($oP3,"setfocus")
Local $oP2=_UIA_getObjectByFindAll($oP3, "Title:=;controltype:=UIA_PaneControlTypeId;class:=ThunderRT6PictureBoxDC", $treescope_children)    
_UIA_Action($oP2,"setfocus")
Local $oP1=_UIA_getObjectByFindAll($oP2, "Title:=;controltype:=UIA_PaneControlTypeId;class:=ThunderRT6UserControlDC", $treescope_children)    
_UIA_Action($oP1,"setfocus")
Local $oP0=_UIA_getObjectByFindAll($oP1, "Title:=;controltype:=UIA_PaneControlTypeId;class:=ThunderRT6PictureBoxDC", $treescope_children)    
_UIA_Action($oP0,"setfocus")
_UIA_setVar(".mainwindow","title:=;classname:=Afx:6be0000:2b")
_UIA_action(".mainwindow","setfocus")


*** Detailed properties of the highlighted element ***
UIA_class:= <Afx:6be0000:2b>
UIA_regexpclass:= <Afx:6be0000:2b>
UIA_iaccessiblechildId:= <0>
UIA_handle:= <983764>
UIA_RuntimeId:= <42;983764>
UIA_BoundingRectangle:= <221;641;1022;601>
UIA_ProcessId:= <1812>
UIA_ControlType:= <50033>
UIA_LocalizedControlType:= <pane>
UIA_HasKeyboardFocus:= <True>
UIA_IsKeyboardFocusable:= <True>
UIA_IsEnabled:= <True>
UIA_ClassName:= <Afx:6be0000:2b>
UIA_Culture:= <0>
UIA_IsControlElement:= <True>
UIA_IsContentElement:= <True>
UIA_IsPassword:= <False>
UIA_NativeWindowHandle:= <983764>
UIA_IsOffscreen:= <True>
UIA_Orientation:= <0>
UIA_FrameworkId:= <Win32>
UIA_IsRequiredForForm:= <False>
UIA_IsDockPatternAvailable:= <False>
UIA_IsExpandCollapsePatternAvailable:= <False>
UIA_IsGridItemPatternAvailable:= <False>
UIA_IsGridPatternAvailable:= <False>
UIA_IsInvokePatternAvailable:= <False>
UIA_IsMultipleViewPatternAvailable:= <False>
UIA_IsRangeValuePatternAvailable:= <False>
UIA_IsScrollPatternAvailable:= <False>
UIA_IsScrollItemPatternAvailable:= <False>
UIA_IsSelectionItemPatternAvailable:= <False>
UIA_IsSelectionPatternAvailable:= <False>
UIA_IsTablePatternAvailable:= <False>
UIA_IsTableItemPatternAvailable:= <False>
UIA_IsTextPatternAvailable:= <False>
UIA_IsTogglePatternAvailable:= <False>
UIA_IsTransformPatternAvailable:= <False>
UIA_IsValuePatternAvailable:= <False>
UIA_IsWindowPatternAvailable:= <False>
UIA_ValueIsReadOnly:= <True>
UIA_RangeValueValue:= <0>
UIA_RangeValueIsReadOnly:= <True>
UIA_RangeValueMinimum:= <0>
UIA_RangeValueMaximum:= <0>
UIA_RangeValueLargeChange:= <0>
UIA_RangeValueSmallChange:= <0>
UIA_ScrollHorizontalScrollPercent:= <0>
UIA_ScrollHorizontalViewSize:= <100>
UIA_ScrollVerticalScrollPercent:= <0>
UIA_ScrollVerticalViewSize:= <100>
UIA_ScrollHorizontallyScrollable:= <False>
UIA_ScrollVerticallyScrollable:= <False>
UIA_SelectionCanSelectMultiple:= <False>
UIA_SelectionIsSelectionRequired:= <False>
UIA_GridRowCount:= <0>
UIA_GridColumnCount:= <0>
UIA_GridItemRow:= <0>
UIA_GridItemColumn:= <0>
UIA_GridItemRowSpan:= <1>
UIA_GridItemColumnSpan:= <1>
UIA_DockDockPosition:= <5>
UIA_ExpandCollapseExpandCollapseState:= <3>
UIA_MultipleViewCurrentView:= <0>
UIA_WindowCanMaximize:= <False>
UIA_WindowCanMinimize:= <False>
UIA_WindowWindowVisualState:= <0>
UIA_WindowWindowInteractionState:= <0>
UIA_WindowIsModal:= <False>
UIA_WindowIsTopmost:= <False>
UIA_SelectionItemIsSelected:= <False>
UIA_TableRowOrColumnMajor:= <2>
UIA_ToggleToggleState:= <2>
UIA_TransformCanMove:= <False>
UIA_TransformCanResize:= <False>
UIA_TransformCanRotate:= <False>
UIA_IsLegacyIAccessiblePatternAvailable:= <True>
UIA_LegacyIAccessibleChildId:= <0>
UIA_LegacyIAccessibleRole:= <10>
UIA_LegacyIAccessibleState:= <1048580>
UIA_IsDataValidForForm:= <False>
UIA_ProviderDescription:= <[pid:4924,hwnd:0xF02D4 Main:Nested [pid:1812,hwnd:0xF02D4 Annotation(parent link):Microsoft: Annotation Proxy (unmanaged:uiautomationcore.dll); Main:Microsoft: MSAA Proxy (unmanaged:uiautomationcore.dll)]; Hwnd(parent link):Microsoft: HWND Proxy (unmanaged:uiautomationcore.dll)]>
UIA_IsItemContainerPatternAvailable:= <False>
UIA_IsVirtualizedItemPatternAvailable:= <False>
UIA_IsSynchronizedInputPatternAvailable:= <False>

I am able to read and set content as follows:

$rt = _UIA_Action("oP6", "getValue")
_UIA_Action("oP6", "setValue using keys", $x2)

This is the full code (I have included a loop for stress-testing)

This is the full code (I have included a loop for stress-testing)
#include "UIAWrappers.au3"
AutoItSetOption("MustDeclareVars", 1)
Global $rt, $i, $x1,$x2

$x1 = "// TestText"
$x2 = "// More Text"

For $i = 1 To 1
    _UIA_setVar("oP6", "Title:=;controltype:=UIA_PaneControlTypeId;class:=ThunderRT6PictureBoxDC") ;
    _UIA_Action("oP6", "setValue using keys", $x1)
    $rt = _UIA_Action("oP6", "getValue")
    If $rt <> $x1 Then
        ConsoleWrite($i & @CRLF)
        ConsoleWrite("Error at $x1" & @CRLF)
    EndIf
    _UIA_Action("oP6", "setValue using keys", $x2)
    $rt = _UIA_Action("oP6", "getValue")
    If $rt <> $x2 Then
        ConsoleWrite($i & @CRLF)
        ConsoleWrite("Error at $x2" & @CRLF)
    EndIf
    $rt = _UIA_Action("oP6", "getValue")
Next

I have a numer of questions around this:

  1. Is it correct to use oP6 to read and write to? Should id not be .mainwindow?
    I am asking this as oP6 is (according to the highlighting) the window that actually contains .mainwindow.
  2. I tried to use the method "setValue using clipboard" which did not work. Since I need to post quite a large piece of text into the window I cannot really use "keys" as it takes to long. Additionally it is not working reliably with long (1k) text. From my understanding it would be best to use "setvalue" but this did not work either.
  3. I have been doing some stress-testing with looping eg 50 times and got occational errors - which I need to avoid :-(

It would be great to get some hints on this!

thank you
-dubi

 

HSEinstellenWindow.PNG

Share this post


Link to post
Share on other sites



Hi.

Are you focusing the correct object? because in this one appears this:

UIA_ValueIsReadOnly:= <True>

(then you couldn't set text in this object)

and not appears something like:

UIA_iaccessiblevalue:= <something>

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Thanks vicivic. I have just double checked and yes, i am focussing the black screen when pressing ctrl-w in simplespy. So does mean that I will not be able to enter text "normally" into the window (as UIA_iaccessablevalue is not even available)?

My script above actually works (but not reliably with longer texts...). Am I using the right object with "oP6"? I have tried ".mainwindow" with no success...

Edited by dubi

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

  1. Is it correct to use oP6 to read and write to? Should id not be .mainwindow?
    I am asking this as oP6 is (according to the highlighting) the window that actually contains .mainwindow.


    In general it will only influence the internal search algorithm when using .mainwindow its just a trigger to hold a cache for the mainwindow element. Technically you can name it anything you want. o stands for object and p for parent
     
  2. I tried to use the method "setValue using clipboard" which did not work. Since I need to post quite a large piece of text into the window I cannot really use "keys" as it takes to long. Additionally it is not working reliably with long (1k) text. From my understanding it would be best to use "setvalue" but this did not work either.

    you could try  Opt ("SendKeyDelay", 0)     (any value from about 0-4 will speed it up as normal its 5 as default)
     
  3. I have been doing some stress-testing with looping eg 50 times and got occational errors - which I need to avoid :-(
    Get the object directly in a variable. There are errors in my library searching algoritm so once you have your object its quicker and more stable to get a reference to your object
$myObj=_UIA_Action("oP6", "getobject")

_UIA_Action($myObj, "setvalue using keys","$x1)

UIA_IsTextPatternAvailable:= <False>
UIA_IsValuePatternAvailable:= <False>

in general means that there is no direct way of putting your values in except sendkeys and paste thru clipboard (which actually is just doing ctrl+v)

There are 4 ways in uiwrapper to put text in a textbox based on the whereas the last 3 ones in the end use send command from AutoIt

Case "setValue", "settextValue"
Case "setValue using keys"
Case "setValue using clipboard"
Case "sendkeys", "enterstring", "type", "typetext"
Edited by junkew

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Hi junkew

Thanks for your explanation and thanks to your help I have solved quite a bit of my issues. I can read and set text into my control (sometimes the pasting does not work perfectly but the "getvalue" works perfect). Since getvalue works so reliably on my control I can just set the value until the getvalue gives me the desired value.

But I am stuck again :blink::

When I open the window ("Handelssystem einstellen") the first time all works perfect (setting the value, testing if it is correctly set). I then close the window and open it again and things break:

_UIA_SetVar and _UIA_Action have no effect any more?? While after opening the window the first time I can see the red square around the control and then the reading and writing of values. All fine. But when I try it again (like in the loop I have in my code), the red square is not shown any more and the return value ($rt) is empty.

What am I missing? Any help appreciated...

This is the code I am using....

#AutoIt3Wrapper_UseX64=N
#include "UIAWrappers.au3"
#include <Array.au3>
#include <Misc.au3>
;~ #include "_Dbug.au3"
Global $instanzTitel = "Investox (1) -"

AutoItSetOption("MustDeclareVars", 1)
Global $rt, $i, $x1, $x2, $myarr, $mywhnd, $ctrlName1, $counter, $errCounter = 1, $errWinCounter = 0, $myObj
Opt("WinTitleMatchMode", 2)
$x1 = FileRead("D:\XVM01\candletext1.txt")
$x2 = FileRead("D:\XVM01\candletext1.txt")
For $i = 1 To 2
    OpenHSEinstellen1()
    $mywhnd = WinGetHandle("Handelssystem einstellen")
    WinListChildren($mywhnd, $myarr)
    ;_ArrayDisplay($myarr)
    $ctrlName1 = StringTrimLeft($myarr[9][1], 2)
    ;_UIA_setVar("oP6", "Title:=;controltype:=UIA_PaneControlTypeId;class:=ThunderRT6PictureBoxDC") ;
    _UIA_setVar("oP7", "title:=;classname:=" & $ctrlName1)
    $myObj = _UIA_Action("oP7", "getobject")
    ClipPut("")
    $counter = 0
    Do
        _UIA_Action($myObj, "setValue using clipboard", $x1)
;~      _UIA_Action("oP7", "setValue using clipboard", $x1)
        ConsoleWrite("Value set" & @CRLF)
        ;_UIA_Action($myObj, "setValue using clipboard", $x1)
        ClipPut("")
        $rt = _UIA_Action($myObj, "getValue")
;~      $rt = _UIA_Action("oP7", "getValue")
;~      msgbox(0,0,$rt)
        ;$rt = _UIA_Action($myObj, "getValue")
        ClipPut("")
        If $counter > 0 Then
            ConsoleWrite("Run : " & $i & " / " & $counter & "   Error at $x1" & @CRLF)
            $errCounter += 1
        EndIf
        $counter += 1
        CopyErr()
    Until $rt = $x1
    $counter = 0
    ConsoleWrite("Run : " & $i & "  /  " & $errCounter & "  (" & Round($errCounter / $counter * 2, 1) & ")" & @CRLF)
    closeHSEinstellen()
Next

Func CopyErr()
    Local $j, $k
    Local $erg, $winHndl
    Opt("WinTitleMatchMode", 3)
    Local $wl = WinList("Investox")
    Opt("WinTitleMatchMode", 2)
    For $j = 1 To UBound($wl) - 1
        $winHndl = $wl[$j][1]
        WinListChildren($winHndl, $erg)
        For $k = 1 To $erg[0][0]
            If StringInStr($erg[$k][1], "Diesen Hinweis nicht mehr anzeigen") > 0 Then
                ;ConsoleWrite("Durchlauf: " & $i & "   Copy Error bei Zeile " & $line & @CRLF)
                Sleep(1)
                ;_ArrayDisplay($wl)
                WinActivate($wl[1][1])
                Sleep(100) ;WinWaitActive($wl[1][1])
                If WinActive($wl[1][1]) Then Send("{ENTER}")
                ConsoleWrite("     Durchlauf : " & $i & " /    Error window geschlossen" & @CRLF)
                $errWinCounter += 1
                Return True
            EndIf
        Next
    Next
    Return False
EndFunc   ;==>CopyErr

Func WinListChildren($hWnd, ByRef $avArr)
    ; writes all child windows into $avArr
    If UBound($avArr, 0) <> 2 Then
        Local $avTmp[10][2] = [[0]]
        $avArr = $avTmp
    EndIf

    Local $hChild = _WinAPI_GetWindow($hWnd, $GW_CHILD)

    While $hChild
        If $avArr[0][0] + 1 > UBound($avArr, 1) - 1 Then ReDim $avArr[$avArr[0][0] + 10][2]
        $avArr[$avArr[0][0] + 1][0] = $hChild
        $avArr[$avArr[0][0] + 1][1] = _WinAPI_GetWindowText($hChild) & "; " & WinGetClassList($hChild)
        $avArr[0][0] += 1
        WinListChildren($hChild, $avArr)
        $hChild = _WinAPI_GetWindow($hChild, $GW_HWNDNEXT)
    WEnd

    ReDim $avArr[$avArr[0][0] + 1][2]
EndFunc   ;==>WinListChildren
Func OpenHSEinstellen1()
    Local $vText
    Local $d, $c
    While Not WinExists("Handelssystem einstellen")
        $d = ControlGetPos($instanzTitel, "", "[CLASS:ThunderRT6TextBox; INSTANCE:5]")
        WinActivate($instanzTitel)
        _SendEx("^y")
        WinActivate("Handelssystem einstellen")
    WEnd
EndFunc   ;==>OpenHSEinstellen1
Func closeHSEinstellen()
    Local $x1, $y1
    Local $aHSWC = WinGetPos("Handelssystem einstellen")
    Local $x1n = $aHSWC[0] + $aHSWC[2]
    Local $y1n = $aHSWC[1] + $aHSWC[3]
    Local $c = WinGetPos("Handelssystem einstellen")
    While WinExists("Handelssystem einstellen")
        WinActivate("Handelssystem einstellen")
        Sleep(100)
        MouseClick('Left', $c[0] + 580, $c[1] + 420, 1, 3)
        WinActivate($instanzTitel)
        _SendEx("+{F3}") ; Optimierungszeitraum selektieren
    WEnd
EndFunc   ;==>closeHSEinstellen
Func _SendEx($ss, $warn = "")
    Local $iT = TimerInit()
    While _IsPressed("10") Or _IsPressed("11") Or _IsPressed("12")
        If $warn <> "" And TimerDiff($iT) > 1000 Then
            MsgBox(262144, "Warning", $warn)
        EndIf
        Sleep(100)
    WEnd
    Send($ss)
EndFunc   ;==>_SendEx

 

Edited by dubi

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

thanks junkew!

what do you mean by "reference"? the "oP7"?

Edited by dubi

Share this post


Link to post
Share on other sites

#9 ·  Posted

Simplespy on this window gives me the following

Mouse position is retrieved 374-547
At least we have an element title: [] class: [Afx:3620000:2b]

Having the following values for all properties: 
Title is: <>    Class   := <Afx:3620000:2b> controltype:= <UIA_PaneControlTypeId>   ,<50033>    , (0000C371)    194;476;514;302
*** Parent Information top down ***
5: Title is: <Investox (1) - [Testproj_I1]> Class   := <ThunderRT6MDIForm>  controltype:= <UIA_WindowControlTypeId> ,<50032>    , (0000C370)    0;30;1000;1100
"Title:=Investox (1) - [Testproj_I1];controltype:=UIA_WindowControlTypeId;class:=ThunderRT6MDIForm""    
4: Title is: <Handelssystem einstellen> Class   := <ThunderRT6FormDC>   controltype:= <UIA_WindowControlTypeId> ,<50032>    , (0000C370)    168;353;663;453
"Title:=Handelssystem einstellen;controltype:=UIA_WindowControlTypeId;class:=ThunderRT6FormDC"" 
3: Title is: <> Class   := <ThunderRT6UserControlDC>    controltype:= <UIA_PaneControlTypeId>   ,<50033>    , (0000C371)    175;382;648;414
"Title:=;controltype:=UIA_PaneControlTypeId;class:=ThunderRT6UserControlDC""    
2: Title is: <> Class   := <ThunderRT6PictureBoxDC> controltype:= <UIA_PaneControlTypeId>   ,<50033>    , (0000C371)    179;404;545;388
"Title:=;controltype:=UIA_PaneControlTypeId;class:=ThunderRT6PictureBoxDC"" 
1: Title is: <> Class   := <ThunderRT6UserControlDC>    controltype:= <UIA_PaneControlTypeId>   ,<50033>    , (0000C371)    192;448;518;332
"Title:=;controltype:=UIA_PaneControlTypeId;class:=ThunderRT6UserControlDC""    
0: Title is: <> Class   := <ThunderRT6PictureBoxDC> controltype:= <UIA_PaneControlTypeId>   ,<50033>    , (0000C371)    194;476;514;302
"Title:=;controltype:=UIA_PaneControlTypeId;class:=ThunderRT6PictureBoxDC"" 


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

_UIA_setVar("oP1","Title:=Investox (1) - [Testproj_I1];controltype:=UIA_WindowControlTypeId;class:=ThunderRT6MDIForm")  ;Investox (1) - [Testproj_I1]
_UIA_setVar("oP2","Title:=Handelssystem einstellen;controltype:=UIA_WindowControlTypeId;class:=ThunderRT6FormDC")   ;Handelssystem einstellen
_UIA_setVar("oP3","Title:=;controltype:=UIA_PaneControlTypeId;class:=ThunderRT6UserControlDC")  ;
_UIA_setVar("oP4","Title:=;controltype:=UIA_PaneControlTypeId;class:=ThunderRT6PictureBoxDC")   ;
_UIA_setVar("oP5","Title:=;controltype:=UIA_PaneControlTypeId;class:=ThunderRT6UserControlDC")  ;
_UIA_setVar("oP6","Title:=;controltype:=UIA_PaneControlTypeId;class:=ThunderRT6PictureBoxDC")   ;

_UIA_setVar(".mainwindow","title:=;classname:=Afx:3620000:2b")

;~ 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("oP3","highlight")
_UIA_Action("oP3","setfocus")
;~_UIA_Action("oP4","highlight")
_UIA_Action("oP4","setfocus")
;~_UIA_Action("oP5","highlight")
_UIA_Action("oP5","setfocus")
;~_UIA_Action("oP6","highlight")
_UIA_Action("oP6","setfocus")

_UIA_action(".mainwindow","setfocus")


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

Local $oP5=_UIA_getObjectByFindAll($UIA_oDesktop, "Title:=Investox (1) - [Testproj_I1];controltype:=UIA_WindowControlTypeId;class:=ThunderRT6MDIForm", $treescope_children) 
_UIA_Action($oP5,"setfocus")
Local $oP4=_UIA_getObjectByFindAll($oP5, "Title:=Handelssystem einstellen;controltype:=UIA_WindowControlTypeId;class:=ThunderRT6FormDC", $treescope_children)   
_UIA_Action($oP4,"setfocus")
Local $oP3=_UIA_getObjectByFindAll($oP4, "Title:=;controltype:=UIA_PaneControlTypeId;class:=ThunderRT6UserControlDC", $treescope_children)  
_UIA_Action($oP3,"setfocus")
Local $oP2=_UIA_getObjectByFindAll($oP3, "Title:=;controltype:=UIA_PaneControlTypeId;class:=ThunderRT6PictureBoxDC", $treescope_children)   
_UIA_Action($oP2,"setfocus")
Local $oP1=_UIA_getObjectByFindAll($oP2, "Title:=;controltype:=UIA_PaneControlTypeId;class:=ThunderRT6UserControlDC", $treescope_children)  
_UIA_Action($oP1,"setfocus")
Local $oP0=_UIA_getObjectByFindAll($oP1, "Title:=;controltype:=UIA_PaneControlTypeId;class:=ThunderRT6PictureBoxDC", $treescope_children)   
_UIA_Action($oP0,"setfocus")
_UIA_setVar(".mainwindow","title:=;classname:=Afx:3620000:2b")
_UIA_action(".mainwindow","setfocus")


*** Detailed properties of the highlighted element ***
UIA_class:= <Afx:3620000:2b>
UIA_regexpclass:= <Afx:3620000:2b>
UIA_iaccessiblechildId:= <0>
UIA_handle:= <2099356>
UIA_RuntimeId:= <42;2099356>
UIA_BoundingRectangle:= <194;476;514;302>
UIA_ProcessId:= <1712>
UIA_ControlType:= <50033>
UIA_LocalizedControlType:= <pane>
UIA_HasKeyboardFocus:= <True>
UIA_IsKeyboardFocusable:= <True>
UIA_IsEnabled:= <True>
UIA_ClassName:= <Afx:3620000:2b>
UIA_Culture:= <0>
UIA_IsControlElement:= <True>
UIA_IsContentElement:= <True>
UIA_IsPassword:= <False>
UIA_NativeWindowHandle:= <2099356>
UIA_IsOffscreen:= <False>
UIA_Orientation:= <0>
UIA_FrameworkId:= <Win32>
UIA_IsRequiredForForm:= <False>
UIA_IsDockPatternAvailable:= <False>
UIA_IsExpandCollapsePatternAvailable:= <False>
UIA_IsGridItemPatternAvailable:= <False>
UIA_IsGridPatternAvailable:= <False>
UIA_IsInvokePatternAvailable:= <False>
UIA_IsMultipleViewPatternAvailable:= <False>
UIA_IsRangeValuePatternAvailable:= <False>
UIA_IsScrollPatternAvailable:= <True>
UIA_IsScrollItemPatternAvailable:= <False>
UIA_IsSelectionItemPatternAvailable:= <False>
UIA_IsSelectionPatternAvailable:= <False>
UIA_IsTablePatternAvailable:= <False>
UIA_IsTableItemPatternAvailable:= <False>
UIA_IsTextPatternAvailable:= <False>
UIA_IsTogglePatternAvailable:= <False>
UIA_IsTransformPatternAvailable:= <False>
UIA_IsValuePatternAvailable:= <False>
UIA_IsWindowPatternAvailable:= <False>
UIA_ValueIsReadOnly:= <True>
UIA_RangeValueValue:= <0>
UIA_RangeValueIsReadOnly:= <True>
UIA_RangeValueMinimum:= <0>
UIA_RangeValueMaximum:= <0>
UIA_RangeValueLargeChange:= <0>
UIA_RangeValueSmallChange:= <0>
UIA_ScrollHorizontalScrollPercent:= <0>
UIA_ScrollHorizontalViewSize:= <100>
UIA_ScrollVerticalScrollPercent:= <0>
UIA_ScrollVerticalViewSize:= <32.6133909287257>
UIA_ScrollHorizontallyScrollable:= <False>
UIA_ScrollVerticallyScrollable:= <True>
UIA_SelectionCanSelectMultiple:= <False>
UIA_SelectionIsSelectionRequired:= <False>
UIA_GridRowCount:= <0>
UIA_GridColumnCount:= <0>
UIA_GridItemRow:= <0>
UIA_GridItemColumn:= <0>
UIA_GridItemRowSpan:= <1>
UIA_GridItemColumnSpan:= <1>
UIA_DockDockPosition:= <5>
UIA_ExpandCollapseExpandCollapseState:= <3>
UIA_MultipleViewCurrentView:= <0>
UIA_WindowCanMaximize:= <False>
UIA_WindowCanMinimize:= <False>
UIA_WindowWindowVisualState:= <0>
UIA_WindowWindowInteractionState:= <0>
UIA_WindowIsModal:= <False>
UIA_WindowIsTopmost:= <False>
UIA_SelectionItemIsSelected:= <False>
UIA_TableRowOrColumnMajor:= <2>
UIA_ToggleToggleState:= <2>
UIA_TransformCanMove:= <False>
UIA_TransformCanResize:= <False>
UIA_TransformCanRotate:= <False>
UIA_IsLegacyIAccessiblePatternAvailable:= <True>
UIA_LegacyIAccessibleChildId:= <0>
UIA_LegacyIAccessibleRole:= <10>
UIA_LegacyIAccessibleState:= <1048580>
UIA_IsDataValidForForm:= <False>
UIA_ProviderDescription:= <[pid:1540,hwnd:0x20089C Main:Nested [pid:1712,hwnd:0x20089C Annotation(parent link):Microsoft: Annotation Proxy (unmanaged:uiautomationcore.dll); Main:Microsoft: MSAA Proxy (unmanaged:uiautomationcore.dll)]; Nonclient:Microsoft: Non-Client Proxy (unmanaged:uiautomationcore.dll); Hwnd(parent link):Microsoft: HWND Proxy (unmanaged:uiautomationcore.dll)]>
UIA_IsItemContainerPatternAvailable:= <False>
UIA_IsVirtualizedItemPatternAvailable:= <False>
UIA_IsSynchronizedInputPatternAvailable:= <False>

 

Share this post


Link to post
Share on other sites

#10 ·  Posted

interesting... I was now running simplespy after the my script got stuck and I am getting different results:

Mouse position is retrieved 599-750
At least we have an element title: [] class: [Afx:3620000:2b]

Having the following values for all properties: 
Title is: <>    Class   := <Afx:3620000:2b> controltype:= <UIA_PaneControlTypeId>   ,<50033>    , (0000C371)    316;528;514;302
*** Parent Information top down ***
8: Title is: <Investox (1) - [Testproj_I1]> Class   := <ThunderRT6MDIForm>  controltype:= <UIA_WindowControlTypeId> ,<50032>    , (0000C370)    0;30;1000;1100
"Title:=Investox (1) - [Testproj_I1];controltype:=UIA_WindowControlTypeId;class:=ThunderRT6MDIForm""    
7: Title is: <Workspace>    Class   := <MDIClient>  controltype:= <UIA_PaneControlTypeId>   ,<50033>    , (0000C371)    8;117;952;961
"Title:=Workspace;controltype:=UIA_PaneControlTypeId;class:=MDIClient"" 
6: Title is: <Testproj_I1>  Class   := <ThunderRT6Form> controltype:= <UIA_WindowControlTypeId> ,<50032>    , (0000C370)    2;89;964;995
"Title:=Testproj_I1;controltype:=UIA_WindowControlTypeId;class:=ThunderRT6Form""    
5: Title is: <> Class   := <ThunderRT6UserControl>  controltype:= <UIA_PaneControlTypeId>   ,<50033>    , (0000C371)    287;188;670;887
"Title:=;controltype:=UIA_PaneControlTypeId;class:=ThunderRT6UserControl""  
4: Title is: <Handelssystem einstellen> Class   := <ThunderRT6FormDC>   controltype:= <UIA_WindowControlTypeId> ,<50032>    , (0000C370)    290;405;663;453
"Title:=Handelssystem einstellen;controltype:=UIA_WindowControlTypeId;class:=ThunderRT6FormDC"" 
3: Title is: <> Class   := <ThunderRT6UserControlDC>    controltype:= <UIA_PaneControlTypeId>   ,<50033>    , (0000C371)    297;434;648;414
"Title:=;controltype:=UIA_PaneControlTypeId;class:=ThunderRT6UserControlDC""    
2: Title is: <> Class   := <ThunderRT6PictureBoxDC> controltype:= <UIA_PaneControlTypeId>   ,<50033>    , (0000C371)    301;456;545;388
"Title:=;controltype:=UIA_PaneControlTypeId;class:=ThunderRT6PictureBoxDC"" 
1: Title is: <> Class   := <ThunderRT6UserControlDC>    controltype:= <UIA_PaneControlTypeId>   ,<50033>    , (0000C371)    314;500;518;332
"Title:=;controltype:=UIA_PaneControlTypeId;class:=ThunderRT6UserControlDC""    
0: Title is: <> Class   := <ThunderRT6PictureBoxDC> controltype:= <UIA_PaneControlTypeId>   ,<50033>    , (0000C371)    316;528;514;302
"Title:=;controltype:=UIA_PaneControlTypeId;class:=ThunderRT6PictureBoxDC"" 


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

_UIA_setVar("oP1","Title:=Investox (1) - [Testproj_I1];controltype:=UIA_WindowControlTypeId;class:=ThunderRT6MDIForm")  ;Investox (1) - [Testproj_I1]
_UIA_setVar("oP2","Title:=Workspace;controltype:=UIA_PaneControlTypeId;class:=MDIClient")   ;Workspace
_UIA_setVar("oP3","Title:=Testproj_I1;controltype:=UIA_WindowControlTypeId;class:=ThunderRT6Form")  ;Testproj_I1
_UIA_setVar("oP4","Title:=;controltype:=UIA_PaneControlTypeId;class:=ThunderRT6UserControl")    ;
_UIA_setVar("oP5","Title:=Handelssystem einstellen;controltype:=UIA_WindowControlTypeId;class:=ThunderRT6FormDC")   ;Handelssystem einstellen
_UIA_setVar("oP6","Title:=;controltype:=UIA_PaneControlTypeId;class:=ThunderRT6UserControlDC")  ;
_UIA_setVar("oP7","Title:=;controltype:=UIA_PaneControlTypeId;class:=ThunderRT6PictureBoxDC")   ;
_UIA_setVar("oP8","Title:=;controltype:=UIA_PaneControlTypeId;class:=ThunderRT6UserControlDC")  ;
_UIA_setVar("oP9","Title:=;controltype:=UIA_PaneControlTypeId;class:=ThunderRT6PictureBoxDC")   ;

_UIA_setVar(".mainwindow","title:=;classname:=Afx:3620000:2b")

;~ 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("oP3","highlight")
_UIA_Action("oP3","setfocus")
;~_UIA_Action("oP4","highlight")
_UIA_Action("oP4","setfocus")
;~_UIA_Action("oP5","highlight")
_UIA_Action("oP5","setfocus")
;~_UIA_Action("oP6","highlight")
_UIA_Action("oP6","setfocus")
;~_UIA_Action("oP7","highlight")
_UIA_Action("oP7","setfocus")
;~_UIA_Action("oP8","highlight")
_UIA_Action("oP8","setfocus")
;~_UIA_Action("oP9","highlight")
_UIA_Action("oP9","setfocus")

_UIA_action(".mainwindow","setfocus")


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

Local $oP8=_UIA_getObjectByFindAll($UIA_oDesktop, "Title:=Investox (1) - [Testproj_I1];controltype:=UIA_WindowControlTypeId;class:=ThunderRT6MDIForm", $treescope_children) 
_UIA_Action($oP8,"setfocus")
Local $oP7=_UIA_getObjectByFindAll($oP8, "Title:=Workspace;controltype:=UIA_PaneControlTypeId;class:=MDIClient", $treescope_children)   
_UIA_Action($oP7,"setfocus")
Local $oP6=_UIA_getObjectByFindAll($oP7, "Title:=Testproj_I1;controltype:=UIA_WindowControlTypeId;class:=ThunderRT6Form", $treescope_children)  
_UIA_Action($oP6,"setfocus")
Local $oP5=_UIA_getObjectByFindAll($oP6, "Title:=;controltype:=UIA_PaneControlTypeId;class:=ThunderRT6UserControl", $treescope_children)    
_UIA_Action($oP5,"setfocus")
Local $oP4=_UIA_getObjectByFindAll($oP5, "Title:=Handelssystem einstellen;controltype:=UIA_WindowControlTypeId;class:=ThunderRT6FormDC", $treescope_children)   
_UIA_Action($oP4,"setfocus")
Local $oP3=_UIA_getObjectByFindAll($oP4, "Title:=;controltype:=UIA_PaneControlTypeId;class:=ThunderRT6UserControlDC", $treescope_children)  
_UIA_Action($oP3,"setfocus")
Local $oP2=_UIA_getObjectByFindAll($oP3, "Title:=;controltype:=UIA_PaneControlTypeId;class:=ThunderRT6PictureBoxDC", $treescope_children)   
_UIA_Action($oP2,"setfocus")
Local $oP1=_UIA_getObjectByFindAll($oP2, "Title:=;controltype:=UIA_PaneControlTypeId;class:=ThunderRT6UserControlDC", $treescope_children)  
_UIA_Action($oP1,"setfocus")
Local $oP0=_UIA_getObjectByFindAll($oP1, "Title:=;controltype:=UIA_PaneControlTypeId;class:=ThunderRT6PictureBoxDC", $treescope_children)   
_UIA_Action($oP0,"setfocus")
_UIA_setVar(".mainwindow","title:=;classname:=Afx:3620000:2b")
_UIA_action(".mainwindow","setfocus")


*** Detailed properties of the highlighted element ***
UIA_class:= <Afx:3620000:2b>
UIA_regexpclass:= <Afx:3620000:2b>
UIA_iaccessiblechildId:= <0>
UIA_handle:= <2884074>
UIA_RuntimeId:= <42;2884074>
UIA_BoundingRectangle:= <316;528;514;302>
UIA_ProcessId:= <1712>
UIA_ControlType:= <50033>
UIA_LocalizedControlType:= <pane>
UIA_HasKeyboardFocus:= <True>
UIA_IsKeyboardFocusable:= <True>
UIA_IsEnabled:= <True>
UIA_ClassName:= <Afx:3620000:2b>
UIA_Culture:= <0>
UIA_IsControlElement:= <True>
UIA_IsContentElement:= <True>
UIA_IsPassword:= <False>
UIA_NativeWindowHandle:= <2884074>
UIA_IsOffscreen:= <False>
UIA_Orientation:= <0>
UIA_FrameworkId:= <Win32>
UIA_IsRequiredForForm:= <False>
UIA_IsDockPatternAvailable:= <False>
UIA_IsExpandCollapsePatternAvailable:= <False>
UIA_IsGridItemPatternAvailable:= <False>
UIA_IsGridPatternAvailable:= <False>
UIA_IsInvokePatternAvailable:= <False>
UIA_IsMultipleViewPatternAvailable:= <False>
UIA_IsRangeValuePatternAvailable:= <False>
UIA_IsScrollPatternAvailable:= <True>
UIA_IsScrollItemPatternAvailable:= <False>
UIA_IsSelectionItemPatternAvailable:= <False>
UIA_IsSelectionPatternAvailable:= <False>
UIA_IsTablePatternAvailable:= <False>
UIA_IsTableItemPatternAvailable:= <False>
UIA_IsTextPatternAvailable:= <False>
UIA_IsTogglePatternAvailable:= <False>
UIA_IsTransformPatternAvailable:= <False>
UIA_IsValuePatternAvailable:= <False>
UIA_IsWindowPatternAvailable:= <False>
UIA_ValueIsReadOnly:= <True>
UIA_RangeValueValue:= <0>
UIA_RangeValueIsReadOnly:= <True>
UIA_RangeValueMinimum:= <0>
UIA_RangeValueMaximum:= <0>
UIA_RangeValueLargeChange:= <0>
UIA_RangeValueSmallChange:= <0>
UIA_ScrollHorizontalScrollPercent:= <0>
UIA_ScrollHorizontalViewSize:= <100>
UIA_ScrollVerticalScrollPercent:= <0>
UIA_ScrollVerticalViewSize:= <32.6133909287257>
UIA_ScrollHorizontallyScrollable:= <False>
UIA_ScrollVerticallyScrollable:= <True>
UIA_SelectionCanSelectMultiple:= <False>
UIA_SelectionIsSelectionRequired:= <False>
UIA_GridRowCount:= <0>
UIA_GridColumnCount:= <0>
UIA_GridItemRow:= <0>
UIA_GridItemColumn:= <0>
UIA_GridItemRowSpan:= <1>
UIA_GridItemColumnSpan:= <1>
UIA_DockDockPosition:= <5>
UIA_ExpandCollapseExpandCollapseState:= <3>
UIA_MultipleViewCurrentView:= <0>
UIA_WindowCanMaximize:= <False>
UIA_WindowCanMinimize:= <False>
UIA_WindowWindowVisualState:= <0>
UIA_WindowWindowInteractionState:= <0>
UIA_WindowIsModal:= <False>
UIA_WindowIsTopmost:= <False>
UIA_SelectionItemIsSelected:= <False>
UIA_TableRowOrColumnMajor:= <2>
UIA_ToggleToggleState:= <2>
UIA_TransformCanMove:= <False>
UIA_TransformCanResize:= <False>
UIA_TransformCanRotate:= <False>
UIA_IsLegacyIAccessiblePatternAvailable:= <True>
UIA_LegacyIAccessibleChildId:= <0>
UIA_LegacyIAccessibleRole:= <10>
UIA_LegacyIAccessibleState:= <1048580>
UIA_IsDataValidForForm:= <False>
UIA_ProviderDescription:= <[pid:4608,hwnd:0x2C01EA Main:Nested [pid:1712,hwnd:0x2C01EA Annotation(parent link):Microsoft: Annotation Proxy (unmanaged:uiautomationcore.dll); Main:Microsoft: MSAA Proxy (unmanaged:uiautomationcore.dll)]; Nonclient:Microsoft: Non-Client Proxy (unmanaged:uiautomationcore.dll); Hwnd(parent link):Microsoft: HWND Proxy (unmanaged:uiautomationcore.dll)]>
UIA_IsItemContainerPatternAvailable:= <False>
UIA_IsVirtualizedItemPatternAvailable:= <False>
UIA_IsSynchronizedInputPatternAvailable:= <False>

 

Share this post


Link to post
Share on other sites

#12 ·  Posted

WinListChildren($mywhnd, $myarr)
    ;_ArrayDisplay($myarr)
    $ctrlName1 = StringTrimLeft($myarr[9][1], 2)

seems like you have access with AutoIt already to the control

so use 

https://www.autoitscript.com/autoit3/docs/libfunctions/_WinAPI_EnumWindows.htm

https://www.autoitscript.com/autoit3/docs/libfunctions/_WinAPI_SetFocus.htm

or

https://www.autoitscript.com/autoit3/docs/functions/ControlFocus.htm

most likely $myarr[9][0] will contain the hwnd of your control

when you are having focus in the control you do sendkeys of ctrl+a to select all text in the control and ctrl+v to paste it in from clipboard

https://www.autoitscript.com/autoit3/docs/functions/Send.htm

or 

https://www.autoitscript.com/autoit3/docs/functions/ControlSend.htm

Send("^a")
Send("^v")

 

Share this post


Link to post
Share on other sites

#13 ·  Posted

Thank you for your time, junkew! Much appreciated! I will try both and will report back.

my current (and most likely working solution) is to externalise the UIAutomation call in a compiled exe that I call from within my script. Since I experienced issues only when I open the sub-window the second time I avoid calling the UIAutomation twice (as it is always first time in the exe). This is faaaiiirly slow but it works as far as I can see this now. If the other solutions will be faster then even better B)

Share this post


Link to post
Share on other sites

#15 ·  Posted

Sorry for the long delay, junkew. While I was so convinced that UIAutomation will do the job for me I discovered that using it with many instances of my application open it takes up to a minute (and sometimes even longer) to find/address the correct window. So I stopped working on it and went back to where I was before and thus using ctrl a, ctrl c, ctrl v. While the app to be automated is fairly unreliable with ctrl a etc. I have now found a way to verify the correct reading and writing into the window... But it takes in some cases up to 10 retries to get into the window what I want - phew! Quite a bit of an effort to avoid all kinds of pop-up windows and error messages. But it works now :-)
Many thanks for your effort - and at least I have learned a new method for a potential future usage :-)

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