Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 02/24/2019 in all areas

  1. How to topics, 8 - 15 How to topics is a guide to use UIASpy to identify windows and controls and to create sample code to obtain information and perform actions. Topics 1 - 7: Introductory topics Topics 8 - 15: Sample code creation Top of next post (bottom of this post) Topics 16 - 17: Other How to topics How to perform UI Automation tasks How to use UIASpy to detect elements How to use UIASpy to create sample code How to create sample code through Detail info page How to create sample code through Sample code menu How to create sample code by copying listview rows How to create objects with ObjCreateInterface How to create UI Automation main objects ($oUIAutomation.GetRootElement()) How to identify and find application top window ($UIA_ClassNamePropertyId, $oUIAutomation.CreatePropertyCondition()) How to identify and find UI elements (controls) (Edit control, $UIA_AutomationIdPropertyId, $oUIElement.FindFirst()) How to get UI element property values ($UIA_NativeWindowHandlePropertyId, $UIA_BoundingRectanglePropertyId) How to create element action objects (Create $oValuePattern action object) How to get pattern property values ($UIA_ValueValuePropertyId, $oUIElement.GetCurrentPropertyValue()) How to perform element actions ($oValuePattern.SetValue()) How to create executable code How to perform a mouse click in middle of bounding rectangle How to perform a control click via PostMessage and $UIA_AutomationIdPropertyId Notepad is used as a general example: The Notepad window is identified, the Edit control is identified, some properties are extracted, the ValuePattern action object is created, the existing text in the Edit control is extracted and a new text is set. It looks like this in pseudo code: ; 8. Create UI Automation main objects Create $oUIAutomation and $oDesktop objects ; 9. Identify and find application top window Create condition to identify window through $UIA_ClassNamePropertyId Find window through $oDesktop.FindFirst() with the condition as input ; 10. Identify and find Edit control from top window Create condition to identify Edit control with $UIA_AutomationIdPropertyId Find Edit control through $oWindow.FindFirst() with the condition as input ; 11. Extract some properties from the Edit control Get $UIA_NativeWindowHandlePropertyId with $oEdit.GetCurrentPropertyValue() Get $UIA_BoundingRectanglePropertyId with $oEdit.GetCurrentPropertyValue() ; 12. Create element action object for the Edit control to set a text value Create $oValuePattern with $oEdit.GetCurrentPattern() and $UIA_ValuePatternId as input ; 13. Extract the existing text in the Edit control as a pattern property Get $UIA_ValueValuePropertyId with $oEdit.GetCurrentPropertyValue() ; 14. Perform an action on the Edit control to set a new text Set new text with $oValuePattern.SetValue() and the new text as input ; 15. Create executable code from the code generated by UIASpy Modify the somewhat generic code to be executable Open an empty Notepad and type/paste Hello into the Edit control. Open UIASpy. Click Left pane | Delete top windows to delete all treeview top windows. Place mouse cursor over Notepad title bar and press F2. Notepad and UIASpy should look like shown in the picture in topic 9. The Edit control should contain the word Hello (not shown in the picture). Let UIASpy be open throughout the entire example. In topic 15 all code will be copied from the listview Code page into SciTE editor. 8. How to create UI Automation main objects Click Sample code | Initial code | Complete code to create complete startup code. The code should look like this in the listview Code page: #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 ;#AutoIt3Wrapper_UseX64=n ; If target application is running as 32 bit code ;#AutoIt3Wrapper_UseX64=y ; If target application is running as 64 bit code #include "CUIAutomation2.au3" ; Get proper version in UIASpy Includes folder ;#include "UIA_Functions.au3" ; Can be copied from UIASpy Includes folder Opt( "MustDeclareVars", 1 ) Example() Func Example() ; Create UI Automation object Local $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation ) If Not IsObj( $oUIAutomation ) Then Return ConsoleWrite( "$oUIAutomation ERR" & @CRLF ) ConsoleWrite( "$oUIAutomation OK" & @CRLF ) ; Get Desktop element Local $pDesktop, $oDesktop $oUIAutomation.GetRootElement( $pDesktop ) $oDesktop = ObjCreateInterface( $pDesktop, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oDesktop ) Then Return ConsoleWrite( "$oDesktop ERR" & @CRLF ) ConsoleWrite( "$oDesktop OK" & @CRLF ) EndFunc 9. How to identify and find application top window Click Notepad window in the treeview to return to the Detail info listview page. Select the row as shown, right-click and click Create sample code. The new code that's added to the bottom of the existing code should look like this in the listview Code page: ; --- Find window/control --- ConsoleWrite( "--- Find window/control ---" & @CRLF ) Local $pCondition0 $oUIAutomation.CreatePropertyCondition( $UIA_ClassNamePropertyId, "Notepad", $pCondition0 ) If Not $pCondition0 Then Return ConsoleWrite( "$pCondition0 ERR" & @CRLF ) ConsoleWrite( "$pCondition0 OK" & @CRLF ) Local $pWindow1, $oWindow1 $oDesktop.FindFirst( $TreeScope_Descendants, $pCondition0, $pWindow1 ) $oWindow1 = ObjCreateInterface( $pWindow1, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oWindow1 ) Then Return ConsoleWrite( "$oWindow1 ERR" & @CRLF ) ConsoleWrite( "$oWindow1 OK" & @CRLF ) If you accidentally selected a wrong row in the Detail info listview page, then click Sample code | Undo code, click treeview, select the right row in the listview, right-click and click Create sample code. 10. How to identify and find UI elements (controls) Click the Edit control in the treeview. Select the row as shown, right-click and click Create sample code. New code: ; --- Find window/control --- ConsoleWrite( "--- Find window/control ---" & @CRLF ) Local $pCondition1 $oUIAutomation.CreatePropertyCondition( $UIA_AutomationIdPropertyId, "15", $pCondition1 ) If Not $pCondition1 Then Return ConsoleWrite( "$pCondition1 ERR" & @CRLF ) ConsoleWrite( "$pCondition1 OK" & @CRLF ) Local $pEdit1, $oEdit1 $oWindow1.FindFirst( $TreeScope_Descendants, $pCondition1, $pEdit1 ) $oEdit1 = ObjCreateInterface( $pEdit1, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oEdit1 ) Then Return ConsoleWrite( "$oEdit1 ERR" & @CRLF ) ConsoleWrite( "$oEdit1 OK" & @CRLF ) 11. How to get UI element property values Extract window handle and bounding rectangle for the Edit control. The far easiest way to extract properties is through Sample code | Properties... Select the row as shown, right-click and click Create sample code. New code: ; --- Element Properties --- ConsoleWrite( "--- Element Properties ---" & @CRLF ) Local $hNativeWindowHandle1 $oEdit1.GetCurrentPropertyValue( $UIA_NativeWindowHandlePropertyId, $hNativeWindowHandle1 ) ConsoleWrite( "$hNativeWindowHandle1 = " & $hNativeWindowHandle1 & @CRLF ) Local $asBoundingRectangle1 $oEdit1.GetCurrentPropertyValue( $UIA_BoundingRectanglePropertyId, $asBoundingRectangle1 ) UIA_GetArrayPropertyValue( $asBoundingRectangle1 ) ConsoleWrite( "$asBoundingRectangle1 = " & $asBoundingRectangle1 & @CRLF ) UIA_GetArrayPropertyValue() in UIA_Functions.au3 converts a property returned as an array to a comma separated string. 12. How to create element action objects Create the ValuePattern action object. It'll be used in topic 14 to set a new text in the Edit control. Click the Edit control in the treeview. Select the row as shown (scroll down), right-click and click Create sample code. New code: ; --- Value Pattern (action) Object --- ConsoleWrite( "--- Value Pattern (action) Object ---" & @CRLF ) Local $pValuePattern1, $oValuePattern1 $oEdit1.GetCurrentPattern( $UIA_ValuePatternId, $pValuePattern1 ) $oValuePattern1 = ObjCreateInterface( $pValuePattern1, $sIID_IUIAutomationValuePattern, $dtagIUIAutomationValuePattern ) If Not IsObj( $oValuePattern1 ) Then Return ConsoleWrite( "$oValuePattern1 ERR" & @CRLF ) ConsoleWrite( "$oValuePattern1 OK" & @CRLF ) 13. How to get pattern property values Extract the existing text in the Edit control. That's the $UIA_ValueValuePropertyId. Click the Edit control in the treeview. Select the row as shown (scroll down), right-click and click Create sample code. New code: ; --- Control Pattern Properties --- ConsoleWrite( "--- Control Pattern Properties ---" & @CRLF ) Local $sValueValue1 $oEdit1.GetCurrentPropertyValue( $UIA_ValueValuePropertyId, $sValueValue1 ) ConsoleWrite( "$sValueValue1 = " & $sValueValue1 & @CRLF ) 14. How to perform element actions Set a new text, HelloWorld, in the Edit control with the SetValue() method of the ValuePattern action object. Click the Edit control in the treeview. Select the row as shown (scroll down), right-click and click Create sample code. New code: ; --- Value Pattern (action) Methods --- ConsoleWrite( "--- Value Pattern (action) Methods ---" & @CRLF ) $oValuePattern1.SetValue(bstr) ConsoleWrite( "$oValuePattern1.SetValue()" & @CRLF ) bstr must be replaced with "HelloWorld". We'll do that in topic 15. 15. How to create executable code The code in the listview Code page isn't immediately executable. A few necessary corrections must be made before the code is executable. Click Sample code | Corrections to add a list of necessary and nice corrections. New code: ; Code corrections: ; CUIAutomation2.au3 path ; UIA_Functions.au3 path ; Code to open target appl ; Create undeclared variables ; Delete double declared variables ; Window, Pane, Parent and Control names ; Fill out Pattern (action) Method parameters All code directly from the listview Code page (Examples\2) How to topics\Notepad\ListViewCodePage.au3): #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 ;#AutoIt3Wrapper_UseX64=n ; If target application is running as 32 bit code ;#AutoIt3Wrapper_UseX64=y ; If target application is running as 64 bit code #include "CUIAutomation2.au3" ; Get proper version in UIASpy Includes folder ;#include "UIA_Functions.au3" ; Can be copied from UIASpy Includes folder Opt( "MustDeclareVars", 1 ) Example() Func Example() ; Create UI Automation object Local $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation ) If Not IsObj( $oUIAutomation ) Then Return ConsoleWrite( "$oUIAutomation ERR" & @CRLF ) ConsoleWrite( "$oUIAutomation OK" & @CRLF ) ; Get Desktop element Local $pDesktop, $oDesktop $oUIAutomation.GetRootElement( $pDesktop ) $oDesktop = ObjCreateInterface( $pDesktop, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oDesktop ) Then Return ConsoleWrite( "$oDesktop ERR" & @CRLF ) ConsoleWrite( "$oDesktop OK" & @CRLF ) EndFunc ; --- Find window/control --- ConsoleWrite( "--- Find window/control ---" & @CRLF ) Local $pCondition0 $oUIAutomation.CreatePropertyCondition( $UIA_ClassNamePropertyId, "Notepad", $pCondition0 ) If Not $pCondition0 Then Return ConsoleWrite( "$pCondition0 ERR" & @CRLF ) ConsoleWrite( "$pCondition0 OK" & @CRLF ) Local $pWindow1, $oWindow1 $oDesktop.FindFirst( $TreeScope_Descendants, $pCondition0, $pWindow1 ) $oWindow1 = ObjCreateInterface( $pWindow1, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oWindow1 ) Then Return ConsoleWrite( "$oWindow1 ERR" & @CRLF ) ConsoleWrite( "$oWindow1 OK" & @CRLF ) ; --- Find window/control --- ConsoleWrite( "--- Find window/control ---" & @CRLF ) Local $pCondition1 $oUIAutomation.CreatePropertyCondition( $UIA_AutomationIdPropertyId, "15", $pCondition1 ) If Not $pCondition1 Then Return ConsoleWrite( "$pCondition1 ERR" & @CRLF ) ConsoleWrite( "$pCondition1 OK" & @CRLF ) Local $pEdit1, $oEdit1 $oWindow1.FindFirst( $TreeScope_Descendants, $pCondition1, $pEdit1 ) $oEdit1 = ObjCreateInterface( $pEdit1, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oEdit1 ) Then Return ConsoleWrite( "$oEdit1 ERR" & @CRLF ) ConsoleWrite( "$oEdit1 OK" & @CRLF ) ; --- Element Properties --- ConsoleWrite( "--- Element Properties ---" & @CRLF ) Local $hNativeWindowHandle1 $oEdit1.GetCurrentPropertyValue( $UIA_NativeWindowHandlePropertyId, $hNativeWindowHandle1 ) ConsoleWrite( "$hNativeWindowHandle1 = " & $hNativeWindowHandle1 & @CRLF ) Local $asBoundingRectangle1 $oEdit1.GetCurrentPropertyValue( $UIA_BoundingRectanglePropertyId, $asBoundingRectangle1 ) UIA_GetArrayPropertyValue( $asBoundingRectangle1 ) ConsoleWrite( "$asBoundingRectangle1 = " & $asBoundingRectangle1 & @CRLF ) ; --- Value Pattern (action) Object --- ConsoleWrite( "--- Value Pattern (action) Object ---" & @CRLF ) Local $pValuePattern1, $oValuePattern1 $oEdit1.GetCurrentPattern( $UIA_ValuePatternId, $pValuePattern1 ) $oValuePattern1 = ObjCreateInterface( $pValuePattern1, $sIID_IUIAutomationValuePattern, $dtagIUIAutomationValuePattern ) If Not IsObj( $oValuePattern1 ) Then Return ConsoleWrite( "$oValuePattern1 ERR" & @CRLF ) ConsoleWrite( "$oValuePattern1 OK" & @CRLF ) ; --- Control Pattern Properties --- ConsoleWrite( "--- Control Pattern Properties ---" & @CRLF ) Local $sValueValue1 $oEdit1.GetCurrentPropertyValue( $UIA_ValueValuePropertyId, $sValueValue1 ) ConsoleWrite( "$sValueValue1 = " & $sValueValue1 & @CRLF ) ; --- Value Pattern (action) Methods --- ConsoleWrite( "--- Value Pattern (action) Methods ---" & @CRLF ) $oValuePattern1.SetValue(bstr) ConsoleWrite( "$oValuePattern1.SetValue()" & @CRLF ) ; Code corrections: ; CUIAutomation2.au3 path ; UIA_Functions.au3 path ; Code to open target appl ; Create undeclared variables ; Delete double declared variables ; Window, Pane, Parent and Control names ; Fill out Pattern (action) Method parameters Necessary corrections: ; CUIAutomation2.au3 path ; UIA_Functions.au3 path ; Fill out Pattern (action) Method parameters And the code from line 26 must be moved into the function. All code after necessary corrections (Examples\2) How to topics\Notepad\NecessaryCorrections.au3): #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 ;#AutoIt3Wrapper_UseX64=n ; If target application is running as 32 bit code ;#AutoIt3Wrapper_UseX64=y ; If target application is running as 64 bit code #include "..\..\..\Includes\CUIAutomation2.au3" ; Get proper version in UIASpy Includes folder #include "..\..\..\Includes\UIA_Functions.au3" ; Can be copied from UIASpy Includes folder Opt( "MustDeclareVars", 1 ) Example() Func Example() ; Create UI Automation object Local $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation ) If Not IsObj( $oUIAutomation ) Then Return ConsoleWrite( "$oUIAutomation ERR" & @CRLF ) ConsoleWrite( "$oUIAutomation OK" & @CRLF ) ; Get Desktop element Local $pDesktop, $oDesktop $oUIAutomation.GetRootElement( $pDesktop ) $oDesktop = ObjCreateInterface( $pDesktop, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oDesktop ) Then Return ConsoleWrite( "$oDesktop ERR" & @CRLF ) ConsoleWrite( "$oDesktop OK" & @CRLF ) ; --- Find window/control --- ConsoleWrite( "--- Find window/control ---" & @CRLF ) Local $pCondition0 $oUIAutomation.CreatePropertyCondition( $UIA_ClassNamePropertyId, "Notepad", $pCondition0 ) If Not $pCondition0 Then Return ConsoleWrite( "$pCondition0 ERR" & @CRLF ) ConsoleWrite( "$pCondition0 OK" & @CRLF ) Local $pWindow1, $oWindow1 $oDesktop.FindFirst( $TreeScope_Descendants, $pCondition0, $pWindow1 ) $oWindow1 = ObjCreateInterface( $pWindow1, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oWindow1 ) Then Return ConsoleWrite( "$oWindow1 ERR" & @CRLF ) ConsoleWrite( "$oWindow1 OK" & @CRLF ) ; --- Find window/control --- ConsoleWrite( "--- Find window/control ---" & @CRLF ) Local $pCondition1 $oUIAutomation.CreatePropertyCondition( $UIA_AutomationIdPropertyId, "15", $pCondition1 ) If Not $pCondition1 Then Return ConsoleWrite( "$pCondition1 ERR" & @CRLF ) ConsoleWrite( "$pCondition1 OK" & @CRLF ) Local $pEdit1, $oEdit1 $oWindow1.FindFirst( $TreeScope_Descendants, $pCondition1, $pEdit1 ) $oEdit1 = ObjCreateInterface( $pEdit1, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oEdit1 ) Then Return ConsoleWrite( "$oEdit1 ERR" & @CRLF ) ConsoleWrite( "$oEdit1 OK" & @CRLF ) ; --- Element Properties --- ConsoleWrite( "--- Element Properties ---" & @CRLF ) Local $hNativeWindowHandle1 $oEdit1.GetCurrentPropertyValue( $UIA_NativeWindowHandlePropertyId, $hNativeWindowHandle1 ) ConsoleWrite( "$hNativeWindowHandle1 = " & $hNativeWindowHandle1 & @CRLF ) Local $asBoundingRectangle1 $oEdit1.GetCurrentPropertyValue( $UIA_BoundingRectanglePropertyId, $asBoundingRectangle1 ) UIA_GetArrayPropertyValue( $asBoundingRectangle1 ) ConsoleWrite( "$asBoundingRectangle1 = " & $asBoundingRectangle1 & @CRLF ) ; --- Value Pattern (action) Object --- ConsoleWrite( "--- Value Pattern (action) Object ---" & @CRLF ) Local $pValuePattern1, $oValuePattern1 $oEdit1.GetCurrentPattern( $UIA_ValuePatternId, $pValuePattern1 ) $oValuePattern1 = ObjCreateInterface( $pValuePattern1, $sIID_IUIAutomationValuePattern, $dtagIUIAutomationValuePattern ) If Not IsObj( $oValuePattern1 ) Then Return ConsoleWrite( "$oValuePattern1 ERR" & @CRLF ) ConsoleWrite( "$oValuePattern1 OK" & @CRLF ) ; --- Control Pattern Properties --- ConsoleWrite( "--- Control Pattern Properties ---" & @CRLF ) Local $sValueValue1 $oEdit1.GetCurrentPropertyValue( $UIA_ValueValuePropertyId, $sValueValue1 ) ConsoleWrite( "$sValueValue1 = " & $sValueValue1 & @CRLF ) ; --- Value Pattern (action) Methods --- ConsoleWrite( "--- Value Pattern (action) Methods ---" & @CRLF ) $oValuePattern1.SetValue( "HelloWorld" ) ConsoleWrite( "$oValuePattern1.SetValue()" & @CRLF ) ; Code corrections: ; CUIAutomation2.au3 path ; UIA_Functions.au3 path ; Fill out Pattern (action) Method parameters EndFunc Run the code. SciTE output: $oUIAutomation OK $oDesktop OK --- Find window/control --- $pCondition0 OK $oWindow1 OK --- Find window/control --- $pCondition1 OK $oEdit1 OK --- Element Properties --- $hNativeWindowHandle1 = 197258 $asBoundingRectangle1 = 258,100,984,842 --- Value Pattern (action) Object --- $oValuePattern1 OK --- Control Pattern Properties --- $sValueValue1 = Hello --- Value Pattern (action) Methods --- $oValuePattern1.SetValue() Nice corrections: Update comments. All code after nice corrections (Examples\2) How to topics\Notepad\NiceCorrections.au3): #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 ;#AutoIt3Wrapper_UseX64=n ; If target application is running as 32 bit code ;#AutoIt3Wrapper_UseX64=y ; If target application is running as 64 bit code #include "..\..\..\Includes\CUIAutomation2.au3" ; Get proper version in UIASpy Includes folder #include "..\..\..\Includes\UIA_Functions.au3" ; Can be copied from UIASpy Includes folder Opt( "MustDeclareVars", 1 ) Example() Func Example() ; Create UI Automation object Local $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation ) If Not IsObj( $oUIAutomation ) Then Return ConsoleWrite( "$oUIAutomation ERR" & @CRLF ) ConsoleWrite( "$oUIAutomation OK" & @CRLF ) ; Get Desktop element Local $pDesktop, $oDesktop $oUIAutomation.GetRootElement( $pDesktop ) $oDesktop = ObjCreateInterface( $pDesktop, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oDesktop ) Then Return ConsoleWrite( "$oDesktop ERR" & @CRLF ) ConsoleWrite( "$oDesktop OK" & @CRLF ) ; --- Find Notepad --- ConsoleWrite( "--- Find Notepad ---" & @CRLF ) Local $pCondition0 $oUIAutomation.CreatePropertyCondition( $UIA_ClassNamePropertyId, "Notepad", $pCondition0 ) If Not $pCondition0 Then Return ConsoleWrite( "$pCondition0 ERR" & @CRLF ) ConsoleWrite( "$pCondition0 OK" & @CRLF ) Local $pWindow1, $oWindow1 $oDesktop.FindFirst( $TreeScope_Descendants, $pCondition0, $pWindow1 ) $oWindow1 = ObjCreateInterface( $pWindow1, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oWindow1 ) Then Return ConsoleWrite( "$oWindow1 ERR" & @CRLF ) ConsoleWrite( "$oWindow1 OK" & @CRLF ) ; --- Find Edit control --- ConsoleWrite( "--- Find Edit control ---" & @CRLF ) Local $pCondition1 $oUIAutomation.CreatePropertyCondition( $UIA_AutomationIdPropertyId, "15", $pCondition1 ) If Not $pCondition1 Then Return ConsoleWrite( "$pCondition1 ERR" & @CRLF ) ConsoleWrite( "$pCondition1 OK" & @CRLF ) Local $pEdit1, $oEdit1 $oWindow1.FindFirst( $TreeScope_Descendants, $pCondition1, $pEdit1 ) $oEdit1 = ObjCreateInterface( $pEdit1, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oEdit1 ) Then Return ConsoleWrite( "$oEdit1 ERR" & @CRLF ) ConsoleWrite( "$oEdit1 OK" & @CRLF ) ; --- Element Properties --- ConsoleWrite( "--- Element Properties ---" & @CRLF ) Local $hNativeWindowHandle1 $oEdit1.GetCurrentPropertyValue( $UIA_NativeWindowHandlePropertyId, $hNativeWindowHandle1 ) ConsoleWrite( "$hNativeWindowHandle1 = " & $hNativeWindowHandle1 & @CRLF ) Local $asBoundingRectangle1 $oEdit1.GetCurrentPropertyValue( $UIA_BoundingRectanglePropertyId, $asBoundingRectangle1 ) UIA_GetArrayPropertyValue( $asBoundingRectangle1 ) ConsoleWrite( "$asBoundingRectangle1 = " & $asBoundingRectangle1 & @CRLF ) ; --- Value Pattern (action) Object --- ConsoleWrite( "--- Value Pattern (action) Object ---" & @CRLF ) Local $pValuePattern1, $oValuePattern1 $oEdit1.GetCurrentPattern( $UIA_ValuePatternId, $pValuePattern1 ) $oValuePattern1 = ObjCreateInterface( $pValuePattern1, $sIID_IUIAutomationValuePattern, $dtagIUIAutomationValuePattern ) If Not IsObj( $oValuePattern1 ) Then Return ConsoleWrite( "$oValuePattern1 ERR" & @CRLF ) ConsoleWrite( "$oValuePattern1 OK" & @CRLF ) ; --- Control Pattern Properties --- ConsoleWrite( "--- Control Pattern Properties ---" & @CRLF ) Local $sValueValue1 $oEdit1.GetCurrentPropertyValue( $UIA_ValueValuePropertyId, $sValueValue1 ) ConsoleWrite( "$sValueValue1 = " & $sValueValue1 & @CRLF ) ; --- Value Pattern (action) Methods --- ConsoleWrite( "--- Value Pattern (action) Methods ---" & @CRLF ) $oValuePattern1.SetValue( "HelloWorld" ) ConsoleWrite( "$oValuePattern1.SetValue()" & @CRLF ) ; Code corrections: ; CUIAutomation2.au3 path ; UIA_Functions.au3 path ; Fill out Pattern (action) Method parameters ; Nice corrections: Update comments EndFunc Run the code. SciTE output: $oUIAutomation OK $oDesktop OK --- Find Notepad --- $pCondition0 OK $oWindow1 OK --- Find Edit control --- $pCondition1 OK $oEdit1 OK --- Element Properties --- $hNativeWindowHandle1 = 197258 $asBoundingRectangle1 = 258,100,984,842 --- Value Pattern (action) Object --- $oValuePattern1 OK --- Control Pattern Properties --- $sValueValue1 = Hello --- Value Pattern (action) Methods --- $oValuePattern1.SetValue() Top of post
    1 point
  2. x86 is 32 bit, x64 is - guess - 64 bit
    1 point
  3. @nbarrosuriburu everything you state above is well known to the community. You are finding that, like other languages such as python, no one can control what a few bad apples choose to do with it. All we can do is keep the forum as free of that kind of stupidity as possible, to protect the reputation of the language. That is why you will see the forum rules specifically forbid things such as keyloggers, game bots, security measure bypasses, etc.
    1 point
  4. jchd

    regexp help

    Try this: Local $u = 'https://www.casa.it/srp/?page=1&tr=vendita&category=residenziale&surrounding=false&geopolygon={"polygon":[[43.843557448900775,10.489038304546511],[43.84241221396654,10.4942954342157],[43.84258245298302,10.494424180248415],[43.84313959545863,10.493694619396365],[43.84496574820621,10.495239571788943],[43.84621926137939,10.492643193462527],[43.846559717198694,10.491162614086306],[43.845894279011965,10.490411595562136],[43.84573178716427,10.488995389202273],[43.84573952488136,10.4888022701532]],"bbox":[[43.8481226939768,10.48334129259888],[43.84084908756247,10.500700549343264]],"zoom":17}&precision=8' Local $s = BinaryToString(InetRead($u)) Local $f = _TempFile(".\") Local $h = FileOpen($f, $FO_OVERWRITE) $s = '"Price €","Rent €","Area m²","Rooms","Parking"' & @CRLF & _ StringRegExpReplace($s, _ '(?sx)' & _ '(?: .*? < div\ class="features" [^<]*? > )' & _ '(?: < [^<]*? > )* (?: [^<]* )' & _ '(?: < [^<]*? > )* ( \d+ ) . ( \d+ )' & _ '(?: < [^<]*? > )* (?: [^<]* )' & _ '(?: < [^<]*? > )* (?: [^<]* )' & _ '(?: < [^<]*? > )* ( \d+ ) .? ( \d* )' & _ '(?: < [^<]*? > )* (?: [^<]* )' & _ '(?: < [^<]*? > )* ( \d+ )' & _ '(?: < [^<]*? > )* (?: [^<]* )' & _ '(?: < [^<]*? > )* (?: [^<]* )' & _ '(?: < [^<]*? > )* ( \d+ )' & _ '(?: < [^<]*? > )* (?: [^<]* )' & _ '(?: < [^<]*? > )* (?: [^<]* )' & _ '(?: < [^<]*? > )* ( \d* )' & _ '(?: < [^<]*? > )* (?: [^<]* )' & _ '(?: < [^<]*? > )* (?: <\/div> .*? (?= <div\ class="features" | $ ) )', _ "$1$2, $3$4, $5, $6, $7" & @CRLF) FileWrite($h, $s) FileClose($h) Local $a _FileReadToArray($f, $a,$FRTA_NOCOUNT, ',') FileDelete($f) _ArrayDisplay($a) Beware, such parsing may break when the site decide to change its format!
    1 point
  5. iamtheky

    regexp help

    i'd like to see this in one big regex, but as best i can determine - find the reactid for 'mq' - get the value at the location "react-text: [reactid minus 2]" *2 bonus mq entries at the end need to be cleaned up, i brute force them with pop #include <Inet.au3> #include <Array.au3> $sHTM = 'https://www.casa.it/srp/?page=1&tr=vendita&category=residenziale&surrounding=false&geopolygon=%7B' $s = BinaryToString(InetRead($sHTM)) $a = StringRegExp($s , 'reactid="(\d+)">mq<' , 3) _ArrayPop($a) _ArrayPop($a) for $i = 0 to ubound($a) - 1 $a[$i] = stringregexp($s , 'react-text: ' & $a[$i] - 2 & ' -->(.*?)<' , 3)[0] & 'mq' Next _ArrayDisplay($a)
    1 point
  6. mikell

    regexp help

    You might first remove all the "<...>" parts, so the result will be much easier to treat Example $s = '<p data-reactid="202">Appartamento</p></div><div class="features" data-reactid="203"><p data-reactid="204"><!-- react-text: 205 -->€ <!-- /react-text --><!-- react-text: 206 -->79.000<!-- /react-text --><span data-reactid="207"><!-- react-text: 208 -->Tua da <!-- /react-text --><span class="asStrong" data-reactid="209"><!-- react-text: 210 -->€ <!-- /react-text --><!-- react-text: 211 -->261<!-- /react-text --></span><!-- react-text: 212 -->/mese<!-- /react-text --></span></p><ul data-reactid="213"><li data-reactid="214"><!-- react-text: 215 -->55<!-- /react-text --><!-- react-text: 216 --> <!-- /react-text --><span data-reactid="217">mq</span></li><li data-reactid="218">' $r = StringRegExpReplace($s, '<.*?>', "") Msgbox(0,"", $r)
    1 point
  7. I am looking to run chromedriver using a persistent chrome profile. I am having an issue getting my argument to pass to chromedriver I believe, because chromedriver continues to create a temp profile each session. The console reads that I have added the --user-data-dir, and I have used the following to make sure it is correct, but am having no luck yet. I am new to using Webdriver so as a starting point I am running a copy of wd_demo with only the DriverParams of SetupGoogle() changed. Func SetupChrome() _WD_Option('Driver', 'chromedriver.exe') _WD_Option('Port', 9515) _WD_Option('DriverParams', '--user-data-dir="C:\Users\' & @UserName & '\AppData\Local\Google\Chrome\User Data"') $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true }}}}' EndFunc It seems that my params are being ignored, as the console writes that the profile being used is still the temp one _WDStartup: OS: WIN_10 WIN32_NT 17134 _WDStartup: AutoIt: 3.3.14.2 _WDStartup: WD.au3: 0.1.0.17 _WDStartup: Driver: chromedriver.exe _WDStartup: Params: --user-data-dir="C:\Users\Jan\AppData\Local\Google\Chrome\User Data" _WDStartup: Port: 9515 __WD_Post: URL=HTTP://127.0.0.1:9515/session; $sData={"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true }}}} __WD_Post: StatusCode=200; ResponseText={"value":{"capabilities":{"acceptInsecureCerts":false,"browserName":"chrome","browserVersion":"71.0.3578.98","chrome":{"chromedriverVersion":"2.45.615291 (ec3682e3c9061c10f26ea9e5cdcf3c53f3f74387)","userDataDir":"C:\\Users\\Jan\\AppData\\Local\\Temp\\scoped_dir11284_12516"},"goog:chromeOptions":{"debuggerAddress":"localhost:50445"},"networkConnectionEnabled":false,"pageLoadStrategy":"normal","platformName":"windows nt","proxy":{},"setWindowRect":true,"strictFileInteractability":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"unhandledPromptBehavior":"dismiss and notify"},"sessionId":"ddca43a6ca34b812eab6e73a18a9d83f"}} My apologies if this is something simple. Thank you for your time. Edit: Accomplished this with $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["--user-data-dir=C:\\Users\\' & @UserName & '\\AppData\\Local\\Google\\Chrome\\User Data\\", "--profile-directory=Default"]}}}}'
    1 point
×
×
  • Create New...