JohnFisher Posted December 7, 2015 Share Posted December 7, 2015 OS: XP embedded with most features ( networking, IE etc) + Win7 embedded tooHave: Window is of class #32770, have title and windowhandler to use, but not button controller ID.Problem: Can't close the window.Want: programmatic way to close the window, or at least an approach to search for answers Details: WinClose blanks it. No buttons are shown in aut3info output. "Close" button and "x" button are visible until I run WinClose, at which point the window goes blank. The window belongs to a large exe from a 3rd-party that I can't close. I can close the window manually with a mouse, but not when I program mouse movements and mouse clicks in AutoIT. First lines of simplespy output:2015-12-07 09:50:06 : Mouse position is retrieved 585-4652015-12-07 09:50:06 : At least we have an element [Update - OfficeScan][#32770]2015-12-07 09:50:06 : Having the following values for all properties: Title is: <Update - Pep> Class := <#32770> controltype:= <UIA_PaneControlTypeId> ,<50033> , (0000C371) *** Parent Information ***Title is: <Desktop> Class := <#32769> controltype:= <UIA_PaneControlTypeId> ,<50033> , (0000C371) *** Detailed properties of the highlighted element ***UIA_AcceleratorKeyPropertyId :=UIA_AccessKeyPropertyId :=UIA_AriaPropertiesPropertyId :=UIA_AriaRolePropertyId :=UIA_AutomationIdPropertyId :=UIA_BoundingRectanglePropertyId :=291;183;442;402UIA_ClassNamePropertyId :=#32770UIA_ClickablePointPropertyId :=UIA_ControllerForPropertyId :=UIA_ControlTypePropertyId :=50033 Link to comment Share on other sites More sharing options...
JohnFisher Posted December 7, 2015 Author Share Posted December 7, 2015 Some clarifications:Before I run Winclose a mouse movement and mouseclick will close the window.I am leery of this method as I have many endpoints to run this on and some have a diffferent screen size/resolution, which I think could cause the mouse position to be different, hence my desire to get a handler for that "close" button that will let me close it reliably. Link to comment Share on other sites More sharing options...
LarsJ Posted December 8, 2015 Share Posted December 8, 2015 To use UI Automation code (if WinClose/WinKill doesn't work) to click the Close button, you need to identify the Close button.The Spy tool information in first post is not the Close button. It could be a pane control probably just below the Close button. For some reason the Spy tool is providing information for the pane control and not the Close button. This is a known issue.You can use Inspect.exe from Windows SDK to identify the Close button. Just run Inspect.exe and hover the mouse cursor over the Close button. When you have identified the Close button it should be possible to automate a click. JohnFisher 1 Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
JohnFisher Posted December 8, 2015 Author Share Posted December 8, 2015 aha! ( me: linux guy, now responsible for windows)inspect yields ( see below) can I use LegacyIAccessible.ChildId: 0 to close the window? ( going to look that up now.)(trimmed)How found: Selected from tree...RuntimeId: "[42.918348.2.26]"BoundingRectangle: {l:708 t:183 r:728 b:217}ProcessId: 5568ControlType: UIA_HyperlinkControlTypeId (0xC355)LocalizedControlType: "hyperlink"Name: "Close"AccessKey: ""HasKeyboardFocus: falseIsKeyboardFocusable: falseIsEnabled: trueAutomationId: "winctrl_close"HelpText: "Close"IsPassword: falseIsOffscreen: falseOrientation: 0FrameworkId: "InternetExplorer"IsRequiredForForm: falseAriaProperties: ""IsDataValidForForm: trueProviderDescription: "[pid:5568,hwnd:0x0 Main(parent link):Microsoft: MSAA Proxy (unmanaged:uiautomationcore.dll)]"Value.IsReadOnly: trueValue.Value: "file:///C:/Program%20Files/YRG%20Active/Outside%20Client/www/1600/html/update.html?_=1449598783#"LegacyIAccessible.ChildId: 0LegacyIAccessible.DefaultAction: "Jump"LegacyIAccessible.Description: "Close"LegacyIAccessible.Help: "Close"LegacyIAccessible.KeyboardShortcut: ""LegacyIAccessible.Name: "Close"LegacyIAccessible.Role: link (0x1E)LegacyIAccessible.State: linked (0x400000) Link to comment Share on other sites More sharing options...
LarsJ Posted December 8, 2015 Share Posted December 8, 2015 Is this an IE window (LocalizedControlType: "hyperlink", FrameworkId: "InternetExplorer")? If this is the case it's probably much easier to automate the window with the IE UDF. Would it be possible for you to show a picture of the window? Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
JohnFisher Posted December 10, 2015 Author Share Posted December 10, 2015 I think it might be similar Lars...It is type internet-explorer_server just a rectangle with a colored rectangle, some text, and a rectangle with "close" on it. Its created from an html file with javascript, but behaves like a pop-up. It took me a while to realize it wasn't a C#/NET window.I used some code from a posting... here is the relevant part where you see the invoke failing, I already tried _UI_Action(objname, "click") click move close If _UIA_getPropertyValue( $oUIElement, $UIA_NamePropertyId ) == $Text Then ITHLog(_UIA_getPropertyValue( $oUIElement, $UIA_NamePropertyId) ) ;_UIA_action( $oUIElement, "highlight") ; Find parent control Local $pRawWalker, $oRawWalker, $pUIParent, $oUIParent $oUIAutomation.RawViewWalker( $pRawWalker ) $oRawWalker = ObjCreateInterface( $pRawWalker, $sIID_IUIAutomationTreeWalker, $dtagIUIAutomationTreeWalker ) $oRawWalker.GetParentElement( $pUIElement, $pUIParent ) If Not $pUIParent Then Return ITHLOg( "Find parent control ERR" & @CRLF ) ITHLog( "Parent control found OK" & @CRLF ) $oUIParent = ObjCreateInterface( $pUIParent, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) ; Click (invoke) parent button Local $pInvoke, $oInvoke $oUIParent.GetCurrentPattern($UIA_InvokePatternId, $pInvoke) If Not IsObj($oUIParent) Then Return ITHLog("parent object ERR" & @CRLF) $oInvoke = ObjCreateInterface($pInvoke, $sIID_IUIAutomationInvokePattern, $dtagIUIAutomationInvokePattern) If Not IsObj($oInvoke) Then Return ITHLog("Invoke pattern ERR" & @CRLF & $sIID_IUIAutomationInvokePattern & @CRLF & $dtagIUIAutomationInvokePattern) ITHLog("Invoke pattern OK" & @CRLF) $oInvoke.Invoke() ITHLog("error txt at end..." & @error & "......") Exit ITHLog("GetOurStuff:return obj") Return $oUIElement EndIfEndIf;;;; Relevant output:2015-12-09 16:28:04 :Parent control found OK2015-12-09 16:28:04 :Invoke pattern ERR{FB377FBE-8EA6-46D5-9C73-6499642D3059}Invoke hresult();2015-12-09 16:28:04 : FoundClose OBJ.......................2015-12-09 16:28:04 :bad obj Link to comment Share on other sites More sharing options...
JohnFisher Posted December 10, 2015 Author Share Posted December 10, 2015 Heres a slightly different output from inspect.exeHow found: Selected from tree...BoundingRectangle: {l:306 t:256 r:635 b:282}ProcessId: 5568ControlType: UIA_TextControlTypeId (0xC364)LocalizedControlType: "text"Name: "Component update is complete."AccessKey: ""HasKeyboardFocus: falseIsKeyboardFocusable: falseIsEnabled: trueHelpText: ""IsPassword: falseIsOffscreen: falseProviderDescription: "[pid:5568,hwnd:0x0 Main(parent link):Microsoft: MSAA Proxy (unmanaged:uiautomationcore.dll)]"Value.IsReadOnly: trueLegacyIAccessible.ChildId: 2LegacyIAccessible.Help: ""LegacyIAccessible.KeyboardShortcut: ""LegacyIAccessible.Name: "Component update is complete."LegacyIAccessible.Role: editable text (0x2A)LegacyIAccessible.State: read only (0x40)IsDockPatternAvailable: falseIsExpandCollapsePatternAvailable: falseIsGridItemPatternAvailable: falseIsGridPatternAvailable: falseIsInvokePatternAvailable: falseIsLegacyIAccessiblePatternAvailable: trueIsMultipleViewPatternAvailable: falseIsRangeValuePatternAvailable: falseIsScrollPatternAvailable: falseIsScrollItemPatternAvailable: falseIsSelectionItemPatternAvailable: falseIsSelectionPatternAvailable: falseIsTablePatternAvailable: falseIsTableItemPatternAvailable: falseIsTextPatternAvailable: falseIsTogglePatternAvailable: falseIsTransformPatternAvailable: falseIsValuePatternAvailable: trueIsWindowPatternAvailable: falseIsItemContainerPatternAvailable: falseIsVirtualizedItemPatternAvailable: falseIsSynchronizedInputPatternAvailable: falseFirstChild: [null]LastChild: [null]Next: "Component update is complete." textPrevious: "Update" textOther Props: Object has no additional propertiesChildren: Container has no children Link to comment Share on other sites More sharing options...
LarsJ Posted December 10, 2015 Share Posted December 10, 2015 This seems to be a tricky little button. Maybe the button supports pure MSAA code better than UI Automation code. Information especially in post 4 might imply this. Will you switch Inspect.exe to MSAA mode (dropdown in upper left corner) and post the same information as in post 4.If the button supports MSAA code you can use accDoDefaultAction method to click the button. If this doesn't work a mouse click seems to be the only solution. At least it's possible to get the bounding rectangle of the button. Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
JohnFisher Posted December 10, 2015 Author Share Posted December 10, 2015 What do you think?inspect->MSAA-> (raise dialog )-> copy dataHow found: Focus [o:0xFFFFFFFC,c:0x0] hwnd=0x000503A2 32bit class="#32770" style=0x94000044 ex=0x90000ChildId: 0Interfaces: IEnumVARIANT IOleWindow IAccIdentityImpl: Local oleacc proxyAnnotationID: 01000080A2030500FCFFFFFF00000000Name: "Update - XXX"Value: [null]Role: dialog (0x12)State: focused,focusable (0x100004)Location: {l:291, t:183, w:442, h:402}Selection: Description: [null]Kbshortcut: [null]DefAction: [null]Help: [null]HelpTopic: ""ChildCount: 0Window: 0x503A2FirstChild: [null]LastChild: [null]Next: [null]Previous: [null]Left: [null]Up: [null]Right: [null]Down: [null]Other Props: Object has no additional propertiesChildren: Container has no childrenAncestors: "Update - XXX" : window : focused,focusable "Desktop" : client : focusable "Desktop" : window : focusable [ No Parent ] Link to comment Share on other sites More sharing options...
JohnOne Posted December 10, 2015 Share Posted December 10, 2015 How about getting the process of the window and ending that? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
JohnFisher Posted December 10, 2015 Author Share Posted December 10, 2015 JohnOne the dialog is only part of the process, and the process can't ( well -shouldn't- be killed) Link to comment Share on other sites More sharing options...
LarsJ Posted December 10, 2015 Share Posted December 10, 2015 Is this the Close button with the name "Update - XXX"? I don't think so. I would have expected information for a button with the name "Close" as in post 4. Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
JohnFisher Posted December 10, 2015 Author Share Posted December 10, 2015 (edited) Is this the Close button with the name "Update - XXX"? I don't think so. I would have expected information for a button with the name "Close" as in post 4.No thats the window. Here is another try at the inspect data. ( Its hard to get right because many elements on the tree in inspect have the same name) expandcollapse popupHow found: Selected from tree... ChildId: 9 Interfaces: Impl: Remote native IAccessible Name: "Close" Value: [Error: hr=0x80004001 - Not implemented] Role: editable text (0x2A) State: read only (0x40) Location: {l:651, t:555, w:36, h:15} Description: [Error: hr=0x80004001 - Not implemented] Kbshortcut: [null] DefAction: [Error: hr=0x80004001 - Not implemented] Help: [null] HelpTopic: "" ChildCount: 0 Window: 0x503AE FirstChild: [null] LastChild: [null] Next: "Help" : link : linked Previous: "Please check your internet connection or your %proxy_settings%." : editable text : read only,invisible Left: [Error: hr=0x80004001 - Not implemented] Up: [Error: hr=0x80004001 - Not implemented] Right: [Error: hr=0x80004001 - Not implemented] Down: [Error: hr=0x80004001 - Not implemented] Other Props: Object has no additional properties Children: Container has no children Ancestors: "" : pane : read only "file://C:\Program Files\xxx\xxx Client\www\1600\html\update.html?_=1449768216" : client : focusable none : client : focusable none : window : focusable none : client : focusable none : window : focusable "Update - xxx" : dialog : focusable "Update - xxx" : window : focusable "Desktop" : client : focusable "Desktop" : window : focusable [ No Parent ] Edited December 10, 2015 by JohnFisher Link to comment Share on other sites More sharing options...
LarsJ Posted December 11, 2015 Share Posted December 11, 2015 This is still a wrong button. It should be easy to get the right control because Inspect.exe draws a yellow rectangle around the selected control.This is information from post 4:LegacyIAccessible.ChildId: 0 LegacyIAccessible.DefaultAction: "Jump" LegacyIAccessible.Description: "Close" LegacyIAccessible.Help: "Close" LegacyIAccessible.Name: "Close" LegacyIAccessible.Role: link (0x1E) LegacyIAccessible.State: linked (0x400000)This information in post 13 doesn't match the information in post 4:ChildId: 9 DefAction: [Error: hr=0x80004001 - Not implemented] Description: [Error: hr=0x80004001 - Not implemented] Help: [null] Name: "Close" Role: editable text (0x2A) State: read only (0x40)I would like to see more or less the same information for the Close button when Inspect.exe is running in MSAA mode as the information we get when Inspect.exe is running in UI Automation mode. We need the information to be able to identify the button with MSAA code.As you can see the name "Close" is not enough to identify the button. There can be many buttons with the name "Close". Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
JohnFisher Posted December 11, 2015 Author Share Posted December 11, 2015 First, thanks. I am quite new at any Windows stuff, the last I did was around year 2000.I understand this morning what you are pointing out, and its obvious what I did wrong: that last posting is the window button text object not the link/button itself, so another try...In MSAA mode there is an element in the treeview (leftside pane of inspect) for the clickable link, but when I highlight it, I get no change in the data. The other elements do produce data.So when I switch back to UIA mode, I do get data and here it is:expandcollapse popupHow found: Selected from tree... RuntimeId: "[42.590748.2.6]" BoundingRectangle: {l:708 t:183 r:728 b:217} ProcessId: 5860 ControlType: UIA_HyperlinkControlTypeId (0xC355) LocalizedControlType: "hyperlink" Name: "Close" AccessKey: "" HasKeyboardFocus: false IsKeyboardFocusable: false IsEnabled: true AutomationId: "winctrl_close" HelpText: "Close" IsPassword: false IsOffscreen: false Orientation: 0 FrameworkId: "InternetExplorer" IsRequiredForForm: false AriaProperties: "" IsDataValidForForm: true ProviderDescription: "[pid:5860,hwnd:0x0 Main(parent link):Microsoft: MSAA Proxy (unmanaged:uiautomationcore.dll)]" Value.IsReadOnly: true Value.Value: "file:///C:/Program%20Files/xxx/xxx/www/1600/html/update.html?_=1449855436#" LegacyIAccessible.ChildId: 0 LegacyIAccessible.DefaultAction: "Jump" LegacyIAccessible.Description: "Close" LegacyIAccessible.Help: "Close" LegacyIAccessible.KeyboardShortcut: "" LegacyIAccessible.Name: "Close" LegacyIAccessible.Role: link (0x1E) LegacyIAccessible.State: linked (0x400000) LegacyIAccessible.Value: "file:///C:/Program%20Files/xxx/xxx/www/1600/html/update.html?_=1449855436#" IsDockPatternAvailable: false IsExpandCollapsePatternAvailable: false IsGridItemPatternAvailable: false IsGridPatternAvailable: false IsInvokePatternAvailable: true IsLegacyIAccessiblePatternAvailable: true IsMultipleViewPatternAvailable: false IsRangeValuePatternAvailable: false IsScrollPatternAvailable: false IsScrollItemPatternAvailable: true IsSelectionItemPatternAvailable: false IsSelectionPatternAvailable: false IsTablePatternAvailable: false IsTableItemPatternAvailable: false IsTextPatternAvailable: false IsTogglePatternAvailable: false IsTransformPatternAvailable: false IsValuePatternAvailable: true IsWindowPatternAvailable: false IsItemContainerPatternAvailable: false IsVirtualizedItemPatternAvailable: false IsSynchronizedInputPatternAvailable: false FirstChild: [null] LastChild: [null] Next: [null] Previous: "Minimize" hyperlink Other Props: Object has no additional properties Children: Container has no children Ancestors: "" pane "file://C:\Program Files\xxx\xxxx\www\1600\html\update.html?_=1449855436" pane "" pane "" pane "xxx" dialog "xxx" dialog "Desktop" pane [ No Parent ] Link to comment Share on other sites More sharing options...
LarsJ Posted December 11, 2015 Share Posted December 11, 2015 (edited) There's nothing to do about it. Try running this code and see if it works. You need MSAccessibility.au3.Be sure to grab the right window. There are many #32770 class windows. Look at WinGetHandle in the helpfile.Run the program in SciTE. It writes information in the console.If the script finds the button based on name and role, it clicks the button with the accDoDefaultAction method. This should close the window and the script exits.expandcollapse popupGlobal Const $S_OK = 0x00000000 #include "MSAccessibility.au3" Opt( "MustDeclareVars", 1 ) Example() Func Example() Local $hWindow = WinGetHandle( "[CLASS:#32770]", "" ) If Not $hWindow Then Return ConsoleWrite( "Window handle ERR" & @CRLF ) ConsoleWrite( "Window handle OK" & @CRLF ) ; Get Window object Local $pWindow AccessibleObjectFromWindow( $hWindow, $OBJID_CLIENT, $tIID_IAccessible, $pWindow ) If Not $pWindow Then Return ConsoleWrite( "Window object ERR" & @CRLF ) ConsoleWrite( "Window object OK" & @CRLF ) WalkTreeWithAccessibleChildren( $pWindow, 0, 4 ) ; Max 4 levels EndFunc Func WalkTreeWithAccessibleChildren( $pAcc, $iLevel, $iLevels = 0 ) If $iLevels And $iLevel = $iLevels Then Return ; Create object Local $oAcc = ObjCreateInterface( $pAcc, $sIID_IAccessible, $dtagIAccessible ) If Not IsObj( $oAcc ) Then Return $oAcc.AddRef() Local $iChildCount, $iReturnCount, $tVarChildren ; Get children If $oAcc.get_accChildCount( $iChildCount ) Or Not $iChildCount Then Return If AccessibleChildren( $pAcc, 0, $iChildCount, $tVarChildren, $iReturnCount ) Then Return ; Indentation Local $sIndent = "" For $i = 0 To $iLevel - 1 $sIndent &= " " Next Local $vt, $pChildObj, $oChildObj, $iChildElem, $sName, $iRole ; For each child For $i = 1 To $iReturnCount ; $tVarChildren is an array of VARIANTs with information about the children $vt = BitAND( DllStructGetData( $tVarChildren, $i, 1 ), 0xFFFF ) If $vt = $VT_DISPATCH Then ; Child object $pChildObj = DllStructGetData( $tVarChildren, $i, 3 ) $oChildObj = ObjCreateInterface( $pChildObj, $sIID_IAccessible, $dtagIAccessible ) If IsObj( $oChildObj ) Then PrintObjectInfo( $oChildObj, $CHILDID_SELF, $sIndent ) $oChildObj.get_accName( $CHILDID_SELF, $sName ) If $sName = "Close" Then If $oChildObj.get_accRole( $CHILDID_SELF, $iRole ) = $S_OK Then If $iRole = 30 Then ; 0x1E $oChildObj.accDoDefaultAction(0) Exit EndIf EndIf EndIf WalkTreeWithAccessibleChildren( $pChildObj, $iLevel + 1, $iLevels ) EndIf Else ; $vt = $VT_I4 ; Child element $iChildElem = DllStructGetData( $tVarChildren, $i, 3 ) PrintObjectInfo( $oAcc, $iChildElem, $sIndent ) EndIf Next EndFunc Func PrintObjectInfo( $oAcc, $iChild, $sIndent ) Local $sName, $iRole, $sRole, $iRoleLen Local $iState, $sState, $iStateLen, $x, $y, $w, $h If $iChild <> $CHILDID_SELF Then _ ConsoleWrite( $sIndent & "$iChildElem = " & $iChild & @CRLF ) $oAcc.get_accName( $iChild, $sName ) ConsoleWrite( $sIndent & "Name = " & $sName & @CRLF ) EndFunc Edited December 12, 2015 by LarsJ Link for MSAccessibility.au3 Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
JohnFisher Posted December 14, 2015 Author Share Posted December 14, 2015 Thanks, LarsI dont get much result with your code, but I had already run pretty much the same stuff, probably taken from one of your posts or the examples. See the attached file of code and results.Sorry I can't give out the app I am testing - its proprietary. lars-forum-test.txt Link to comment Share on other sites More sharing options...
JohnFisher Posted December 14, 2015 Author Share Posted December 14, 2015 Ignore last post please, I've gotten past it.I've got everything except the click-expandcollapse popup#include "ith-CUIAutomation2.au3" #include "ith-MSAccessibility.au3" #include "ith-utilities.au3" Opt( "MustDeclareVars", 1 ) Example() Func Example() ; Get window handle Local $hWindow = WinGetHandle( "xxx" ) If Not $hWindow Then Return ConsoleWrite( "Window handle ERR" & @CRLF ) ConsoleWrite( "Window handle OK" & @CRLF ) ; 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 ) ; Condition to find text control Local $pCondition $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_TextControlTypeId, $pCondition ) If Not $pCondition Then Return ConsoleWrite( "Find condition ERR" & @CRLF ) ConsoleWrite( "Find condition OK" & @CRLF ) ; Find all text controls Local $pUIElementArray, $oUIElementArray, $iElements $oWindow.FindAll( $TreeScope_Descendants, $pCondition, $pUIElementArray ) $oUIElementArray = ObjCreateInterface( $pUIElementArray, $sIID_IUIAutomationElementArray, $dtagIUIAutomationElementArray ) $oUIElementArray.Length( $iElements ) If Not $iElements Then Return ConsoleWrite( "No objects found ERR" & @CRLF ) ConsoleWrite( $iElements & " objects found OK" & @CRLF ) ; Identify text control by name Local $pUIElement, $oUIElement, $fIdentified = False For $i = 0 To $iElements - 1 $oUIElementArray.GetElement( $i, $pUIElement ) $oUIElement = ObjCreateInterface( $pUIElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If _UIA_getPropertyValue( $oUIElement, $UIA_NamePropertyId ) = "Component update is complete." Then ConsoleWrite( "FOUND: Component update is complete. text" & @CRLF ) $fIdentified = True ExitLoop EndIf Next If $fIdentified Then ; Identify button by name $pUIElement = False $oUIElement = False $fIdentified = False For $i = 0 To $iElements - 1 $oUIElementArray.GetElement( $i, $pUIElement ) $oUIElement = ObjCreateInterface( $pUIElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If _UIA_getPropertyValue( $oUIElement, $UIA_NamePropertyId ) = "Close" Then ConsoleWrite( "FOUND: Close button" & @CRLF ) ;;###### GOOD TO HERE ########################## ;; #### NO CLICK?! _UIA_Action($oUIElement,"click") Else ConsoleWrite( "NOT FOUND: Close button" & @CRLF ) EndIf Next EndIf EndFunc Link to comment Share on other sites More sharing options...
JohnFisher Posted December 14, 2015 Author Share Posted December 14, 2015 AHAI needed to setfocus and then click. thanks, all done. Link to comment Share on other sites More sharing options...
LarsJ Posted December 15, 2015 Share Posted December 15, 2015 Well done.Regards Lars. Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
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