Search the Community
Showing results for tags 'UIA'.
-
I have a project in mind that I would like to share. I would like to create example windows with standard elements like ComboBox, ListView, some Button, some text, some edit field. Nothing special just simple Window.Net form that can be created with this following UDF: or this one: The main idea is to easily provide possible modifications to the "Testing GUI Window", and no need for any other tool than the AutoIt + SciTE kit. Such "Testing GUI Window" will be very useful later on topic/threads/projects like: As I am not very familiar with NetFramework, I would like to ask for help with this project. Thanks in advance for any help. @mLipok
-
Hi, I am trying to catch closing of a window via the UIA. End goal is to detect closing of a Chrome's tab, but currently I am having issues with the window created with GUICreate. I have modified example from UI Automation Events . I added GUI to show issues. Inside this GUI AutomationEventHandler is attached to all buttons. There are two buttons created by the script. One displays the message while the other closes the GUI. There are also buttons from the title bar. I attached automation event handlers to those buttons too. Currently script notifies me if I click on "OK" button. If I click on any of "Close", "X" or "Minimize" button then I do not get any notification. Is it possible for the script to notify when any of the buttons mentioned above is clicked? #include "..\Includes\UIAEH_AutomationEventHandler.au3" $hMain=GUICreate("UI Automation Event Handler") $idButtonOK=GUICtrlCreateButton("OK",10,10) $idButtonClose=GUICtrlCreateButton("Close",70,10) $idOutput=GUICtrlCreateEdit("",10,35,300,300) GUISetState() UIAEH_AutomationEventHandlerCreate() If Not IsObj( $oUIAEH_AutomationEventHandler ) Then Exit ConsoleWrite( "$oUIAEH_AutomationEventHandler ERR" & @CRLF ) ConsoleWrite( "$oUIAEH_AutomationEventHandler OK" & @CRLF ) Local $oUIAutomation = ObjCreateInterface($sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtag_IUIAutomation) ;~ Local $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation8, $sIID_IUIAutomation6, $dtag_IUIAutomation6 ) If Not IsObj($oUIAutomation) Then Exit ConsoleWrite("$oUIAutomation ERR" & @CRLF) ConsoleWrite("$oUIAutomation OK" & @CRLF) Local $pIUIAutomationCacheRequest, $oIUIAutomationCacheRequest $oUIAutomation.CreateCacheRequest( $pIUIAutomationCacheRequest ) $oIUIAutomationCacheRequest = ObjCreateInterface( $pIUIAutomationCacheRequest, $sIID_IUIAutomationCacheRequest, $dtag_IUIAutomationCacheRequest ) If Not IsObj( $oIUIAutomationCacheRequest ) Then Exit ConsoleWrite("$oIUIAutomationCacheRequest Error" & @CRLF) If $oIUIAutomationCacheRequest.AddPattern($UIA_InvokePatternId) Then Exit ConsoleWrite("$oIUIAutomationCacheRequest.AddPattern Error" & @CRLF) If $oIUIAutomationCacheRequest.put_AutomationElementMode( $AutomationElementMode_Full) Then Exit ConsoleWrite("$oIUIAutomationCacheRequest.put_AutomationElementMode Error" & @CRLF) ;~ $pIUIAutomationCacheRequest=0 ConsoleWrite("--- Find window/control ---" & @CRLF) Local $pPane1, $oGUI $oUIAutomation.ElementFromHandle($hMain,$pPane1) $oGUI = ObjCreateInterface($pPane1, $sIID_IUIAutomationElement, $dtag_IUIAutomationElement) If Not IsObj($oGUI) Then Exit ConsoleWrite("$oGUI ERR" & @CRLF) ConsoleWrite("$oGUI OK" & @CRLF) Local $sNamePropperty, $sClassName1 $oGUI.GetCurrentPropertyValue($UIA_NamePropertyId, $sNamePropperty) ConsoleWrite("Name:" & $sNamePropperty & @CRLF) $oGUI.GetCurrentPropertyValue($UIA_ClassNamePropertyId, $sClassName1) ConsoleWrite("ClassName:" & $sClassName1 & @CRLF) ConsoleWrite("--- Find buttons ---" & @CRLF) Local $pCondition0 $oUIAutomation.CreatePropertyCondition($UIA_ControlTypePropertyId, $UIA_ButtonControlTypeId, $pCondition0) If Not $pCondition0 Then Exit ConsoleWrite("$pCondition0 ERR" & @CRLF) ConsoleWrite("$pCondition0 OK" & @CRLF) Local $pButtons, $oButton $oGUI.FindAll($TreeScope_Descendants, $pCondition0, $pButtons) ConsoleWrite("$oGUI FindAll()" & @CRLF) Local $oUIElementArray1, $iLength1 ; $pButtons is a pointer to an UI Automation element array $oUIElementArray1 = ObjCreateInterface($pButtons, $sIID_IUIAutomationElementArray, $dtag_IUIAutomationElementArray) $oUIElementArray1.Length($iLength1) If Not $iLength1 Then Exit ConsoleWrite("$iLength1 = 0 ERR" & @CRLF) ConsoleWrite("$iLength1 = " & $iLength1 & @CRLF) ; --- Code Snippets --- ConsoleWrite("--- Code Snippets ---" & @CRLF) Local $pElement1, $oElement1, $pCondition0 Local $sClassName1, $sLocalizedControlType1, $sName1, $hNativeWindowHandle1, $iError For $i = 0 To $iLength1 - 1 $oUIElementArray1.GetElement($i, $pElement1) $oElement1 = ObjCreateInterface($pElement1, $sIID_IUIAutomationElement, $dtag_IUIAutomationElement) $oElement1.GetCurrentPropertyValue($UIA_NamePropertyId, $sName1) ConsoleWrite("$sName1 = " & $sName1 & @CRLF) ;~ $iError = $oUIAutomation.AddAutomationEventHandler( $UIA_Invoke_InvokedEventId, $pElement1, $TreeScope_Children, 0, $oUIAEH_AutomationEventHandler ) ;~ $iError = $oUIAutomation.AddAutomationEventHandler( $UIA_Invoke_InvokedEventId, $pElement1, $TreeScope_Element, 0, $oUIAEH_AutomationEventHandler ) $iError = $oUIAutomation.AddAutomationEventHandler( $UIA_Invoke_InvokedEventId, $pElement1, $TreeScope_Element, $pIUIAutomationCacheRequest, $oUIAEH_AutomationEventHandler ) If $iError Then Exit ConsoleWrite( "AddAutomationEventHandler() ERR" & @CRLF ) ConsoleWrite( "AddAutomationEventHandler() OK" & @CRLF ) Next While Sleep(10) Switch GUIGetMsg() Case -3, $idButtonClose GUIDelete($hMain) MsgBox(0,"About to exit","") Quit() Case $idButtonOK GUICtrlSetData($idOutput,"You clicked on button" & @CRLF,"a") EndSwitch WEnd Func Quit() UIAEH_AutomationEventHandlerDelete() Exit EndFunc ; This is the function that receives events Func UIAEH_AutomationEventHandler_HandleAutomationEvent( $pSelf, $pSender, $iEventId ) ; Ret: long Par: ptr;int ConsoleWrite( @CRLF & "UIAEH_AutomationEventHandler_HandleAutomationEvent: $iEventId = " & $iEventId & @CRLF ) ;~ Local $oSender = ObjCreateInterface( $pSender, $sIID_IUIAutomationElement, $dtag_IUIAutomationElement ) ; Windows 7 ;Local $oSender = ObjCreateInterface( $pSender, $sIID_IUIAutomationElement2, $dtag_IUIAutomationElement2 ) ; Windows 8 ;Local $oSender = ObjCreateInterface( $pSender, $sIID_IUIAutomationElement3, $dtag_IUIAutomationElement3 ) ; Windows 8.1 ;Local $oSender = ObjCreateInterface( $pSender, $sIID_IUIAutomationElement4, $dtag_IUIAutomationElement4 ) ; Windows 10 First Local $oSender = ObjCreateInterface( $pSender, $sIID_IUIAutomationElement9, $dtag_IUIAutomationElement9 ) ; Windows 10 Last $oSender.AddRef() GUICtrlSetData($idOutput,"InvokedEvent:" & UIAEH_GetCurrentPropertyValue( $oSender, $UIA_NamePropertyId ) & @CRLF,"a") ConsoleWrite( "Title = " & UIAEH_GetCurrentPropertyValue( $oSender, $UIA_NamePropertyId ) & @CRLF & _ "Class = " & UIAEH_GetCurrentPropertyValue( $oSender, $UIA_ClassNamePropertyId ) & @CRLF & _ "Ctrl type = " & UIAEH_GetCurrentPropertyValue( $oSender, $UIA_ControlTypePropertyId ) & @CRLF & _ "Ctrl name = " & UIAEH_GetCurrentPropertyValue( $oSender, $UIA_LocalizedControlTypePropertyId ) & @CRLF & _ "Handle = " & "0x" & Hex( UIAEH_GetCurrentPropertyValue( $oSender, $UIA_NativeWindowHandlePropertyId ) ) & @CRLF & _ "Value = " & UIAEH_GetCurrentPropertyValue( $oSender, $UIA_ValueValuePropertyId ) & @CRLF ) MsgBox(0,"","Invoke event") Return 0x00000000 ; $S_OK #forceref $pSelf EndFunc ; Auxiliary function (for simple properties only) ; There must be only one instance of this function Func UIAEH_GetCurrentPropertyValue( $oSender, $iPropertyId ) Local $vPropertyValue $oSender.GetCurrentPropertyValue( $iPropertyId, $vPropertyValue ) Return $vPropertyValue EndFunc
-
Hello , I am trying to fetch data and control a Windows Program. The data isn't reflected in the Au3Info tool , hence used SimpleSpy UIA , for trying. The code is able to fetch only one row at a time. Most Strangely , the code doesn't retreive the same specified row consistently. If I run the same code , under same circumstance , it is still fetching different rows. This was when op2 and op3 were zero. I would not like to use this at all. Also , it takes 3 seconds for it search down the hiearchy and reach the row. I will need to fetch ALL the rows continuously for 6 hours every second , in a minimized state. Can you please help. Attached : 1. AuInfo summary 2. Code 3. Simple Spy Summary The Actions I am trying to do (in a Minimzed State - not affecting usage of computer for other purposes) 1. Fetch all Rows (number of rows will not always be constant 2. Press the Check box for a specific row(s) 3. Press the squareOff button on top Thanks a lot #include <MsgBoxConstants.au3> #include "UIAWrappers.au3" AutoItSetOption("MustDeclareVars", 1) Local $oP8=_UIA_getObjectByFindAll($UIA_oDesktop, "Title:=MO Trader;controltype:=UIA_WindowControlTypeId;class:=WindowsForms10.Window.8.app.0.3e799b_r8_ad1", $treescope_children) _UIA_Action($oP8,"setfocus") Local $oP7=_UIA_getObjectByFindAll($oP8, "Title:=;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.3e799b_r8_ad1", $treescope_children) _UIA_Action($oP7,"setfocus") Local $oP6=_UIA_getObjectByFindAll($oP7, "Title:=;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.3e799b_r8_ad1", $treescope_children) _UIA_Action($oP6,"setfocus") Local $oP5=_UIA_getObjectByFindAll($oP6, "Title:=;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.3e799b_r8_ad1", $treescope_children) _UIA_Action($oP5,"setfocus") Local $oP4=_UIA_getObjectByFindAll($oP5, "Title:=Day Net Position;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.3e799b_r8_ad1", $treescope_children) _UIA_Action($oP4,"setfocus") Local $oP3=_UIA_getObjectByFindAll($oP4, "Title:=;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.3e799b_r8_ad1", $treescope_children) _UIA_Action($oP3,"setfocus") Local $oP2=_UIA_getObjectByFindAll($oP3, "Title:=0.0000;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.3e799b_r8_ad1", $treescope_children) _UIA_Action($oP2,"setfocus") Local $oP1=_UIA_getObjectByFindAll($oP2, "Title:=0.0000;controltype:=UIA_TableControlTypeId;class:=WindowsForms10.Window.8.app.0.3e799b_r8_ad1", $treescope_children) _UIA_Action($oP1,"setfocus") Local $oP0=_UIA_getObjectByFindAll($oP1, "Title:=Data Panel;controltype:=UIA_CustomControlTypeId;class:=", $treescope_children) ;~ First find the object in the parent before you can do something Local $oUIElement=_UIA_getObjectByFindAll($oP0, "title:=Row 12;ControlType:=UIA_CustomControlTypeId", $treescope_subtree) _UIA_action($oUIElement,"click") Local $string = _UIA_action($oUIElement,"getValue") MsgBox($MB_OK,"", $string) Local $oUIElement2=_UIA_getObjectByFindAll($oP0, "title:=Row 6;ControlType:=UIA_CustomControlTypeId", $treescope_subtree) _UIA_action($oUIElement2,"click") Local $string2 = _UIA_action($oUIElement2,"getValue") MsgBox($MB_OK,"", $string2) SimpleSpy Row.txt
-
Good morning, all. I am having a very hard time figuring out why my code "breaks" every second (and every time after) iteration in the loop. I am trying to automate the process of filling out a form for work. I need to find and send data to seven fields and get data from one field. Here are a couple of pictures of the fields I am interacting with. The fields are on the same forum/page. (the green boxed ones) Here is my code so far. #AutoIt3Wrapper_Au3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7 ;Allows for the combining of UDFs by disabling error messages. (I get error messages for "problems" that dont actually exsist) #include <AD.au3> ;Allows Active Directory functions #include <Array.au3> ;Allows special Array functions #include <Constants.au3> ;Allows constants to be used #include <Date.au3> ;Allows Date and Time functions #include <DateTimeConstants.au3> ;Allows Date and Time constant functions #include "DTC.au3" ;Allows Custom Date and Time functions #include <IE.au3> ;Allows Internet Explorer functions #include <Misc.au3> ;Allows the "is pressed" function to be used #include <MsgBoxConstants.au3> ;Allows Message box function to be used #include <OutlookEX.au3> ;Allows the Outlook functions #include <String.au3> ;Allows special string functions #include <StringConstants.au3> ;Allows String constant functions #include <Timers.au3> ;Allows timer functions ;#RequireAdmin ;Requests admin privliges before starting program ; Special UDFs for UIA automation #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <debug.au3> #include <WinAPI.au3> #include "UIAWrappers.au3" #AutoIt3Wrapper_UseX64=N ;Should be used for stuff like tagpoint having right struct etc. when running on a 64 bits os ;******************************************************************************* ; Format and send the vaild E-mail's contents ;******************************************************************************* Func SendEmailData() ConsoleWrite("Action 16: Send E-mail Data to it's proper fields" & " at line: " & @ScriptLineNumber & @CRLF) ;=============================================================================== ; Store the Elements ;=============================================================================== ; Description _UIA_setVar("oDescription","Title:=Description:;controltype:=UIA_EditControlTypeId;class:=") ; Long Description OK Button _UIA_setVar("oLongButton","Title:=Long Description;controltype:=UIA_ImageControlTypeId;class:=") _UIA_setVar("oLongOk","Title:=OK;controltype:=UIA_ButtonControlTypeId;class:=") ; Work Order Number _UIA_setVar("oWorkOrderNum","Title:=Work Order:;controltype:=UIA_EditControlTypeId;class:=") ; Location _UIA_setVar("oLocation","Title:=Location:;controltype:=UIA_EditControlTypeId;class:=") ; Work Type _UIA_setVar("oWorkType","Title:=Work Type:;controltype:=UIA_EditControlTypeId;class:=") ; Reported By Date _UIA_setVar("oDate","Title:=Reported Date:;controltype:=UIA_EditControlTypeId;class:=") ; Reported By Person _UIA_setVar("oCustomer","Title:=Reported By:;controltype:=UIA_EditControlTypeId;class:=") ; Reported By Email _UIA_setVar("oEmail","Title:=Reported By Email:;controltype:=UIA_EditControlTypeId;class:=") ; Reported By Phone _UIA_setVar("oPhone","Title:=Reported By Phone:;controltype:=UIA_EditControlTypeId;class:=") Local $WorkType = "CM" ; Send the stored data to the proper field Local $stringSplitter = ", " Local $conCateStrings = $eDescription & $stringSplitter & $eComments Local $ComStringLen = StringLen($eComments) Local $TrimedDesc = StringTrimLeft($eDescription, 1) ;=============================================================================== ; Check to see if the Description and the Long Description can be concatenated If StringLen($conCateStrings) <= 100 Then Sleep(2000) _UIA_action("oDescription","highlight") Sleep(300) _UIA_Action("oDescription","setfocus") Sleep(300) _UIA_action("oDescription","click") Sleep(500) _UIA_action("oDescription", "setvalue", $conCateStrings) _UIA_action("oDescription","highlight") ; Wipes the long description so no duplication happens $eComments = "" ;=============================================================================== ; Send the Long Description in place of the Description ElseIf $TrimedDesc = "Other" AND $ComStringLen <= 100 Then Sleep(2000) _UIA_action("oDescription","highlight") Sleep(300) _UIA_Action("oDescription","setfocus") Sleep(300) _UIA_action("oDescription","click") Sleep(500) _UIA_action("oDescription", "setvalue", $eComments) _UIA_action("oDescription","highlight") Sleep(2000) ;=============================================================================== ; Send the Long Description in place of the Description and Send the rest of it to the Long Description field ElseIf $TrimedDesc = "Other" AND $ComStringLen >= 100 Then SplitLongDesc() ; Description gets the first 100 Characters $eDescription = $FirstLine ; Long Description gets the rest $eComments = StringMid($sNewString, 101) Sleep(2000) _UIA_action("oDescription","highlight") Sleep(500) _UIA_Action("oDescription","setfocus") Sleep(500) _UIA_action("oDescription","click") Sleep(500) _UIA_action("oDescription", "setvalue", $eDescription) _UIA_action("oDescription","highlight") Sleep(2000) ;=============================================================================== ; Send the Description and some of the Long Description ElseIf StringLen($eDescription) <= 80 AND $eComments <> "" Then SplitLongDesc() ; Description gets the first 100 Characters $eDescription = $FirstLine ; Long Description gets the rest $eComments = StringMid($sNewString, 101) Sleep(2000) _UIA_action("oDescription","highlight") Sleep(300) _UIA_Action("oDescription","setfocus") Sleep(300) _UIA_action("oDescription","click") Sleep(500) _UIA_action("oDescription", "setvalue", $eDescription) _UIA_action("oDescription","highlight") Sleep(2000) ;=============================================================================== ; Send the original Description Else Sleep(2000) _UIA_action("oDescription","highlight") Sleep(300) _UIA_Action("oDescription","setfocus") Sleep(300) _UIA_action("oDescription","click") Sleep(500) _UIA_action("oDescription", "setvalue", $eDescription) _UIA_action("oDescription","highlight") Sleep(2000) EndIf ;=============================================================================== ; Click the long description button Sleep(2000) _UIA_action("oLongButton","highlight") Sleep(300) _UIA_Action("oLongButton","setfocus") Sleep(300) _UIA_action("oLongButton", "click") _UIA_action("oLongButton", "highlight") _UIA_action("oLongButton", "click") Sleep(2000) ;=============================================================================== ; Send the long description Sleep(1000) if StringLen($eComments) >= 250 Then Sleep(500) Send($eComments) Sleep(10000) ElseIf StringLen($eComments) >= 150 Then Sleep(500) Send($eComments) Sleep(6000) ElseIf StringLen($eComments) <= 10 Then Sleep(500) Send($eComments) Sleep(1500) Else Sleep(500) Send($eComments) Sleep(4000) EndIf ;=============================================================================== ; Click the ok button Sleep(2000) _UIA_action("oLongOk","highlight") Sleep(300) _UIA_Action("oLongOk","setfocus") Sleep(300) _UIA_action("oLongOk", "click") _UIA_action("oLongOk", "highlight") Sleep(2000) ;=============================================================================== ; The work order number _UIA_action("oWorkOrderNum","highlight") Sleep(300) _UIA_Action("oWorkOrderNum","setfocus") Sleep(300) _UIA_action("oWorkOrderNum", "getvalue", $WoNum) _UIA_action("oWorkOrderNum","highlight") ;MsgBox("", "Work order number", $WoNum[2]) ;=============================================================================== ; The Location field Sleep(2000) _UIA_action("oLocation","highlight") Sleep(300) _UIA_Action("oLocation","setfocus") Sleep(300) _UIA_action("oLocation", "setvalue", $eLocation) _UIA_action("oLocation","highlight") ;=============================================================================== ; The Work Type field Sleep(2000) _UIA_action("oWorkType","highlight") Sleep(300) _UIA_Action("oWorkType","setfocus") Sleep(300) _UIA_action("oWorkType", "setvalue", $WorkType) _UIA_action("oWorkType","highlight") ;=============================================================================== ; The Reported By Date Sleep(2000) _UIA_action("oDate","highlight") Sleep(300) _UIA_Action("oDate","setfocus") Sleep(300) _UIA_action("oDate", "setvalue", $eSentOn) _UIA_action("oDate","highlight") ;=============================================================================== ; The Requested by field Sleep(2000) _UIA_action("oCustomer","highlight") Sleep(300) _UIA_Action("oCustomer","setfocus") Sleep(300) _UIA_action("oCustomer", "setvalue", $eReportedBy) _UIA_action("oCustomer","highlight") ;=============================================================================== ; The Requested by E-mail Sleep(2000) _UIA_action("oEmail","highlight") Sleep(300) _UIA_Action("oEmail","setfocus") Sleep(300) _UIA_action("oEmail", "setvalue", $eSenderAddress) _UIA_action("oEmail","highlight") ;=============================================================================== ; The Requested by Phone Sleep(2000) _UIA_action("oPhone","highlight") Sleep(300) _UIA_Action("oPhone","setfocus") Sleep(300) _UIA_action("oPhone", "setvalue", $eRoomPhone) _UIA_action("oPhone","highlight") MouseClick("left", 1843, 437, 2) Sleep(1500) Send("{UP}") Send("{UP}") Send("{UP}") Send("{UP}") Send("{UP}") Send("{UP}") Send("{UP}") Send("{UP}") Send("{UP}") Send("{UP}") Send("{UP}") Send("{UP}") Send("{UP}") Send("{UP}") Send("{UP}") Send("{UP}") Send("{UP}") Send("{UP}") Send("{UP}") Send("{UP}") Send("{UP}") Send("{UP}") Send("{UP}") Send("{UP}") Send("{UP}") Send("{UP}") Send("{UP}") Send("{UP}") Send("{UP}") Send("{UP}") Send("{UP}") Send("{UP}") Sleep(1000) MouseClick("left", 591, 279, 2) Sleep(3000) $lCount += 1 ConsoleWrite("Action 16: Finished" & " at line: " & @ScriptLineNumber & @CRLF) Sleep(2000) EndFunc That is not all the code but that is the function that keeps "breaking" and by "breaking" I mean the program acts like it doesn't know where the description field is after the first iteration. My code will just click somewhere in the far top left corner and somehow shrink the browser in the process of finding the description field. The code works perfectly the first iteration but after that, it "breaks" (doesn't know where to click/send data to). As always any help is greatly appreciated. NOTE: By the time 'Action 16' runs Chrome has already been opened and has navigated to the proper webpage. I am trying to loop 'Action 16' multiple times. I do not leave that webpage while looping.
-
Good morning, I am having a hard time figuring out how to read or get the valve (628850) from the red squared box in the picture below. Here is what I have tried so far. (see code below. Also, I'm very sorry my code is sloppy.) #AutoIt3Wrapper_Au3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7 ;Allows for the combining of UDFs by disabling error messages. (I get error messages for "problems" that dont actually exsist) #include <AD.au3> ;Allows Active Directory functions #include <Array.au3> ;Allows special Array functions #include <Constants.au3> ;Allows constants to be used #include <Date.au3> ;Allows Date and Time functions #include <DateTimeConstants.au3> ;Allows Date and Time constant functions #include "DTC.au3" ;Allows Custom Date and Time functions #include <IE.au3> ;Allows Internet Explorer functions #include <Misc.au3> ;Allows the "is pressed" function to be used #include <MsgBoxConstants.au3> ;Allows Message box function to be used #include <OutlookEX.au3> ;Allows the Outlook functions #include <String.au3> ;Allows special string functions #include <StringConstants.au3> ;Allows String constant functions #include <Timers.au3> ;Allows timer functions ;#RequireAdmin ;Requests admin privliges before starting program #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <debug.au3> #include <WinAPI.au3> #include "UIAWrappers.au3" #AutoIt3Wrapper_UseX64=N ;Should be used for stuff like tagpoint having right struct etc. when running on a 64 bits os ; Sets the script to accept coordinates off the program window and not the screen AutoItSetOption('MouseCoordMode', 0) ; Defines the time it takes to send text to the software/program AutoItSetOption('SendKeyDelay', 10) ;******************************************************************************* ; Close the script if "End" is pressed ;******************************************************************************* Local $oMyError = ObjEvent("AutoIt.Error","MyErrFunc") HotKeySet("{END}", "Terminate") Func Terminate() MsgBox($MB_ICONINFORMATION, "DEATH", "AI Stoped!", 5) Exit EndFunc ;******************************************************************************* ; Script has started ;******************************************************************************* Sleep(2000) MsgBox($MB_ICONINFORMATION, "WO_AI", "AI Started!", 5) Sleep(1500) ;******************************************************************************* ; Main functions of the program ;******************************************************************************* test() ;=============================================================================== ; Function Definitions ;=============================================================================== Func test() MsgBox("", "TESTing", "Timer Started") Sleep(15000) MsgBox("", "TESTing", "timer Finished") ;~ *** Standard code maintainable *** AutoItSetOption("MustDeclareVars", 1) _UIA_setVar("oP1","Title:=Work Order Tracking - Google Chrome;controltype:=UIA_PaneControlTypeId;class:=Chrome_WidgetWin_1") ;Work Order Tracking - Google Chrome _UIA_setVar("oP2","Title:=Work Order Tracking;controltype:=UIA_DocumentControlTypeId;class:=Chrome_RenderWidgetHostHWND") ;Work Order Tracking _UIA_setVar("oP3","Title:= Work Order Tracking;controltype:=UIA_CustomControlTypeId;class:=") ; Work Order Tracking _UIA_setVar("oP4","Title:=main form;controltype:=UIA_GroupControlTypeId;class:=") ;main form _UIA_setVar("oP5","Title:=;controltype:=UIA_CustomControlTypeId;class:=") ; _UIA_setVar("oP6","Title:=View Work Details;controltype:=UIA_CustomControlTypeId;class:=") ;View Work Details _UIA_setVar("oP7","Title:=;controltype:=UIA_CustomControlTypeId;class:=") ; _UIA_setVar("oP8","Title:=Location: Location description Long Description Include Children? Include Children: unchecked Include Ancestors? Include Ancestors: unchecked Include History? Include History: unchecked Work Scope Minimize Work Scope Section Minimize Work Scope Section Work Scope Work Close Filter CTRL+Z Close Filter CTRL+Z Filter Filter Table Filter Table Next Row [CTRL+Down Arrow] Next Row [CTRL+Down Arrow] 1 - 4 of 4 Download Hide Table: Work Hide Table: Work Work Work Table Button Group;controltype:=UIA_CustomControlTypeId;class:=") ;Location: Location description Long Description Include Children? Include Children: unchecked Include Ancestors? Include Ancestors: unchecked Include History? Include History: unchecked Work Scope Minimize Work Scope Section Minimize Work Scope Section Work Scope Work Close Filter CTRL+Z Close Filter CTRL+Z Filter Filter Table Filter Table Next Row [CTRL+Down Arrow] Next Row [CTRL+Down Arrow] 1 - 4 of 4 Download Hide Table: Work Hide Table: Work Work Work Table Button Group _UIA_setVar("oP9","Title:=;controltype:=UIA_CustomControlTypeId;class:=") ; _UIA_setVar("oP10","Title:=Work;controltype:=UIA_TableControlTypeId;class:=") ;Work _UIA_setVar("oP11","Title:=;controltype:=UIA_CustomControlTypeId;class:=") ; _UIA_setVar("oP12","Title:=Record Detail Menu;controltype:=UIA_DataItemControlTypeId;class:=") ;Record Detail Menu ; Clicks on the main record field _UIA_setVar("oUIElement","Title:=Record ;controltype:=UIA_EditControlTypeId;class:=") ;ControlType:=UIA_EditControlTypeId;classname:=") ; Trying to click on / get value from the 3rd from top record field (this is me trying to use the id to access the record box) Local $otest =_UIA_getObjectByFindAll("Record.mainwindow", "id:=ma9038468_tdrow_[C\:1]_txt-tb[R\:3].;ControlType:=UIA_DataItemControlTypeId", $treescope_subtree) ;~ 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("oP10","highlight") _UIA_Action("oP10","setfocus") ;~_UIA_Action("oP11","highlight") _UIA_Action("oP11","setfocus") ;~_UIA_Action("oP12","highlight") _UIA_Action("oP12","setfocus") _UIA_action("oUIElement","highlight") _UIA_Action("oUIElement","setfocus") _UIA_action("oUIElement","click") Sleep(2500) _UIA_action($otest,"highlight") _UIA_Action($otest,"setfocus") _UIA_action($otest,"click") MsgBox("", "End of program", "death") EndFunc I'm using $otest to try and click on the box, through the id that chrome gives it, with the UIA functions. I am kind of completely new to the UIA UDF but I do find it capable of doing a lot of cool things. as always any help would be greatly appreciated. I know how hard you people hard. Thank you for taking the time to help us.
-
Good evening! Can somebody help me with getting text from wpf controls. With a help of inspect.exe I found element selector and now I need to get text from some button and assert that text is as expected?
-
Good Evening Everyone Long time since I've been in the forums - missing AutoIt and programming dearly - but on with the question... I hope this one is easy I am using SimpleSpy / UIAWrappers.au3 to automate an application. I basically have a "Stop" button that I am waiting to change from UIA_IsEnabled:= <False> to UIA_IsEnabled:= <True> How do I check for the UIA_IsEnabled condition ? Of course SimpleSpy gives all the details of GUI elements... but what code do I use to just check the GUI "Stop" buttons UIA_IsEnabled condition? Local $oUIElement=_UIA_getObjectByFindAll($oP0, "title:=Stop;ControlType:=UIA_ButtonControlTypeId", $treescope_subtree) Thanks!
- 9 replies
-
- automating applications
- simplespy
-
(and 1 more)
Tagged with:
-
I'm building a fake WinForms GUI that I'm using to test. In one instance, it has a panel with a number of text elements. I have the inspect.exe output of the real target UI that I'm trying to automate, but I'm trying to build a fake one now that emulates it so I can more easily test. The problem is the order of the text elements in the pane is different, and I'm having a helluva time trying to figure out how to set the order -- if that's even possible. The WinForms TabIndex property doesn't do it. There is no Index property on it otherwise. I'm worried it may not even be possible, so I figured I'd ask here. Thank in advance
-
Hey there, i have the code from simplespy but have no idea about what to use, got the UIA_V0_64 files. I look at the examples but i get lost, i ask for guideance in this matter. Best regards. To get to this window simply run: control.exe /name Microsoft.DefaultPrograms /page pageFileAssoc select a filetype and click "change program"
-
Consider the following image. I'm interested in all of the text elements embedded in the last pane called "Power Container". Unfortunately, this pane is embedded in 8 other panes with the same name and no other identifying characteristics. I think I can get to the target pane using indexrelative. Local $powerContainer = _UIA_getObjectByFindAll($cPowerMain, "controltype:=UIA_PaneControlTypeId;Name:=Power Container;indexrelative:=8", $treescope_subtree) If Not IsObj($powerContainer) Then Return ConsoleWrite("Could not find Power Container pane") So, now I have the pane, but I want to target individual text elements. They do seemingly have AutomationIds so I think I can use that as a selector. Problem is I'm building a fake WinForms GUI to test with since I don't have access to the real UI to automate for testing purposes, and with WinForms, there is no way to set the AutomationId. There is no other identifying information on these text elements. Their Name property contains the actual data, which varies. Except for the labels that sit in from of them. The way it is built it looks like this: My question is this: I know I can select to get the one with the static label value "Tag#" Local $tagLabel = _UIA_getObjectByFindAll($powerContainer, "controltype:='UIA_TextControlTypeId;Name:=Tag#", $treescope_subtree) Now, what I want to do is navigate to get the next sibling of this element. It doesn't look like the API allows me to do this? I think what I have to do is get a RawViewWalker and just iterate through all of them and inspect each one and figure out if it is what I'm looking for. Does this seem correct? Is there a better way to achieve this?
-
Hi, If I'm reading the code in UIAWrappers.au3 correctly, the function _UIA_getObjectByFindAll( ) uses the UIElement.FindAll with the true condition, so it would find any elements that match the treescope passed in. This populates an array, and then it iterates through them and tries matching the properties that were passed into _UIA_getObjectByFindAll and returns the first element that is the best match. I understand one can use the index or relativeindex properties to target a specific child, let's say when you have a panel that has a bunch of edit fields. If you know the specific index of the one you want you can use the index to get it back, but what if I want to return, say the whole array of UIElements that match a specific type. Is my best option here to just use the .FindAll( ) function directly and set my own condition to match the controltypeid?
-
I have a winforms app with multiple tabs on a tab control, and I'm trying to tab to one of them. I'm trying to use the Invoke pattern but it is not working. Apparently a tab doesn't implement invoke? What other pattern can I try? #include "../uia/UIA_V0_64/UIAWrappers.au3" #include "../uia/UIA_V0_64/CUIAutomation2.au3" AutoItSetOption("MustDeclareVars", 1) Example() Func Example() ; Get Handle to the application Local $hWindow = WinGetHandle("Service/STG") If Not $hWindow Then Return ConsoleWrite( "Window handle ERR" & @CRLF ) ConsoleWrite( "Window handle OK" & @CRLF ) WinActivate($hWindow) ; Create UI Automation object Local $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation ) If Not IsObj( $oUIAutomation ) Then Return ConsoleWrite( "UI Automation object ERR" & @CRLF ) ConsoleWrite( "UI Automation object OK" & @CRLF ) ; Get UI Automation element from window handle Local $pWindow, $oWindow $oUIAutomation.ElementFromHandle( $hWindow, $pWindow ) $oWindow = ObjCreateInterface( $pWindow, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oWindow ) Then Return ConsoleWrite( "Automation element from window ERR" & @CRLF ) ConsoleWrite( "Automation element from window OK" & @CRLF ) Local $pCondition, $pCondition1, $pCondition2 $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_TabItemControlTypeId, $pCondition1) $oUIAutomation.CreatePropertyCondition( $UIA_NamePropertyId, "Service/STG", $pCondition2) $oUIAutomation.CreateAndCondition( $pCondition1, $pCondition2, $pCondition ) If Not $pCondition Then Return ConsoleWrite("Property condition ERR" & @CRLF) ; Find the Service/STG Tab so we can click it Local $pTab, $oTab $oWindow.FindFirst($TreeScope_Descendants, $pCondition, $pTab) $oTab = ObjCreateInterface($pTab, $sIID_IUIAutomationElement, $dtagIUIAutomationElement) If Not IsObj($oTab) Then Return ConsoleWrite("Find Service tab ERR" & @CRLF) ; Invoke the Service/STG Tab Local $pInvoke, $oInvoke $oTab.GetCurrentPattern($UIA_InvokePatternId, $pInvoke) $oInvoke = ObjCreateInterface( $pInvoke, $sIID_IUIAutomationInvokePattern, $dtagIUIAutomationInvokePattern ) If Not IsObj( $oInvoke ) Then Return ConsoleWrite( "Invoke object ERR" & @CRLF) $oInvoke.Invoke()
-
I am parsing the rows of a tree control, but the parent window's title is variable along the lines of Local $oP4=_UIA_getObjectByFindAll($oP5, "Title:=List: Items (1);controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.13f082a_r27_ad1", $treescope_children) the (1) may be anything, I was hoping I could partial match with "Title:=List: Items" but this does not work Is there a way to get an object based on a partial title match? Thank you
- 4 replies
-
- treecontrol
- autoit
-
(and 1 more)
Tagged with:
-
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