Jump to content

IUIAutomation MS framework automate chrome, FF, IE, ....


junkew
 Share

Recommended Posts

  • 3 weeks later...

I'm trying to run Example 5 (Chrome) and have trouble with line 71.
 

local $oChromeAddressBar=_UIA_getFirstObjectOfElement($oChrome,"title:=Adres- en zoekbalk"  , $treescope_subtree) ;works in chrome 65

This seems to be Dutch. My System has German locale.

What is the correct text in German locale ?

Or better: What tool can be used to obtain this information? And how?

TIA Exit

Edited by Exit
typo

App: Au3toCmd              UDF: _SingleScript()                             

Link to comment
Share on other sites

Use an UIA spy tool eg. simplespy by junkew (place the mouse over the control and press ctrl+w) or UIASpy (place the mouse over the control and press F1).

Link to comment
Share on other sites

Okay, so I think that selecting an item from this list is not possible, and using click with junkew's cold is the only option. Can anyone verify this? It says that "IsSelectionItemPatternAvailable:    true" but I can't seem to pull it off. Also invoke doesn't seem to do much either and neither does dodefaultaction.

Anyone have any ideas on what else I can try?

 

The output from Inspect:

How found:  Mouse move (1384,636)
    hwnd=0x00130C64 32bit class="F3 Server 59b60000" style=0x56000000 ex=0x0
BoundingRectangle:  {l:1296 t:635 r:1467 b:648}
ProcessId:  5840
ControlType:    UIA_ListItemControlTypeId (0xC357)
LocalizedControlType:   "list item"
Name:   "18012507.css"
AccessKey:  ""
HasKeyboardFocus:   false
IsKeyboardFocusable:    false
IsEnabled:  true
HelpText:   ""
IsPassword: false
IsOffscreen:    false
ProviderDescription:    "[pid:5840,hwnd:0x0 Main(parent link):Microsoft: MSAA Proxy (unmanaged:uiautomationcore.dll)]"
SelectionItem.IsSelected:   false
SelectionItem.SelectionContainer:   "" list
IsDockPatternAvailable: false
IsExpandCollapsePatternAvailable:   false
IsGridItemPatternAvailable: false
IsGridPatternAvailable: false
IsInvokePatternAvailable:   true
IsMultipleViewPatternAvailable: false
IsRangeValuePatternAvailable:   false
IsScrollPatternAvailable:   false
IsScrollItemPatternAvailable:   false
IsSelectionItemPatternAvailable:    true
IsSelectionPatternAvailable:    false
IsTablePatternAvailable:    false
IsTableItemPatternAvailable:    false
IsTextPatternAvailable: false
IsTogglePatternAvailable:   false
IsTransformPatternAvailable:    false
IsValuePatternAvailable:    false
IsWindowPatternAvailable:   false
IsItemContainerPatternAvailable:    false
IsVirtualizedItemPatternAvailable:  false
FirstChild: [null]
LastChild:  [null]
Next:   "18012508.css" list item
Previous:   "17121315.css" list item
Other Props:    Object has no additional properties
Children:   Container has no children
Ancestors:  "" list
    "Select File" pane
    "Select File" window
    "Microsoft Excel - Book1" window
    "Desktop" pane
    [ No Parent ]

 

Link to comment
Share on other sites

I'm trying to use regexptitle with no success. :(

What is wrong with my regexptitle definition in the second call?

;~ trying To automate Chrome browser with regexptitle

#include "UIAWrappers.au3"

$pid = ShellExecute("chrome.exe", "about:blank")
Sleep(500)  ; allow browser to start

_GetObject("regexptitle:=about:blank - Google Chrome")     ; this works OK
_GetObject("regexptitle:=about:blank - Google Chrom.")     ; this works NOT.  Why?

winClose("about:blank - Google Chrome")
Exit

Func _GetObject($sSearch)
    Local $oWindow = _UIA_getFirstObjectOfElement($UIA_oDesktop, $sSearch, $treescope_subtree)
    If Not IsObj($oWindow) Then
        MsgBox(16 + 262144, "ERROR", $sSearch & @LF & @LF & "NOT found.   Press OK to continue", 0)
    Else
        MsgBox(64 + 262144, "Success", $sSearch & @LF & @LF & "found.   Press OK to continue", 0)
    EndIf
EndFunc   ;==>_GetObject

TIA Exit

App: Au3toCmd              UDF: _SingleScript()                             

Link to comment
Share on other sites

15 hours ago, junkew said:

Probably a plus sign after dot will help

nope ☹️

see console output:

Quote

