UIA_IsEnabled - Loop until False changes to True
-
Recently Browsing 0 members
No registered users viewing this page.
-
Similar Content
-
By ythong
I have tried to combine several PropertyConditions with CreateAndConditionFromArray without success. According to Microsoft's api instructions, SafeArray needs to be used, and I don't understand how to use it. Can someone give an example of using CreateAndConditionFromArray?
-
By mLipok
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
-
By ahmet
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
-
By Sayed
Hi there,
I'm new in AutoIt forms and using AutoIt to automate desktop application (able to automate the application normally but facing issue when I've to re-run the application twice within the same script...so need help in this please)
here is the steps then followed by the issue in a brief :
1- run application .
2- do some actions (click menus,activate windows,set texts..)
3- close the application.
4- run the application again & access the same controls.
5- open the same windows again (like step 2)
6- perform some validations (by getting texts from some text boxes)
7- close the application again (and repeat 1-7 for 15 times in average )
The issue
* all controls are accessible in the first run and actions done successfully on controls (for steps 1-3) BUT from the second run of the application from step-4 it's able to set focus only the main application window.
Note: only unique properties used to while mapping the controls.
Error that appear in the console :
UIAWrappers.au3" (1673) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: $x = Int($t[1] + ($t[3] / 2)) $x = Int($t[1] + (^ ERROR
Simple spy code of one of the controls that has this strange issue(menubar&view menu Item):
;~ *** Standard code maintainable *** #include "UIAWrappers.au3" AutoItSetOption("MustDeclareVars", 1) _UIA_setVar("oP1","Title:=XXX;controltype:=UIA_WindowControlTypeId;class:=WindowsForms10.Window.8.app") ;main app form xxx _UIA_setVar("oP2","Title:=menuStrip1;controltype:=UIA_MenuBarControlTypeId;class:=WindowsForms10.Window.8.app") ;menuStrip1 ;~ $oUIElement=_UIA_getObjectByFindAll("View.mainwindow", "title:=View;ControlType:=UIA_MenuItemControlTypeId", $treescope_subtree) _UIA_setVar("oUIElement","Title:=View;controltype:=UIA_MenuItemControlTypeId;class:=") ;ControlType:=UIA_MenuItemControlTypeId;classname:=") ;~ Actions split away from logical/technical definition above can come from configfiles ;~_UIA_Action("oP1","highlight") _UIA_Action("oP1","setfocus") ;~_UIA_Action("oP2","highlight") _UIA_Action("oP2","setfocus") _UIA_action("oUIElement","highlight") ;~_UIA_action("oUIElement","click")
-
By adityaparakh
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
-
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now