Success >regexptitle:=about:blank - Google Chrome<  found.
ERROR   >regexptitle:=about:blank - Google Chrom.<  NOT found.
ERROR   >regexptitle:=about:blank - Google Chrom.+<  NOT found.

modified script in spoiler

Spoiler
;~ trying To automate Chrome browser with regexptitle

#include "UIAWrappers.au3"

ShellExecute("chrome.exe", "about:blank")
Sleep(500) ; allow browser to start

_GetObject("regexptitle:=about:blank - Google Chrome") ; this works OK
_GetObject("regexptitle:=about:blank - Google Chrom.") ; this works NOT.  Why?
_GetObject("regexptitle:=about:blank - Google Chrom.+") ; this works NOT.  Why?

Send("^w") ; close "about:blank" tab
Exit

Func _GetObject($sSearch)
    Local $oWindow = _UIA_getFirstObjectOfElement($UIA_oDesktop, $sSearch, $treescope_subtree)
    If Not IsObj($oWindow) Then
        ConsoleWrite( "ERROR   >" & $sSearch & "<  NOT found." & @CRLF)
        MsgBox(16 + 262144, "ERROR", $sSearch & @LF & @LF & "NOT found.   Press OK to continue", 0)
    Else
        ConsoleWrite( "Success >" & $sSearch & "<  found." & @CRLF)
        MsgBox(64 + 262144, "Success", $sSearch & @LF & @LF & "found.   Press OK to continue", 0)
    EndIf
EndFunc   ;==>_GetObject

 

 

Edited by Exit
added new script

App: Au3toCmd              UDF: _SingleScript()                             

Link to comment
Share on other sites

So I tried a lot of variations and looked in the header files.

My conclusion is that the "Regexp…" keywords are just placeholders for a feature to come in the future.

I did not found any comments that regular expressions are used in UIAutomation at all. 

Can someone confirm this or proof the contrary ?

Thanks

Exit

 

App: Au3toCmd              UDF: _SingleScript()                             

Link to comment
Share on other sites

example 10 is also containing notepad in these example below a regex to differentiate on english and dutch version of notepad.

Full library works with

  1. a string regexp in Func _UIA_getObjectByFindAll
  2. a full match In getFirstObject so if you use _UIA_getFirstObjectOfElement you will not have regex matching

The difference is mainly a choice on speed over flexibility

_UIA_setVar("NOTEPAD.mainwindow","classname:=Notepad")
_UIA_setVar("NOTEPAD.edit","classname:=Edit")
_UIA_setVar("NOTEPAD.mnuFile","name:=((File)|(Bestand))")
_UIA_setVar("NOTEPAD.mnuSave","name:=((Save.*)|(Opslaan.*))")
_UIA_setVar("NOTEPAD.btnClose","name:=((Close)|(Sluiten))")

_UIA_setVar("NOTEPAD.dlgSave","name:=((Save as.*)|(Opslaan als.*))")
_UIA_setVar("NOTEPAD.dlgSave.edtFilename","name:=((Filename:)|(Bestandsnaam:));indexrelative:=1")
_UIA_setVar("NOTEPAD.dlgSave.btnSave","name:=((Save)|(Opslaan));ControlType:=Button")
_UIA_setVar("NOTEPAD.dlgSave.btnYes","name:=((Yes)|(Ja));ControlType:=Button")

regexptitle so will not trigger a special matching on regex it just transforms to property name and all matching with findall will use regex matching.

Link to comment
Share on other sites

Hello, all.

Is there any example about Drag & Drop functionality with obljects in WPF application?

Basically I need two AutoIt functions: ControlGetPos and ControlMove working with objects in WPF application. Is it possible to implement somehow?

 

Thank you for any tip or example.

 

Link to comment
Share on other sites

  • 3 weeks later...

Hi, hepl me please..

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

Local $oP2=_UIA_getObjectByFindAll($UIA_oDesktop, "Title:=test.htm;controltype:=UIA_PaneControlTypeId;class:=Chrome_WidgetWin_1", $treescope_children)
_UIA_Action($oP2,"setfocus")
Local $oP1=_UIA_getObjectByFindAll($oP2, "Title:=;controltype:=UIA_DocumentControlTypeId;class:=Chrome_RenderWidgetHostHWND", $treescope_children)
_UIA_Action($oP1,"setfocus")
Local $oP0=_UIA_getObjectByFindAll($oP1, "Title:=;controltype:=UIA_CustomControlTypeId;class:=", $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,"highlight")
_UIA_action($oUIElement,"click")

MsgBox(64,'',_UIA_action($oUIElement,"getvalue"))

Is there a way without using the clipboard? (for example... $oUIElement.GetCurrentPropertyValue('value', $vValue)... )

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