junkew Posted May 23, 2011 Author Share Posted May 23, 2011 thx. Will have to clean up some function definition(s) for interface/enums currently using none.Everything combined together showing the automation api that works excellent from within AutoIT(Be aware that API is not allways installed under XP/Vista see http://support.microsoft.com/kb/971513)Next exercise is something like inspect.exe or a macrorecorder based on this stuffFun part of this is that IE, FF and Chrome also work all similar with this API. No separate logic for each browser needed.Chrome needs to start like chrome.exe --force-renderer-accessibilitySample0() ;- Just get all properties of the desktopSample1() ;- Just either find the programmanager and/or the calculator (calc.exe)Sample2() ;- Just iterate over the desktop windows and show their propertiesshellexecute("wordpad")sleep(1000) ;~ Some time to start wordpadSample3() ;- Automate some wordpad menu's showing the invokepatternAnd after that starting the focus changed handler showing the classname, name and value of all kinds of objects getting focusexpandcollapse popup#include <WinAPI.au3> #include <AutoItObject.au3> #include "CUIAutomation.au3" HotKeySet("{ESC}", "Terminate") ;~ Assume to have loaded the DLL first Global Const $hUIAutomation = DllOpen("uiautomationcore.dll") Global $objUIAutomation ;For creating the uiautomation instance Global $oDesktop ;Desktop will be frequently the starting point Global $aCall ;For handling the return values _AutoItObject_StartUp() ;Starting the autoit object library Local $pUIAutomationElement Global $oError = ObjEvent("AutoIt.Error", "_ErrFunc") Func _ErrFunc() ConsoleWrite("COM Error, ScriptLine(" & $oError.scriptline & ") : Number 0x" & Hex($oError.number, 8) & " - " & $oError.windescription & @CRLF) EndFunc ;==>_ErrFunc ;~ The main object with acces to the windows automation api 3.0 $objUIAutomation = _AutoItObject_ObjCreate($sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation) If IsObj($objUIAutomation) Then ConsoleWrite("At least it seems we have the core object to start with" & @CRLF) EndIf ;~ Try to get the desktop as a generic reference/global for all samples $aCall = $objUIAutomation.GetRootElement(0) $oDesktop = _AutoItObject_WrapperCreate($aCall[1], $dtagIUIAutomationElement) If IsObj($oDesktop) Then ConsoleWrite("At least it seems I have the desktop as a frequently used starting point" & @CRLF) EndIf ;~ Some samples Sample0() ;- Just get all properties of the desktop Sample1() ;- Just either find the programmanager and/or the calculator (calc.exe) Sample2() ;- Just iterate over the desktop windows and show their properties shellexecute("wordpad") sleep(1000) ;~ Some time to start wordpad Sample3() ;- Automate some wordpad menu's showing the invokepattern ;~ Focus Changed Handler Global $oFCEHandler = _AutoItObject_ObjectFromDtag("_MyHandler_", $dtagIUIAutomationFocusChangedEventHandler) $objUIAutomation.AddFocusChangedEventHandler(0, $oFCEHandler.__ptr__) While 1 Sleep(100) WEnd Func Terminate() $objUIAutomation.RemoveAllEventHandlers() $objUIAutomation = 0 $oFCEHandler = 0 $oElem = 0 $oDesktop = 0 Exit 0 EndFunc ;==>Terminate ; Handler methods. "_MyHandler_" is the specified prefix: Func _MyHandler_QueryInterface($pSelf, $pRIID, $pObj) ConsoleWrite("_MyHandler_QueryInterface called " & $pSelf & " " & _WinAPI_StringFromGUID($pRIID) & " ") Local $tStruct = DllStructCreate("ptr", $pObj) Switch _WinAPI_StringFromGUID($pRIID) Case $sIID_IUnknown ConsoleWrite("IUnknown" & @CRLF) Case $sIID_IUIAutomationFocusChangedEventHandler ConsoleWrite("IUIAutomationFocusChangedEventHandler" & @CRLF) Case Else ConsoleWrite(@CRLF) Return 0x80004002 ; E_NOINTERFACE EndSwitch DllStructSetData($tStruct, 1, $pSelf) Return 0 ; S_OK EndFunc ;==>_MyHandler_QueryInterface Func _MyHandler_AddRef($pSelf) #forceref $pSelf ConsoleWrite("_MyHandler_AddRef called" & @CRLF) Return 0 ; S_OK EndFunc ;==>_MyHandler_AddRef Func _MyHandler_Release($pSelf) #forceref $pSelf ConsoleWrite("_MyHandler_Release called" & @CRLF) Return 0 ; S_OK EndFunc ;==>_MyHandler_Release Func _MyHandler_HandleFocusChangedEvent($pSelf, $pElem) #forceref $pSelf ConsoleWrite("! _MyHandler_HandleFocusChangedEvent called: $pElem = " & $pElem & @CRLF) If $pElem Then Local $oElem = _AutoItObject_WrapperCreate($pElem, $dtagIUIAutomationElement) $oElem.AddRef() Local $aCall = $oElem.CurrentClassName(0) ConsoleWrite(">>> Somebody is changing the focus to: " & $aCall[1] & " with name/caption : " & getPVal($oElem, $UIA_NamePropertyId) & getPVal($oElem, $UIA_ValueValuePropertyId) & @CRLF) EndIf Return 0 ; S_OK EndFunc ;==>_MyHandler_HandleFocusChangedEvent ;~ Just show the classname as a starting sample func sample0() $aCall = $oDesktop.CurrentClassName(0) ConsoleWrite("We did get for classname of the desktop: " & $aCall[1] & @CRLF) $aCall = $oDesktop.CurrentClassName(0) ;~ Just try to show all the property values that could be applicable to this element showAllPropertyValues($oDesktop) EndFunc ;~ Lets try to find 2 applications based on their name (Calc.Exe with title in dutch Rekenmachine) ;~ Unfortunately uiautomation is not supporting regexpressions or wildcards to search func Sample1() $aCall = $objUIAutomation.CreatePropertyCondition($UIA_NamePropertyId, "Program Manager", 0) $oCondition1 = _AutoItObject_WrapperCreate($aCall[3], $dtagIUIAutomationCondition) ;~ $aCall = $objUIAutomation.CreatePropertyCondition($UIA_NamePropertyId, "Rekenmachine", 0) ;~ $oCondition2 = _AutoItObject_WrapperCreate($aCall[3], $dtagIUIAutomationCondition) $aCall = $objUIAutomation.CreatePropertyCondition($UIA_ClassNamePropertyId, "SciCalc", 0) $oCondition2 = _AutoItObject_WrapperCreate($aCall[3], $dtagIUIAutomationCondition) ;~ Combine the 2 to be an or condition $aCall = $objUIAutomation.CreateOrCondition($oCondition1.__ptr__, $oCondition2.__ptr__, 0) $oCondition3 = _AutoItObject_WrapperCreate($aCall[3], $dtagIUIAutomationCondition) ;- Find them based on the or condition $aCall = $oDesktop.FindAll($TreeScope_Children, $oCondition3.__ptr__, 0) $oAutomationElementArray = _AutoItObject_WrapperCreate($aCall[3], $dtagIUIAutomationElementArray) $aCall = $oAutomationElementArray.Length(0) $iLength = $aCall[1] consolewrite("Showing 1 or 2 windows depending if (dutch) calculator is opened " & @CRLF) For $i = 0 To $iLength - 1; it's zero based $aCall = $oAutomationElementArray.GetElement($i, 0) $pElem = $aCall[2] $oElem = _AutoItObject_WrapperCreate($pElem, $dtagIUIAutomationElement) $aCall = $oElem.CurrentClassName(0) ConsoleWrite("Classname of the element No" & $i & ": " & $aCall[1] & @CRLF) Next EndFunc ;~ Do something similar by showing all main windows with all their properties func sample2() consolewrite("Showing all windows " & @CRLF) $aCall = $objUIAutomation.CreateTrueCondition(0) $oCondition1 = _AutoItObject_WrapperCreate($aCall[1], $dtagIUIAutomationCondition) $aCall = $oDesktop.FindAll($TreeScope_Children, $oCondition1.__ptr__, 0) $oAutomationElementArray = _AutoItObject_WrapperCreate($aCall[3], $dtagIUIAutomationElementArray) $aCall = $oAutomationElementArray.Length(0) $iLength = $aCall[1] For $i = 0 To $iLength - 1; it's zero based $pElem=0 $oElem=0 $aCall = $oAutomationElementArray.GetElement($i, 0) $pElem = $aCall[2] $oElem = _AutoItObject_WrapperCreate($pElem, $dtagIUIAutomationElement) $aCall = $oElem.CurrentClassName(0) ConsoleWrite("Classname of the element No " & $i & ": " & $aCall[1] & getPVal($oElem,$UIA_ClassNamePropertyId) & getPVal($oElem,$UIA_NamePropertyId) & @CRLF) showAllPropertyValues($oElem) ;~ consolewrite($tVal) Next EndFunc ;-Automate some wordpad stuff func sample3() $oWordpad=getObjectOfElement($oDesktop, "WordPad",$TreeScope_Children) if isobj($oWordpad) Then consolewrite("And the object name is " & getPVal($oWordpad, $UIA_NamePropertyId)) $aCall=$oWordpad.SetFocus() EndIf $oMenu=getObjectOfElement($oWordPad, "Bestand", $TreeScope_Descendants) if isobj($oMenu) Then consolewrite("And the menu name is " & getPVal($oMenu, $UIA_NamePropertyId) & @CRLF) EndIf $aCall=$oMenu.getCurrentPattern($UIA_InvokePatternId,0) $pMenu=$aCall[2] $oInvokeP=_AutoItObject_WrapperCreate($pMenu, $dtagIUIAutomationInvokePattern) $oInvokeP.invoke() sleep(350) $aCall=$objuiautomation.getFocusedElement(0) $pMenu=$aCall[1] $oMenu=_AutoItObject_WrapperCreate($pMenu, $dtagIUIAutomationElement) $oMenu=getObjectOfElement($oWordPad, "Pagina", $TreeScope_Descendants) if isobj($oMenu) Then consolewrite("And the 2nd menu name is " & getPVal($oMenu, $UIA_NamePropertyId) & @CRLF) EndIf $aCall=$oMenu.getCurrentPattern($UIA_InvokePatternId,0) $pMenu=$aCall[2] $oInvokeP=_AutoItObject_WrapperCreate($pMenu, $dtagIUIAutomationInvokePattern) $oInvokeP.invoke() sleep(200) $aCall=$objuiautomation.getFocusedElement(0) $pObj=$aCall[1] $oFocusObj=_AutoItObject_WrapperCreate($pObj, $dtagIUIAutomationElement) if isobj($oFocusObj) Then consolewrite("And the active window is " & getPVal($oFocusObj, $UIA_NamePropertyId) & @CRLF) EndIf EndFunc ;~ Just return a single property or if its an array string them together func getPVal($obj, $id) $aCall= $obj.GetCurrentPropertyValue($Id,0) $tVal=$aCall[2] $tStr="" if isarray($tVal) Then for $i=0 to ubound($tval)-1 $tStr=$tStr & $tVal[$i] if $i <> ubound($tVal)-1 Then $tStr=$tStr & ";" endif Next ;~ consolewrite($id & " is an array") return $tStr endIf return $tVal EndFunc ;~ Just display all available properties for desktop/should work on all IUIAutomationElements depending on ControlTypePropertyID they work yes/no ;~ http://msdn.microsoft.com/en-us/library/dd319579(v=vs.85).aspx func showAllPropertyValues($oUIElement) ConsoleWrite(" We did get for UIA_AcceleratorKeyPropertyId : " & getPVal($oUIElement, $UIA_AcceleratorKeyPropertyId) & @CRLF);Shortcut key for the element's default action. ConsoleWrite(" We did get for UIA_AccessKeyPropertyId : " & getPVal($oUIElement, $UIA_AccessKeyPropertyId) & @CRLF);Keys used to move focus to a control. ConsoleWrite(" We did get for UIA_AriaPropertiesPropertyId : " & getPVal($oUIElement, $UIA_AriaPropertiesPropertyId) & @CRLF);A collection of Accessible Rich Internet Application (ARIA) properties, each consisting of a name/value pair delimited by ‘-’ and ‘;’ (for example, ("checked=true;disabled=false"). ConsoleWrite(" We did get for UIA_AriaRolePropertyId : " & getPVal($oUIElement, $UIA_AriaRolePropertyId) & @CRLF);ARIA role information. ConsoleWrite(" We did get for UIA_AutomationIdPropertyId : " & getPVal($oUIElement, $UIA_AutomationIdPropertyId) & @CRLF);UI Automation identifier. ConsoleWrite(" We did get for UIA_BoundingRectanglePropertyId : " & getPVal($oUIElement, $UIA_BoundingRectanglePropertyId) & @CRLF);Coordinates of the rectangle that completely encloses the element. ConsoleWrite(" We did get for UIA_ClassNamePropertyId : " & getPVal($oUIElement, $UIA_ClassNamePropertyId) & @CRLF);Class name of the element as assigned by the control developer. ConsoleWrite(" We did get for UIA_ClickablePointPropertyId : " & getPVal($oUIElement, $UIA_ClickablePointPropertyId) & @CRLF);Screen coordinates of any clickable point within the control. ConsoleWrite(" We did get for UIA_ControllerForPropertyId : " & getPVal($oUIElement, $UIA_ControllerForPropertyId) & @CRLF);Array of elements controlled by the automation element that supports this property. ConsoleWrite(" We did get for UIA_ControlTypePropertyId : " & getPVal($oUIElement, $UIA_ControlTypePropertyId) & @CRLF);Control Type of the element. ConsoleWrite(" We did get for UIA_CulturePropertyId : " & getPVal($oUIElement, $UIA_CulturePropertyId) & @CRLF);Locale identifier of the element. ConsoleWrite(" We did get for UIA_DescribedByPropertyId : " & getPVal($oUIElement, $UIA_DescribedByPropertyId) & @CRLF);Array of elements that provide more information about the element. ConsoleWrite(" We did get for UIA_DockDockPositionPropertyId : " & getPVal($oUIElement, $UIA_DockDockPositionPropertyId) & @CRLF);Docking position. ConsoleWrite(" We did get for UIA_ExpandCollapseExpandCollapseStatePropertyId : " & getPVal($oUIElement, $UIA_ExpandCollapseExpandCollapseStatePropertyId) & @CRLF);The expand/collapse state. ConsoleWrite(" We did get for UIA_FlowsToPropertyId : " & getPVal($oUIElement, $UIA_FlowsToPropertyId) & @CRLF);Array of elements that suggest the reading order after the corresponding element. ConsoleWrite(" We did get for UIA_FrameworkIdPropertyId : " & getPVal($oUIElement, $UIA_FrameworkIdPropertyId) & @CRLF);Underlying UI framework that the element is part of. ConsoleWrite(" We did get for UIA_GridColumnCountPropertyId : " & getPVal($oUIElement, $UIA_GridColumnCountPropertyId) & @CRLF);Number of columns. ConsoleWrite(" We did get for UIA_GridItemColumnPropertyId : " & getPVal($oUIElement, $UIA_GridItemColumnPropertyId) & @CRLF);Column the item is in. ConsoleWrite(" We did get for UIA_GridItemColumnSpanPropertyId : " & getPVal($oUIElement, $UIA_GridItemColumnSpanPropertyId) & @CRLF);number of columns that the item spans. ConsoleWrite(" We did get for UIA_GridItemContainingGridPropertyId : " & getPVal($oUIElement, $UIA_GridItemContainingGridPropertyId) & @CRLF);UI Automation provider that implements IGridProvider and represents the container of the cell or item. ConsoleWrite(" We did get for UIA_GridItemRowPropertyId : " & getPVal($oUIElement, $UIA_GridItemRowPropertyId) & @CRLF);Row the item is in. ConsoleWrite(" We did get for UIA_GridItemRowSpanPropertyId : " & getPVal($oUIElement, $UIA_GridItemRowSpanPropertyId) & @CRLF);Number of rows that the item spzns. ConsoleWrite(" We did get for UIA_GridRowCountPropertyId : " & getPVal($oUIElement, $UIA_GridRowCountPropertyId) & @CRLF);Number of rows. ConsoleWrite(" We did get for UIA_HasKeyboardFocusPropertyId : " & getPVal($oUIElement, $UIA_HasKeyboardFocusPropertyId) & @CRLF);Whether the element has the keyboard focus. ConsoleWrite(" We did get for UIA_HelpTextPropertyId : " & getPVal($oUIElement, $UIA_HelpTextPropertyId) & @CRLF);Additional information about how to use the element. ConsoleWrite(" We did get for UIA_IsContentElementPropertyId : " & getPVal($oUIElement, $UIA_IsContentElementPropertyId) & @CRLF);Whether the element appears in the content view of the automation element tree. ConsoleWrite(" We did get for UIA_IsControlElementPropertyId : " & getPVal($oUIElement, $UIA_IsControlElementPropertyId) & @CRLF);Whether the element appears in the control view of the automation element tree. ConsoleWrite(" We did get for UIA_IsDataValidForFormPropertyId : " & getPVal($oUIElement, $UIA_IsDataValidForFormPropertyId) & @CRLF);Whether the data in a form is valid. ConsoleWrite(" We did get for UIA_IsDockPatternAvailablePropertyId : " & getPVal($oUIElement, $UIA_IsDockPatternAvailablePropertyId) & @CRLF);Whether the Dock control pattern is available on the element. ConsoleWrite(" We did get for UIA_IsEnabledPropertyId : " & getPVal($oUIElement, $UIA_IsEnabledPropertyId) & @CRLF);Whether the control is enabled. ConsoleWrite(" We did get for UIA_IsExpandCollapsePatternAvailablePropertyId : " & getPVal($oUIElement, $UIA_IsExpandCollapsePatternAvailablePropertyId) & @CRLF);Whether the ExpandCollapse control pattern is available on the element. ConsoleWrite(" We did get for UIA_IsGridItemPatternAvailablePropertyId : " & getPVal($oUIElement, $UIA_IsGridItemPatternAvailablePropertyId) & @CRLF);Whether the GridItem control pattern is available on the element. ConsoleWrite(" We did get for UIA_IsGridPatternAvailablePropertyId : " & getPVal($oUIElement, $UIA_IsGridPatternAvailablePropertyId) & @CRLF);Whether the Grid control pattern is available on the element. ConsoleWrite(" We did get for UIA_IsInvokePatternAvailablePropertyId : " & getPVal($oUIElement, $UIA_IsInvokePatternAvailablePropertyId) & @CRLF);Whether the Invoke control pattern is available on the element. ConsoleWrite(" We did get for UIA_IsItemContainerPatternAvailablePropertyId : " & getPVal($oUIElement, $UIA_IsItemContainerPatternAvailablePropertyId) & @CRLF);Whether the ItemContainer control pattern is available on the element. ConsoleWrite(" We did get for UIA_IsKeyboardFocusablePropertyId : " & getPVal($oUIElement, $UIA_IsKeyboardFocusablePropertyId) & @CRLF);Whether the element can accept the keyboard focus. ConsoleWrite(" We did get for UIA_IsLegacyIAccessiblePatternAvailablePropertyId : " & getPVal($oUIElement, $UIA_IsLegacyIAccessiblePatternAvailablePropertyId) & @CRLF);Whether the LegacyIAccessible control pattern is available on the control. ConsoleWrite(" We did get for UIA_IsMultipleViewPatternAvailablePropertyId : " & getPVal($oUIElement, $UIA_IsMultipleViewPatternAvailablePropertyId) & @CRLF);Whether the pattern is available on the control. ConsoleWrite(" We did get for UIA_IsOffscreenPropertyId : " & getPVal($oUIElement, $UIA_IsOffscreenPropertyId) & @CRLF);Whether the element is scrolled or collapsed out of view. ConsoleWrite(" We did get for UIA_IsPasswordPropertyId : " & getPVal($oUIElement, $UIA_IsPasswordPropertyId) & @CRLF);Whether the element contains protected content or a password. ConsoleWrite(" We did get for UIA_IsRangeValuePatternAvailablePropertyId : " & getPVal($oUIElement, $UIA_IsRangeValuePatternAvailablePropertyId) & @CRLF);Whether the RangeValue pattern is available on the control. ConsoleWrite(" We did get for UIA_IsRequiredForFormPropertyId : " & getPVal($oUIElement, $UIA_IsRequiredForFormPropertyId) & @CRLF);Whether the element is a required field on a form. ConsoleWrite(" We did get for UIA_IsScrollItemPatternAvailablePropertyId : " & getPVal($oUIElement, $UIA_IsScrollItemPatternAvailablePropertyId) & @CRLF);Whether the ScrollItem control pattern is available on the element. ConsoleWrite(" We did get for UIA_IsScrollPatternAvailablePropertyId : " & getPVal($oUIElement, $UIA_IsScrollPatternAvailablePropertyId) & @CRLF);Whether the Scroll control pattern is available on the element. ConsoleWrite(" We did get for UIA_IsSelectionItemPatternAvailablePropertyId : " & getPVal($oUIElement, $UIA_IsSelectionItemPatternAvailablePropertyId) & @CRLF);Whether the SelectionItem control pattern is available on the element. ConsoleWrite(" We did get for UIA_IsSelectionPatternAvailablePropertyId : " & getPVal($oUIElement, $UIA_IsSelectionPatternAvailablePropertyId) & @CRLF);Whether the pattern is available on the element. ConsoleWrite(" We did get for UIA_IsSynchronizedInputPatternAvailablePropertyId : " & getPVal($oUIElement, $UIA_IsSynchronizedInputPatternAvailablePropertyId) & @CRLF);Whether the SynchronizedInput control pattern is available on the element. ConsoleWrite(" We did get for UIA_IsTableItemPatternAvailablePropertyId : " & getPVal($oUIElement, $UIA_IsTableItemPatternAvailablePropertyId) & @CRLF);Whether the TableItem control pattern is available on the element. ConsoleWrite(" We did get for UIA_IsTablePatternAvailablePropertyId : " & getPVal($oUIElement, $UIA_IsTablePatternAvailablePropertyId) & @CRLF);Whether the Table conntrol pattern is available on the element. ConsoleWrite(" We did get for UIA_IsTextPatternAvailablePropertyId : " & getPVal($oUIElement, $UIA_IsTextPatternAvailablePropertyId) & @CRLF);Whether the Text control pattern is available on the element. ConsoleWrite(" We did get for UIA_IsTogglePatternAvailablePropertyId : " & getPVal($oUIElement, $UIA_IsTogglePatternAvailablePropertyId) & @CRLF);Whether the Toggle control pattern is available on the element. ConsoleWrite(" We did get for UIA_IsTransformPatternAvailablePropertyId : " & getPVal($oUIElement, $UIA_IsTransformPatternAvailablePropertyId) & @CRLF);Whether the Transform control pattern is available on the element. ConsoleWrite(" We did get for UIA_IsValuePatternAvailablePropertyId : " & getPVal($oUIElement, $UIA_IsValuePatternAvailablePropertyId) & @CRLF);Whether the Value control pattern is available on the element. ConsoleWrite(" We did get for UIA_IsVirtualizedItemPatternAvailablePropertyId : " & getPVal($oUIElement, $UIA_IsVirtualizedItemPatternAvailablePropertyId) & @CRLF);Whether the VirtualizedItem control pattern is available on the element. ConsoleWrite(" We did get for UIA_IsWindowPatternAvailablePropertyId : " & getPVal($oUIElement, $UIA_IsWindowPatternAvailablePropertyId) & @CRLF);Whether the Window control pattern is available on the element. ConsoleWrite(" We did get for UIA_ItemStatusPropertyId : " & getPVal($oUIElement, $UIA_ItemStatusPropertyId) & @CRLF);Control-specific status. ConsoleWrite(" We did get for UIA_ItemTypePropertyId : " & getPVal($oUIElement, $UIA_ItemTypePropertyId) & @CRLF);Description of the item type, such as "Document File" or "Folder". ConsoleWrite(" We did get for UIA_LabeledByPropertyId : " & getPVal($oUIElement, $UIA_LabeledByPropertyId) & @CRLF);Element that contains the text label for this element. ConsoleWrite(" We did get for UIA_LegacyIAccessibleChildIdPropertyId : " & getPVal($oUIElement, $UIA_LegacyIAccessibleChildIdPropertyId) & @CRLF);MSAA child ID of the element. ConsoleWrite(" We did get for UIA_LegacyIAccessibleDefaultActionPropertyId : " & getPVal($oUIElement, $UIA_LegacyIAccessibleDefaultActionPropertyId) & @CRLF);MSAA default action. ConsoleWrite(" We did get for UIA_LegacyIAccessibleDescriptionPropertyId : " & getPVal($oUIElement, $UIA_LegacyIAccessibleDescriptionPropertyId) & @CRLF);MSAA description. ConsoleWrite(" We did get for UIA_LegacyIAccessibleHelpPropertyId : " & getPVal($oUIElement, $UIA_LegacyIAccessibleHelpPropertyId) & @CRLF);MSAA help string. ConsoleWrite(" We did get for UIA_LegacyIAccessibleKeyboardShortcutPropertyId : " & getPVal($oUIElement, $UIA_LegacyIAccessibleKeyboardShortcutPropertyId) & @CRLF);MSAA shortcut key. ConsoleWrite(" We did get for UIA_LegacyIAccessibleNamePropertyId : " & getPVal($oUIElement, $UIA_LegacyIAccessibleNamePropertyId) & @CRLF);MSAA name. ConsoleWrite(" We did get for UIA_LegacyIAccessibleRolePropertyId : " & getPVal($oUIElement, $UIA_LegacyIAccessibleRolePropertyId) & @CRLF);MSAA role. ConsoleWrite(" We did get for UIA_LegacyIAccessibleSelectionPropertyId : " & getPVal($oUIElement, $UIA_LegacyIAccessibleSelectionPropertyId) & @CRLF);MSAA selection. ConsoleWrite(" We did get for UIA_LegacyIAccessibleStatePropertyId : " & getPVal($oUIElement, $UIA_LegacyIAccessibleStatePropertyId) & @CRLF);MSAA state. ConsoleWrite(" We did get for UIA_LegacyIAccessibleValuePropertyId : " & getPVal($oUIElement, $UIA_LegacyIAccessibleValuePropertyId) & @CRLF);MSAA value. ConsoleWrite(" We did get for UIA_LocalizedControlTypePropertyId : " & getPVal($oUIElement, $UIA_LocalizedControlTypePropertyId) & @CRLF);Localized string describing the control type of element. ConsoleWrite(" We did get for UIA_MultipleViewCurrentViewPropertyId : " & getPVal($oUIElement, $UIA_MultipleViewCurrentViewPropertyId) & @CRLF);Current view state of the control. ConsoleWrite(" We did get for UIA_MultipleViewSupportedViewsPropertyId : " & getPVal($oUIElement, $UIA_MultipleViewSupportedViewsPropertyId) & @CRLF);Supported control-specific views. ConsoleWrite(" We did get for UIA_NamePropertyId : " & getPVal($oUIElement, $UIA_NamePropertyId) & @CRLF);Name of the control. ConsoleWrite(" We did get for UIA_NativeWindowHandlePropertyId : " & getPVal($oUIElement, $UIA_NativeWindowHandlePropertyId) & @CRLF);Underlying HWND of the element, if one exists. ConsoleWrite(" We did get for UIA_OrientationPropertyId : " & getPVal($oUIElement, $UIA_OrientationPropertyId) & @CRLF);Orientation of the element. ConsoleWrite(" We did get for UIA_ProcessIdPropertyId : " & getPVal($oUIElement, $UIA_ProcessIdPropertyId) & @CRLF);Identifier of the process that the element resides in. ConsoleWrite(" We did get for UIA_ProviderDescriptionPropertyId : " & getPVal($oUIElement, $UIA_ProviderDescriptionPropertyId) & @CRLF);Description of the UI Automation provider. ConsoleWrite(" We did get for UIA_RangeValueIsReadOnlyPropertyId : " & getPVal($oUIElement, $UIA_RangeValueIsReadOnlyPropertyId) & @CRLF);Whether the value is read-only. ConsoleWrite(" We did get for UIA_RangeValueLargeChangePropertyId : " & getPVal($oUIElement, $UIA_RangeValueLargeChangePropertyId) & @CRLF);Amount by which the value is adjusted by input such as PgDn. ConsoleWrite(" We did get for UIA_RangeValueMaximumPropertyId : " & getPVal($oUIElement, $UIA_RangeValueMaximumPropertyId) & @CRLF);Maximum value in the range. ConsoleWrite(" We did get for UIA_RangeValueMinimumPropertyId : " & getPVal($oUIElement, $UIA_RangeValueMinimumPropertyId) & @CRLF);Minimum value in the range. ConsoleWrite(" We did get for UIA_RangeValueSmallChangePropertyId : " & getPVal($oUIElement, $UIA_RangeValueSmallChangePropertyId) & @CRLF);Amount by which the value is adjusted by input such as an arrow key. ConsoleWrite(" We did get for UIA_RangeValueValuePropertyId : " & getPVal($oUIElement, $UIA_RangeValueValuePropertyId) & @CRLF);Current value. ConsoleWrite(" We did get for UIA_RuntimeIdPropertyId : " & getPVal($oUIElement, $UIA_RuntimeIdPropertyId) & @CRLF);Run time identifier of the element. ConsoleWrite(" We did get for UIA_ScrollHorizontallyScrollablePropertyId : " & getPVal($oUIElement, $UIA_ScrollHorizontallyScrollablePropertyId) & @CRLF);Whether the control can be scrolled horizontally. ConsoleWrite(" We did get for UIA_ScrollHorizontalScrollPercentPropertyId : " & getPVal($oUIElement, $UIA_ScrollHorizontalScrollPercentPropertyId) & @CRLF);How far the element is currently scrolled. ConsoleWrite(" We did get for UIA_ScrollHorizontalViewSizePropertyId : " & getPVal($oUIElement, $UIA_ScrollHorizontalViewSizePropertyId) & @CRLF);The viewable width of the control. ConsoleWrite(" We did get for UIA_ScrollVerticallyScrollablePropertyId : " & getPVal($oUIElement, $UIA_ScrollVerticallyScrollablePropertyId) & @CRLF);Whether the control can be scrolled vertically. ConsoleWrite(" We did get for UIA_ScrollVerticalScrollPercentPropertyId : " & getPVal($oUIElement, $UIA_ScrollVerticalScrollPercentPropertyId) & @CRLF);How far the element is currently scrolled. ConsoleWrite(" We did get for UIA_ScrollVerticalViewSizePropertyId : " & getPVal($oUIElement, $UIA_ScrollVerticalViewSizePropertyId) & @CRLF);The viewable height of the control. ConsoleWrite(" We did get for UIA_SelectionCanSelectMultiplePropertyId : " & getPVal($oUIElement, $UIA_SelectionCanSelectMultiplePropertyId) & @CRLF);Whether multiple items can be in the selection. ConsoleWrite(" We did get for UIA_SelectionIsSelectionRequiredPropertyId : " & getPVal($oUIElement, $UIA_SelectionIsSelectionRequiredPropertyId) & @CRLF);Whether at least one item must be in the selection at all times. ConsoleWrite(" We did get for UIA_SelectionSelectionPropertyId : " & getPVal($oUIElement, $UIA_SelectionSelectionPropertyId) & @CRLF);The items in the selection. ConsoleWrite(" We did get for UIA_SelectionItemIsSelectedPropertyId : " & getPVal($oUIElement, $UIA_SelectionItemIsSelectedPropertyId) & @CRLF);Whether the item can be selected. ConsoleWrite(" We did get for UIA_SelectionItemSelectionContainerPropertyId : " & getPVal($oUIElement, $UIA_SelectionItemSelectionContainerPropertyId) & @CRLF);The control that contains the item. ConsoleWrite(" We did get for UIA_TableColumnHeadersPropertyId : " & getPVal($oUIElement, $UIA_TableColumnHeadersPropertyId) & @CRLF);Collection of column header providers. ConsoleWrite(" We did get for UIA_TableItemColumnHeaderItemsPropertyId : " & getPVal($oUIElement, $UIA_TableItemColumnHeaderItemsPropertyId) & @CRLF);Column headers. ConsoleWrite(" We did get for UIA_TableRowHeadersPropertyId : " & getPVal($oUIElement, $UIA_TableRowHeadersPropertyId) & @CRLF);Collection of row header providers. ConsoleWrite(" We did get for UIA_TableRowOrColumnMajorPropertyId : " & getPVal($oUIElement, $UIA_TableRowOrColumnMajorPropertyId) & @CRLF);Whether the table is primarily organized by row or column. ConsoleWrite(" We did get for UIA_TableItemRowHeaderItemsPropertyId : " & getPVal($oUIElement, $UIA_TableItemRowHeaderItemsPropertyId) & @CRLF);Row headers. ConsoleWrite(" We did get for UIA_ToggleToggleStatePropertyId : " & getPVal($oUIElement, $UIA_ToggleToggleStatePropertyId) & @CRLF);The toggle state of the control. ConsoleWrite(" We did get for UIA_TransformCanMovePropertyId : " & getPVal($oUIElement, $UIA_TransformCanMovePropertyId) & @CRLF);Whether the element can be moved. ConsoleWrite(" We did get for UIA_TransformCanResizePropertyId : " & getPVal($oUIElement, $UIA_TransformCanResizePropertyId) & @CRLF);Whether the element can be resized. ConsoleWrite(" We did get for UIA_TransformCanRotatePropertyId : " & getPVal($oUIElement, $UIA_TransformCanRotatePropertyId) & @CRLF);Whether the element can be rotated. ConsoleWrite(" We did get for UIA_ValueIsReadOnlyPropertyId : " & getPVal($oUIElement, $UIA_ValueIsReadOnlyPropertyId) & @CRLF);Whether the value is read-only. ConsoleWrite(" We did get for UIA_ValueValuePropertyId : " & getPVal($oUIElement, $UIA_ValueValuePropertyId) & @CRLF);Current value. ConsoleWrite(" We did get for UIA_WindowCanMaximizePropertyId : " & getPVal($oUIElement, $UIA_WindowCanMaximizePropertyId) & @CRLF);Whether the window can be maximized. ConsoleWrite(" We did get for UIA_WindowCanMinimizePropertyId : " & getPVal($oUIElement, $UIA_WindowCanMinimizePropertyId) & @CRLF);Whether the window can be minimized. ConsoleWrite(" We did get for UIA_WindowIsModalPropertyId : " & getPVal($oUIElement, $UIA_WindowIsModalPropertyId) & @CRLF);Whether the window is modal. ConsoleWrite(" We did get for UIA_WindowIsTopmostPropertyId : " & getPVal($oUIElement, $UIA_WindowIsTopmostPropertyId) & @CRLF);Whether the window is on top of other windows. ConsoleWrite(" We did get for UIA_WindowWindowInteractionStatePropertyId : " & getPVal($oUIElement, $UIA_WindowWindowInteractionStatePropertyId) & @CRLF);Whether the window can receive input. ConsoleWrite(" We did get for UIA_WindowWindowVisualStatePropertyId : " & getPVal($oUIElement, $UIA_WindowWindowVisualStatePropertyId) & @CRLF);Whether the window is maximized, minimized, or restored (normal). endFunc func playMenu($strMenuChoice) $arrItem=stringsplit($strMenuChoice,"|") for $i=1 to ubound($arrItem)-1 consolewrite($arrItem[$i]) Next EndFunc ;~ Small helper function to get an object out of a treeSearch func getObjectOfElement($obj,$str,$treeScope) ;~ Get result with findall function alternative could be the treewalker $aCall = $objUIAutomation.CreateTrueCondition(0) $oCondition1 = _AutoItObject_WrapperCreate($aCall[1], $dtagIUIAutomationCondition) ;~ Tricky to search all descendants on html objects or from desktop/root element $aCall = $obj.FindAll($TreeScope, $oCondition1.__ptr__, 0) $oAutomationElementArray = _AutoItObject_WrapperCreate($aCall[3], $dtagIUIAutomationElementArray) $aCall = $oAutomationElementArray.Length(0) $iLength = $aCall[1] For $i = 0 To $iLength - 1; it's zero based $pElem=0 $oElem=0 $aCall = $oAutomationElementArray.GetElement($i, 0) $pElem = $aCall[2] $oElem = _AutoItObject_WrapperCreate($pElem, $dtagIUIAutomationElement) $aCall = getPVal($oElem, $UIA_NamePropertyId) ;~ consolewrite($iLength & "Searching " & $aCall & $str & stringinstr($aCall,$str) & @CRLF) if stringinstr($aCall,$str)>0 Then return $oElem endif Next EndFunc FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
junkew Posted May 29, 2011 Author Share Posted May 29, 2011 Small part of code for treeWalker (to include in previous code) func sampleTW() ;~ ' Lets show all the items of the desktop with a treewalker $aCall=$objUIAutomation.ControlViewWalker(0) $pTW=$aCall[1] $oTW=_AutoItObject_WrapperCreate($pTW, $dtagIUIAutomationTreeWalker) $aCall = $oTW.GetFirstChildElement($oDesktop.__ptr__, 0) $pElem = $aCall[2] $oElem = _AutoItObject_WrapperCreate($pElem, $dtagIUIAutomationElement) While isobj($oElem)=true consolewrite("Value is: " & getPVal($oElem,$UIA_NamePropertyId) & getPVal($oElem,$uia_classnamepropertyid) & @CRLF) $aCall = $oTW.GetNextSiblingElement($oElem.__ptr__,0) $pElem = $aCall[2] $oElem = _AutoItObject_WrapperCreate($pElem, $dtagIUIAutomationElement) Wend EndFunc FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
junkew Posted May 29, 2011 Author Share Posted May 29, 2011 All stuff combined in a treeview 1. Getting the automation object 2. Getting the desktop and a treewalker 3. Getting all available properties for an object and showing them in editbox 4. Add first level to the treeview and traversing the treewalker Not yet done with recursion for child objects expandcollapse popup#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <GuiConstantsEx.au3> #include <EditConstants.au3> #include <StaticConstants.au3> #include <GuiTreeView.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> #include <AutoItObject.au3> #include "CUIAutomation.au3" Opt('MustDeclareVars', 1) ;~ Assume to have loaded the DLL first Global Const $hUIAutomation = DllOpen("uiautomationcore.dll") Global $objUIAutomation ;For creating the uiautomation instance Global $oDesktop ;Desktop will be frequently the starting point Global $aCall ;For handling the return values Global $pTW ; Pointer to the treewalker Global $oTW ; The object treewalker Global $pElem ; a pointer to a user element Global $oElem ; a ui element object Global $AllData[1000] ; Caching all property data of the ui elements, not realy nice but hard to find the actual element back (should be done with runtime id and automation condition) _AutoItObject_StartUp() ;Starting the autoit object library Global $oError = ObjEvent("AutoIt.Error", "_ErrFunc") Func _ErrFunc() ConsoleWrite("COM Error, ScriptLine(" & $oError.scriptline & ") : Number 0x" & Hex($oError.number, 8) & " - " & $oError.windescription & @CRLF) EndFunc ;==>_ErrFunc _UIAutomationInit() $Debug_TV = False ; Check ClassName being passed to functions, set to True and use a handle to another control to see it work Global $hTreeView Global $myedit _Main() Func _Main() local $iParam local $hRootItem Local $GUI, $hItem Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES) $GUI = GUICreate("(UDF Created) TreeView Create", 1024, 768) $hTreeView = _GUICtrlTreeView_Create($GUI, 2, 2, 396, 768, $iStyle, $WS_EX_CLIENTEDGE) $myedit = GUICtrlCreateEdit("" & @CRLF, 400, 2, 400, 768, $ES_AUTOVSCROLL + $WS_VSCROLL) GUISetState() GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") _GUICtrlTreeView_BeginUpdate($hTreeView) $hRootItem =_GUICtrlTreeView_Add($hTreeView, 0, """" & getPVal($oDesktop,$UIA_NamePropertyId) & """" & " (" & getPVal($oDesktop,$uia_classnamepropertyid) & ")" ) ;Add the desktop $iParam=1 _GUICtrlTreeView_SetItemParam($hTreeView, $hRootItem, $iParam) $alldata[$iParam]=getallpropertyvalues($oDesktop) ;~ ' Lets show all the items of the desktop with a treewalker $aCall=$objUIAutomation.ControlViewWalker(0) $pTW=$aCall[1] $oTW=_AutoItObject_WrapperCreate($pTW, $dtagIUIAutomationTreeWalker) $aCall = $oTW.GetFirstChildElement($oDesktop.__ptr__, 0) $pElem = $aCall[2] $oElem = _AutoItObject_WrapperCreate($pElem, $dtagIUIAutomationElement) While isobj($oElem)=true $hItem=_GUICtrlTreeView_AddChild($hTreeView, $hRootItem, """" & getPVal($oElem,$UIA_NamePropertyId) & """" & " (" & getPVal($oElem,$uia_classnamepropertyid) & ")" ) $iParam += 1 $alldata[$iParam]=getallpropertyvalues($oElem) _GUICtrlTreeView_SetItemParam($hTreeView, $hItem, $iParam) ;~ consolewrite("Value is: " & getPVal($oElem,$UIA_NamePropertyId) & getPVal($oElem,$uia_classnamepropertyid) & @CRLF) $aCall = $oTW.GetNextSiblingElement($oElem.__ptr__,0) $pElem = $aCall[2] $oElem = _AutoItObject_WrapperCreate($pElem, $dtagIUIAutomationElement) Wend _GUICtrlTreeView_EndUpdate($hTreeView) ; Loop until user exits Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>_Main Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $iwParam Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndTreeview $hWndTreeview = $hTreeView If Not IsHWnd($hTreeView) Then $hWndTreeview = GUICtrlGetHandle($hTreeView) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndTreeview Switch $iCode Case $NM_CLICK ; The user has clicked the left mouse button within the control _DebugPrint("$NM_CLICK" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _ "-->IDFrom:" & @TAB & $iIDFrom & @LF & _ "-->Code:" & @TAB & $iCode) ;~ Return 1 ; nonzero to not allow the default processing Return 0 ; zero to allow the default processing Case $NM_DBLCLK ; The user has double-clicked the left mouse button within the control _DebugPrint("$NM_DBLCLK" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _ "-->IDFrom:" & @TAB & $iIDFrom & @LF & _ "-->Code:" & @TAB & $iCode) ;~ Return 1 ; nonzero to not allow the default processing Return 0 ; zero to allow the default processing Case $NM_RCLICK ; The user has clicked the right mouse button within the control _DebugPrint("$NM_RCLICK" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _ "-->IDFrom:" & @TAB & $iIDFrom & @LF & _ "-->Code:" & @TAB & $iCode) ;~ Return 1 ; nonzero to not allow the default processing Return 0 ; zero to allow the default processing Case $NM_RDBLCLK ; The user has clicked the right mouse button within the control _DebugPrint("$NM_RDBLCLK" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _ "-->IDFrom:" & @TAB & $iIDFrom & @LF & _ "-->Code:" & @TAB & $iCode) ;~ Return 1 ; nonzero to not allow the default processing Return 0 ; zero to allow the default processing Case $NM_KILLFOCUS ; control has lost the input focus _DebugPrint("$NM_KILLFOCUS" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _ "-->IDFrom:" & @TAB & $iIDFrom & @LF & _ "-->Code:" & @TAB & $iCode) ; No return value Case $NM_RETURN ; control has the input focus and that the user has pressed the key _DebugPrint("$NM_RETURN" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _ "-->IDFrom:" & @TAB & $iIDFrom & @LF & _ "-->Code:" & @TAB & $iCode) ;~ Return 1 ; nonzero to not allow the default processing Return 0 ; zero to allow the default processing ;~ Case $NM_SETCURSOR ; control is setting the cursor in response to a WM_SETCURSOR message ;~ Local $tinfo = DllStructCreate($tagNMMOUSE, $ilParam) ;~ $hWndFrom = HWnd(DllStructGetData($tinfo, "hWndFrom")) ;~ $iIDFrom = DllStructGetData($tinfo, "IDFrom") ;~ $iCode = DllStructGetData($tinfo, "Code") ;~ _DebugPrint("$NM_SETCURSOR" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _ ;~ "-->IDFrom:" & @TAB & $iIDFrom & @LF & _ ;~ "-->Code:" & @TAB & $iCode & @LF & _ ;~ "-->ItemSpec:" & @TAB & DllStructGetData($tinfo, "ItemSpec") & @LF & _ ;~ "-->ItemData:" & @TAB & DllStructGetData($tinfo, "ItemData") & @LF & _ ;~ "-->X:" & @TAB & DllStructGetData($tinfo, "X") & @LF & _ ;~ "-->Y:" & @TAB & DllStructGetData($tinfo, "Y") & @LF & _ ;~ "-->HitInfo:" & @TAB & DllStructGetData($tinfo, "HitInfo")) ;~ Return 0 ; to enable the control to set the cursor ;~ Return 1 ; nonzero to prevent the control from setting the cursor Case $NM_SETFOCUS ; control has received the input focus _DebugPrint("$NM_SETFOCUS" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _ "-->IDFrom:" & @TAB & $iIDFrom & @LF & _ "-->Code:" & @TAB & $iCode) ; No return value Case $TVN_BEGINDRAGA, $TVN_BEGINDRAGW _DebugPrint("$TVN_BEGINDRAG") Case $TVN_BEGINLABELEDITA, $TVN_BEGINLABELEDITW _DebugPrint("$TVN_BEGINLABELEDIT") Case $TVN_BEGINRDRAGA, $TVN_BEGINRDRAGW _DebugPrint("$TVN_BEGINRDRAG") Case $TVN_DELETEITEMA, $TVN_DELETEITEMW _DebugPrint("$TVN_DELETEITEM") Case $TVN_ENDLABELEDITA, $TVN_ENDLABELEDITW _DebugPrint("$TVN_ENDLABELEDIT") Case $TVN_GETDISPINFOA, $TVN_GETDISPINFOW _DebugPrint("$TVN_GETDISPINFO") Case $TVN_GETINFOTIPA, $TVN_GETINFOTIPW _DebugPrint("$TVN_GETINFOTIP") Case $TVN_ITEMEXPANDEDA, $TVN_ITEMEXPANDEDW _DebugPrint("$TVN_ITEMEXPANDED") Case $TVN_ITEMEXPANDINGA, $TVN_ITEMEXPANDINGW _DebugPrint("$TVN_ITEMEXPANDING") Case $TVN_KEYDOWN _DebugPrint("$TVN_KEYDOWN") Case $TVN_SELCHANGEDA, $TVN_SELCHANGEDW ;~ _DebugPrint("$TVN_SELCHANGED") ;~ Display the property values as cached upfront ;~ ConsoleWrite("-->Selection Text: " & _GUICtrlTreeView_GetText($hWndTreeview, _GUICtrlTreeView_GetSelection($hWndTreeview))) GUICtrlSetData($myedit, $AllData[_GUICtrlTreeView_GetItemParam($hTreeView, _GUICtrlTreeView_GetSelection($hWndTreeview))]) Case $TVN_SELCHANGINGA, $TVN_SELCHANGINGW _DebugPrint("$TVN_SELCHANGING") Case $TVN_SETDISPINFOA, $TVN_SETDISPINFOW _DebugPrint("$TVN_SETDISPINFO") Case $TVN_SINGLEEXPAND _DebugPrint("$TVN_SINGLEEXPAND") EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func _DebugPrint($s_text, $line = @ScriptLineNumber) ConsoleWrite( _ "!===========================================================" & @LF & _ "+======================================================" & @LF & _ "-->Line(" & StringFormat("%04d", $line) & "):" & @TAB & $s_text & @LF & _ "+======================================================" & @LF) EndFunc ;==>_DebugPrint func _UIAutomationInit() ;~ The main object with acces to the windows automation api 3.0 $objUIAutomation = _AutoItObject_ObjCreate($sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation) If IsObj($objUIAutomation) Then ConsoleWrite("At least it seems we have the core object to start with" & @CRLF) EndIf ;~ Try to get the desktop as a generic reference/global for all samples $aCall = $objUIAutomation.GetRootElement(0) $oDesktop = _AutoItObject_WrapperCreate($aCall[1], $dtagIUIAutomationElement) If IsObj($oDesktop) Then ConsoleWrite("At least it seems I have the desktop as a frequently used starting point" & @CRLF) EndIf EndFunc ;~ Just return a single property or if its an array string them together func getPVal($obj, $id) local $tval local $tStr local $aCall $aCall= $obj.GetCurrentPropertyValue($Id,0) $tVal=$aCall[2] $tStr="" if isarray($tVal) Then for $i=0 to ubound($tval)-1 $tStr=$tStr & $tVal[$i] if $i <> ubound($tVal)-1 Then $tStr=$tStr & ";" endif Next ;~ consolewrite($id & " is an array") return $tStr endIf return $tVal EndFunc ; ~ Just get all available properties for desktop/should work on all IUIAutomationElements depending on ControlTypePropertyID they work yes/no ; ~ Just make it a very long string name:= value pairs func getAllPropertyValues($oUIElement) local $tStr, $tSeparator $tStr="" $tSeparator = @crLF ; To make sure its not a value you normally will get back for values $tStr=$tStr & "UIA_AcceleratorKeyPropertyId :=" & getPVal($oUIElement, $UIA_AcceleratorKeyPropertyId) & $tSeparator ; Shortcut key for the element's default action. $tStr=$tStr & "UIA_AccessKeyPropertyId :=" & getPVal($oUIElement, $UIA_AccessKeyPropertyId) & $tSeparator ; Keys used to move focus to a control. $tStr=$tStr & "UIA_AriaPropertiesPropertyId :=" & getPVal($oUIElement, $UIA_AriaPropertiesPropertyId) & $tSeparator ; A collection of Accessible Rich Internet Application (ARIA) properties, each consisting of a name/value pair delimited by ‘-’ and ‘ ; ’ (for example, ("checked=true ; disabled=false"). $tStr=$tStr & "UIA_AriaRolePropertyId :=" & getPVal($oUIElement, $UIA_AriaRolePropertyId) & $tSeparator ; ARIA role information. $tStr=$tStr & "UIA_AutomationIdPropertyId :=" & getPVal($oUIElement, $UIA_AutomationIdPropertyId) & $tSeparator ; UI Automation identifier. $tStr=$tStr & "UIA_BoundingRectanglePropertyId :=" & getPVal($oUIElement, $UIA_BoundingRectanglePropertyId) & $tSeparator ; Coordinates of the rectangle that completely encloses the element. $tStr=$tStr & "UIA_ClassNamePropertyId :=" & getPVal($oUIElement, $UIA_ClassNamePropertyId) & $tSeparator ; Class name of the element as assigned by the control developer. $tStr=$tStr & "UIA_ClickablePointPropertyId :=" & getPVal($oUIElement, $UIA_ClickablePointPropertyId) & $tSeparator ; Screen coordinates of any clickable point within the control. $tStr=$tStr & "UIA_ControllerForPropertyId :=" & getPVal($oUIElement, $UIA_ControllerForPropertyId) & $tSeparator ; Array of elements controlled by the automation element that supports this property. $tStr=$tStr & "UIA_ControlTypePropertyId :=" & getPVal($oUIElement, $UIA_ControlTypePropertyId) & $tSeparator ; Control Type of the element. $tStr=$tStr & "UIA_CulturePropertyId :=" & getPVal($oUIElement, $UIA_CulturePropertyId) & $tSeparator ; Locale identifier of the element. $tStr=$tStr & "UIA_DescribedByPropertyId :=" & getPVal($oUIElement, $UIA_DescribedByPropertyId) & $tSeparator ; Array of elements that provide more information about the element. $tStr=$tStr & "UIA_DockDockPositionPropertyId :=" & getPVal($oUIElement, $UIA_DockDockPositionPropertyId) & $tSeparator ; Docking position. $tStr=$tStr & "UIA_ExpandCollapseExpandCollapseStatePropertyId :=" & getPVal($oUIElement, $UIA_ExpandCollapseExpandCollapseStatePropertyId) & $tSeparator ; The expand/collapse state. $tStr=$tStr & "UIA_FlowsToPropertyId :=" & getPVal($oUIElement, $UIA_FlowsToPropertyId) & $tSeparator ; Array of elements that suggest the reading order after the corresponding element. $tStr=$tStr & "UIA_FrameworkIdPropertyId :=" & getPVal($oUIElement, $UIA_FrameworkIdPropertyId) & $tSeparator ; Underlying UI framework that the element is part of. $tStr=$tStr & "UIA_GridColumnCountPropertyId :=" & getPVal($oUIElement, $UIA_GridColumnCountPropertyId) & $tSeparator ; Number of columns. $tStr=$tStr & "UIA_GridItemColumnPropertyId :=" & getPVal($oUIElement, $UIA_GridItemColumnPropertyId) & $tSeparator ; Column the item is in. $tStr=$tStr & "UIA_GridItemColumnSpanPropertyId :=" & getPVal($oUIElement, $UIA_GridItemColumnSpanPropertyId) & $tSeparator ; number of columns that the item spans. $tStr=$tStr & "UIA_GridItemContainingGridPropertyId :=" & getPVal($oUIElement, $UIA_GridItemContainingGridPropertyId) & $tSeparator ; UI Automation provider that implements IGridProvider and represents the container of the cell or item. $tStr=$tStr & "UIA_GridItemRowPropertyId :=" & getPVal($oUIElement, $UIA_GridItemRowPropertyId) & $tSeparator ; Row the item is in. $tStr=$tStr & "UIA_GridItemRowSpanPropertyId :=" & getPVal($oUIElement, $UIA_GridItemRowSpanPropertyId) & $tSeparator ; Number of rows that the item spzns. $tStr=$tStr & "UIA_GridRowCountPropertyId :=" & getPVal($oUIElement, $UIA_GridRowCountPropertyId) & $tSeparator ; Number of rows. $tStr=$tStr & "UIA_HasKeyboardFocusPropertyId :=" & getPVal($oUIElement, $UIA_HasKeyboardFocusPropertyId) & $tSeparator ; Whether the element has the keyboard focus. $tStr=$tStr & "UIA_HelpTextPropertyId :=" & getPVal($oUIElement, $UIA_HelpTextPropertyId) & $tSeparator ; Additional information about how to use the element. $tStr=$tStr & "UIA_IsContentElementPropertyId :=" & getPVal($oUIElement, $UIA_IsContentElementPropertyId) & $tSeparator ; Whether the element appears in the content view of the automation element tree. $tStr=$tStr & "UIA_IsControlElementPropertyId :=" & getPVal($oUIElement, $UIA_IsControlElementPropertyId) & $tSeparator ; Whether the element appears in the control view of the automation element tree. $tStr=$tStr & "UIA_IsDataValidForFormPropertyId :=" & getPVal($oUIElement, $UIA_IsDataValidForFormPropertyId) & $tSeparator ; Whether the data in a form is valid. $tStr=$tStr & "UIA_IsDockPatternAvailablePropertyId :=" & getPVal($oUIElement, $UIA_IsDockPatternAvailablePropertyId) & $tSeparator ; Whether the Dock control pattern is available on the element. $tStr=$tStr & "UIA_IsEnabledPropertyId :=" & getPVal($oUIElement, $UIA_IsEnabledPropertyId) & $tSeparator ; Whether the control is enabled. $tStr=$tStr & "UIA_IsExpandCollapsePatternAvailablePropertyId :=" & getPVal($oUIElement, $UIA_IsExpandCollapsePatternAvailablePropertyId) & $tSeparator ; Whether the ExpandCollapse control pattern is available on the element. $tStr=$tStr & "UIA_IsGridItemPatternAvailablePropertyId :=" & getPVal($oUIElement, $UIA_IsGridItemPatternAvailablePropertyId) & $tSeparator ; Whether the GridItem control pattern is available on the element. $tStr=$tStr & "UIA_IsGridPatternAvailablePropertyId :=" & getPVal($oUIElement, $UIA_IsGridPatternAvailablePropertyId) & $tSeparator ; Whether the Grid control pattern is available on the element. $tStr=$tStr & "UIA_IsInvokePatternAvailablePropertyId :=" & getPVal($oUIElement, $UIA_IsInvokePatternAvailablePropertyId) & $tSeparator ; Whether the Invoke control pattern is available on the element. $tStr=$tStr & "UIA_IsItemContainerPatternAvailablePropertyId :=" & getPVal($oUIElement, $UIA_IsItemContainerPatternAvailablePropertyId) & $tSeparator ; Whether the ItemContainer control pattern is available on the element. $tStr=$tStr & "UIA_IsKeyboardFocusablePropertyId :=" & getPVal($oUIElement, $UIA_IsKeyboardFocusablePropertyId) & $tSeparator ; Whether the element can accept the keyboard focus. $tStr=$tStr & "UIA_IsLegacyIAccessiblePatternAvailablePropertyId :=" & getPVal($oUIElement, $UIA_IsLegacyIAccessiblePatternAvailablePropertyId) & $tSeparator ; Whether the LegacyIAccessible control pattern is available on the control. $tStr=$tStr & "UIA_IsMultipleViewPatternAvailablePropertyId :=" & getPVal($oUIElement, $UIA_IsMultipleViewPatternAvailablePropertyId) & $tSeparator ; Whether the pattern is available on the control. $tStr=$tStr & "UIA_IsOffscreenPropertyId :=" & getPVal($oUIElement, $UIA_IsOffscreenPropertyId) & $tSeparator ; Whether the element is scrolled or collapsed out of view. $tStr=$tStr & "UIA_IsPasswordPropertyId :=" & getPVal($oUIElement, $UIA_IsPasswordPropertyId) & $tSeparator ; Whether the element contains protected content or a password. $tStr=$tStr & "UIA_IsRangeValuePatternAvailablePropertyId :=" & getPVal($oUIElement, $UIA_IsRangeValuePatternAvailablePropertyId) & $tSeparator ; Whether the RangeValue pattern is available on the control. $tStr=$tStr & "UIA_IsRequiredForFormPropertyId :=" & getPVal($oUIElement, $UIA_IsRequiredForFormPropertyId) & $tSeparator ; Whether the element is a required field on a form. $tStr=$tStr & "UIA_IsScrollItemPatternAvailablePropertyId :=" & getPVal($oUIElement, $UIA_IsScrollItemPatternAvailablePropertyId) & $tSeparator ; Whether the ScrollItem control pattern is available on the element. $tStr=$tStr & "UIA_IsScrollPatternAvailablePropertyId :=" & getPVal($oUIElement, $UIA_IsScrollPatternAvailablePropertyId) & $tSeparator ; Whether the Scroll control pattern is available on the element. $tStr=$tStr & "UIA_IsSelectionItemPatternAvailablePropertyId :=" & getPVal($oUIElement, $UIA_IsSelectionItemPatternAvailablePropertyId) & $tSeparator ; Whether the SelectionItem control pattern is available on the element. $tStr=$tStr & "UIA_IsSelectionPatternAvailablePropertyId :=" & getPVal($oUIElement, $UIA_IsSelectionPatternAvailablePropertyId) & $tSeparator ; Whether the pattern is available on the element. $tStr=$tStr & "UIA_IsSynchronizedInputPatternAvailablePropertyId :=" & getPVal($oUIElement, $UIA_IsSynchronizedInputPatternAvailablePropertyId) & $tSeparator ; Whether the SynchronizedInput control pattern is available on the element. $tStr=$tStr & "UIA_IsTableItemPatternAvailablePropertyId :=" & getPVal($oUIElement, $UIA_IsTableItemPatternAvailablePropertyId) & $tSeparator ; Whether the TableItem control pattern is available on the element. $tStr=$tStr & "UIA_IsTablePatternAvailablePropertyId :=" & getPVal($oUIElement, $UIA_IsTablePatternAvailablePropertyId) & $tSeparator ; Whether the Table conntrol pattern is available on the element. $tStr=$tStr & "UIA_IsTextPatternAvailablePropertyId :=" & getPVal($oUIElement, $UIA_IsTextPatternAvailablePropertyId) & $tSeparator ; Whether the Text control pattern is available on the element. $tStr=$tStr & "UIA_IsTogglePatternAvailablePropertyId :=" & getPVal($oUIElement, $UIA_IsTogglePatternAvailablePropertyId) & $tSeparator ; Whether the Toggle control pattern is available on the element. $tStr=$tStr & "UIA_IsTransformPatternAvailablePropertyId :=" & getPVal($oUIElement, $UIA_IsTransformPatternAvailablePropertyId) & $tSeparator ; Whether the Transform control pattern is available on the element. $tStr=$tStr & "UIA_IsValuePatternAvailablePropertyId :=" & getPVal($oUIElement, $UIA_IsValuePatternAvailablePropertyId) & $tSeparator ; Whether the Value control pattern is available on the element. $tStr=$tStr & "UIA_IsVirtualizedItemPatternAvailablePropertyId :=" & getPVal($oUIElement, $UIA_IsVirtualizedItemPatternAvailablePropertyId) & $tSeparator ; Whether the VirtualizedItem control pattern is available on the element. $tStr=$tStr & "UIA_IsWindowPatternAvailablePropertyId :=" & getPVal($oUIElement, $UIA_IsWindowPatternAvailablePropertyId) & $tSeparator ; Whether the Window control pattern is available on the element. $tStr=$tStr & "UIA_ItemStatusPropertyId :=" & getPVal($oUIElement, $UIA_ItemStatusPropertyId) & $tSeparator ; Control-specific status. $tStr=$tStr & "UIA_ItemTypePropertyId :=" & getPVal($oUIElement, $UIA_ItemTypePropertyId) & $tSeparator ; Description of the item type, such as "Document File" or "Folder". $tStr=$tStr & "UIA_LabeledByPropertyId :=" & getPVal($oUIElement, $UIA_LabeledByPropertyId) & $tSeparator ; Element that contains the text label for this element. $tStr=$tStr & "UIA_LegacyIAccessibleChildIdPropertyId :=" & getPVal($oUIElement, $UIA_LegacyIAccessibleChildIdPropertyId) & $tSeparator ; MSAA child ID of the element. $tStr=$tStr & "UIA_LegacyIAccessibleDefaultActionPropertyId :=" & getPVal($oUIElement, $UIA_LegacyIAccessibleDefaultActionPropertyId) & $tSeparator ; MSAA default action. $tStr=$tStr & "UIA_LegacyIAccessibleDescriptionPropertyId :=" & getPVal($oUIElement, $UIA_LegacyIAccessibleDescriptionPropertyId) & $tSeparator ; MSAA description. $tStr=$tStr & "UIA_LegacyIAccessibleHelpPropertyId :=" & getPVal($oUIElement, $UIA_LegacyIAccessibleHelpPropertyId) & $tSeparator ; MSAA help string. $tStr=$tStr & "UIA_LegacyIAccessibleKeyboardShortcutPropertyId :=" & getPVal($oUIElement, $UIA_LegacyIAccessibleKeyboardShortcutPropertyId) & $tSeparator ; MSAA shortcut key. $tStr=$tStr & "UIA_LegacyIAccessibleNamePropertyId :=" & getPVal($oUIElement, $UIA_LegacyIAccessibleNamePropertyId) & $tSeparator ; MSAA name. $tStr=$tStr & "UIA_LegacyIAccessibleRolePropertyId :=" & getPVal($oUIElement, $UIA_LegacyIAccessibleRolePropertyId) & $tSeparator ; MSAA role. $tStr=$tStr & "UIA_LegacyIAccessibleSelectionPropertyId :=" & getPVal($oUIElement, $UIA_LegacyIAccessibleSelectionPropertyId) & $tSeparator ; MSAA selection. $tStr=$tStr & "UIA_LegacyIAccessibleStatePropertyId :=" & getPVal($oUIElement, $UIA_LegacyIAccessibleStatePropertyId) & $tSeparator ; MSAA state. $tStr=$tStr & "UIA_LegacyIAccessibleValuePropertyId :=" & getPVal($oUIElement, $UIA_LegacyIAccessibleValuePropertyId) & $tSeparator ; MSAA value. $tStr=$tStr & "UIA_LocalizedControlTypePropertyId :=" & getPVal($oUIElement, $UIA_LocalizedControlTypePropertyId) & $tSeparator ; Localized string describing the control type of element. $tStr=$tStr & "UIA_MultipleViewCurrentViewPropertyId :=" & getPVal($oUIElement, $UIA_MultipleViewCurrentViewPropertyId) & $tSeparator ; Current view state of the control. $tStr=$tStr & "UIA_MultipleViewSupportedViewsPropertyId :=" & getPVal($oUIElement, $UIA_MultipleViewSupportedViewsPropertyId) & $tSeparator ; Supported control-specific views. $tStr=$tStr & "UIA_NamePropertyId :=" & getPVal($oUIElement, $UIA_NamePropertyId) & $tSeparator ; Name of the control. $tStr=$tStr & "UIA_NativeWindowHandlePropertyId :=" & getPVal($oUIElement, $UIA_NativeWindowHandlePropertyId) & $tSeparator ; Underlying HWND of the element, if one exists. $tStr=$tStr & "UIA_OrientationPropertyId :=" & getPVal($oUIElement, $UIA_OrientationPropertyId) & $tSeparator ; Orientation of the element. $tStr=$tStr & "UIA_ProcessIdPropertyId :=" & getPVal($oUIElement, $UIA_ProcessIdPropertyId) & $tSeparator ; Identifier of the process that the element resides in. $tStr=$tStr & "UIA_ProviderDescriptionPropertyId :=" & getPVal($oUIElement, $UIA_ProviderDescriptionPropertyId) & $tSeparator ; Description of the UI Automation provider. $tStr=$tStr & "UIA_RangeValueIsReadOnlyPropertyId :=" & getPVal($oUIElement, $UIA_RangeValueIsReadOnlyPropertyId) & $tSeparator ; Whether the value is read-only. $tStr=$tStr & "UIA_RangeValueLargeChangePropertyId :=" & getPVal($oUIElement, $UIA_RangeValueLargeChangePropertyId) & $tSeparator ; Amount by which the value is adjusted by input such as PgDn. $tStr=$tStr & "UIA_RangeValueMaximumPropertyId :=" & getPVal($oUIElement, $UIA_RangeValueMaximumPropertyId) & $tSeparator ; Maximum value in the range. $tStr=$tStr & "UIA_RangeValueMinimumPropertyId :=" & getPVal($oUIElement, $UIA_RangeValueMinimumPropertyId) & $tSeparator ; Minimum value in the range. $tStr=$tStr & "UIA_RangeValueSmallChangePropertyId :=" & getPVal($oUIElement, $UIA_RangeValueSmallChangePropertyId) & $tSeparator ; Amount by which the value is adjusted by input such as an arrow key. $tStr=$tStr & "UIA_RangeValueValuePropertyId :=" & getPVal($oUIElement, $UIA_RangeValueValuePropertyId) & $tSeparator ; Current value. $tStr=$tStr & "UIA_RuntimeIdPropertyId :=" & getPVal($oUIElement, $UIA_RuntimeIdPropertyId) & $tSeparator ; Run time identifier of the element. $tStr=$tStr & "UIA_ScrollHorizontallyScrollablePropertyId :=" & getPVal($oUIElement, $UIA_ScrollHorizontallyScrollablePropertyId) & $tSeparator ; Whether the control can be scrolled horizontally. $tStr=$tStr & "UIA_ScrollHorizontalScrollPercentPropertyId :=" & getPVal($oUIElement, $UIA_ScrollHorizontalScrollPercentPropertyId) & $tSeparator ; How far the element is currently scrolled. $tStr=$tStr & "UIA_ScrollHorizontalViewSizePropertyId :=" & getPVal($oUIElement, $UIA_ScrollHorizontalViewSizePropertyId) & $tSeparator ; The viewable width of the control. $tStr=$tStr & "UIA_ScrollVerticallyScrollablePropertyId :=" & getPVal($oUIElement, $UIA_ScrollVerticallyScrollablePropertyId) & $tSeparator ; Whether the control can be scrolled vertically. $tStr=$tStr & "UIA_ScrollVerticalScrollPercentPropertyId :=" & getPVal($oUIElement, $UIA_ScrollVerticalScrollPercentPropertyId) & $tSeparator ; How far the element is currently scrolled. $tStr=$tStr & "UIA_ScrollVerticalViewSizePropertyId :=" & getPVal($oUIElement, $UIA_ScrollVerticalViewSizePropertyId) & $tSeparator ; The viewable height of the control. $tStr=$tStr & "UIA_SelectionCanSelectMultiplePropertyId :=" & getPVal($oUIElement, $UIA_SelectionCanSelectMultiplePropertyId) & $tSeparator ; Whether multiple items can be in the selection. $tStr=$tStr & "UIA_SelectionIsSelectionRequiredPropertyId :=" & getPVal($oUIElement, $UIA_SelectionIsSelectionRequiredPropertyId) & $tSeparator ; Whether at least one item must be in the selection at all times. $tStr=$tStr & "UIA_SelectionSelectionPropertyId :=" & getPVal($oUIElement, $UIA_SelectionSelectionPropertyId) & $tSeparator ; The items in the selection. $tStr=$tStr & "UIA_SelectionItemIsSelectedPropertyId :=" & getPVal($oUIElement, $UIA_SelectionItemIsSelectedPropertyId) & $tSeparator ; Whether the item can be selected. $tStr=$tStr & "UIA_SelectionItemSelectionContainerPropertyId :=" & getPVal($oUIElement, $UIA_SelectionItemSelectionContainerPropertyId) & $tSeparator ; The control that contains the item. $tStr=$tStr & "UIA_TableColumnHeadersPropertyId :=" & getPVal($oUIElement, $UIA_TableColumnHeadersPropertyId) & $tSeparator ; Collection of column header providers. $tStr=$tStr & "UIA_TableItemColumnHeaderItemsPropertyId :=" & getPVal($oUIElement, $UIA_TableItemColumnHeaderItemsPropertyId) & $tSeparator ; Column headers. $tStr=$tStr & "UIA_TableRowHeadersPropertyId :=" & getPVal($oUIElement, $UIA_TableRowHeadersPropertyId) & $tSeparator ; Collection of row header providers. $tStr=$tStr & "UIA_TableRowOrColumnMajorPropertyId :=" & getPVal($oUIElement, $UIA_TableRowOrColumnMajorPropertyId) & $tSeparator ; Whether the table is primarily organized by row or column. $tStr=$tStr & "UIA_TableItemRowHeaderItemsPropertyId :=" & getPVal($oUIElement, $UIA_TableItemRowHeaderItemsPropertyId) & $tSeparator ; Row headers. $tStr=$tStr & "UIA_ToggleToggleStatePropertyId :=" & getPVal($oUIElement, $UIA_ToggleToggleStatePropertyId) & $tSeparator ; The toggle state of the control. $tStr=$tStr & "UIA_TransformCanMovePropertyId :=" & getPVal($oUIElement, $UIA_TransformCanMovePropertyId) & $tSeparator ; Whether the element can be moved. $tStr=$tStr & "UIA_TransformCanResizePropertyId :=" & getPVal($oUIElement, $UIA_TransformCanResizePropertyId) & $tSeparator ; Whether the element can be resized. $tStr=$tStr & "UIA_TransformCanRotatePropertyId :=" & getPVal($oUIElement, $UIA_TransformCanRotatePropertyId) & $tSeparator ; Whether the element can be rotated. $tStr=$tStr & "UIA_ValueIsReadOnlyPropertyId :=" & getPVal($oUIElement, $UIA_ValueIsReadOnlyPropertyId) & $tSeparator ; Whether the value is read-only. $tStr=$tStr & "UIA_ValueValuePropertyId :=" & getPVal($oUIElement, $UIA_ValueValuePropertyId) & $tSeparator ; Current value. $tStr=$tStr & "UIA_WindowCanMaximizePropertyId :=" & getPVal($oUIElement, $UIA_WindowCanMaximizePropertyId) & $tSeparator ; Whether the window can be maximized. $tStr=$tStr & "UIA_WindowCanMinimizePropertyId :=" & getPVal($oUIElement, $UIA_WindowCanMinimizePropertyId) & $tSeparator ; Whether the window can be minimized. $tStr=$tStr & "UIA_WindowIsModalPropertyId :=" & getPVal($oUIElement, $UIA_WindowIsModalPropertyId) & $tSeparator ; Whether the window is modal. $tStr=$tStr & "UIA_WindowIsTopmostPropertyId :=" & getPVal($oUIElement, $UIA_WindowIsTopmostPropertyId) & $tSeparator ; Whether the window is on top of other windows. $tStr=$tStr & "UIA_WindowWindowInteractionStatePropertyId :=" & getPVal($oUIElement, $UIA_WindowWindowInteractionStatePropertyId) & $tSeparator ; Whether the window can receive input. $tStr=$tStr & "UIA_WindowWindowVisualStatePropertyId :=" & getPVal($oUIElement, $UIA_WindowWindowVisualStatePropertyId) & $tSeparator ; Whether the window is maximized, minimized, or restored (normal). return $tStr endFunc FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
Ascend4nt Posted May 30, 2011 Share Posted May 30, 2011 (edited) Very nice, junkew. Tell ya what, I might as well give you a look at a pretty messy version of the "IAccessible Tests" UDF I was working on, so you can see what the 'UIA_LegacyIAccessible' interface reveals. The code is a mess, with the exception of a few UDF functions, so it's probably best to look at the output in Notepad (may take a while for it to popup, but let it run and it will go through everything it finds). I intend to get back to the project soon, since I've realized that UI Automation isn't necessarily available on everyone's PC - though I still believe UI Automation is the future. Actually - about that.. is it just UI Automation version 3 that's not installed on XP SP3+? What about version 2 or 1 for that matter? Hmm.. need to look into that. Anyway, here's the old IAccessible interface in its current form. If you can read through the horrendous amounts of output, you'll see that it lists most every control and action. There's a difference in output for different O/S's (XP vs. Windows 7 for example). Oh, guess I should mention the usual - if anyone uses or reproduces the code in any form, credit the original author(s) and keep the headers intact in the source. [iAccessibleAIOTests.au3] Edited May 30, 2011 by Ascend4nt My contributions: Performance Counters in Windows - Measure CPU, Disk, Network etc Performance | Network Interface Info, Statistics, and Traffic | CPU Multi-Processor Usage w/o Performance Counters | Disk and Device Read/Write Statistics | Atom Table Functions | Process, Thread, & DLL Functions UDFs | Process CPU Usage Trackers | PE File Overlay Extraction | A3X Script Extract | File + Process Imports/Exports Information | Windows Desktop Dimmer Shade | Spotlight + Focus GUI - Highlight and Dim for Eyestrain Relief | CrossHairs (FullScreen) | Rubber-Band Boxes using GUI's (_GUIBox) | GUI Fun! | IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) | Magnifier (Vista+) Functions UDF | _DLLStructDisplay (Debug!) | _EnumChildWindows (controls etc) | _FileFindEx | _ClipGetHTML | _ClipPutHTML + ClipPutHyperlink | _FileGetShortcutEx | _FilePropertiesDialog | I/O Port Functions | File(s) Drag & Drop | _RunWithReducedPrivileges | _ShellExecuteWithReducedPrivileges | _WinAPI_GetSystemInfo | dotNETGetVersions | Drive(s) Power Status | _WinGetDesktopHandle | _StringParseParameters | Screensaver, Sleep, Desktop Lock Disable | Full-Screen Crash Recovery Wrappers/Modifications of others' contributions: _DOSWildcardsToPCRegEx (original code: RobSaunder's) | WinGetAltTabWinList (original: Authenticity) UDF's added support/programming to: _ExplorerWinGetSelectedItems | MIDIEx UDF (original code: eynstyne) (All personal code/wrappers centrally located at Ascend4nt's AutoIT Code) Link to comment Share on other sites More sharing options...
junkew Posted May 30, 2011 Author Share Posted May 30, 2011 (edited) Any tips on keeping the syntax with AutoItObject a little more readable in core code? I could make another AutoIt Class wrapping all methods/properties to move it to the library but is that the way to go I now do this (but not real happy with an approach like this) ;~ ' Lets show all the items of the desktop with a treewalker $oTW=__Wrapme($objUIAutomation,"ControlViewWalker") $oElem=__WrapMe($oTW,"GetFirstChildElement",$odesktop.__ptr__) and just a dummy stupid function to keep main code a little more readable func __WrapMe($o, $tStrCall, $v1=0) local $aRet local $pT local $oT switch $tStrCall case "ControlViewWalker" $aRet=$o.ControlViewWalker(0) $pT=$aRet[1] $oT=_AutoItObject_WrapperCreate($pT, $dtagIUIAutomationTreeWalker) return $oT case "GetFirstChildElement" $aRet=$o.GetFirstChildElement($v1, 0) $pT=$aRet[2] $oT=_AutoItObject_WrapperCreate($pT, $dtagIUIAutomationElement) return $oT case "GetNextSiblingElement" $aRet=$o.GetNextSiblingElement($v1, 0) $pT=$aRet[2] $oT=_AutoItObject_WrapperCreate($pT, $dtagIUIAutomationElement) return $oT endswitch EndFunc Edited May 30, 2011 by junkew FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
junkew Posted May 30, 2011 Author Share Posted May 30, 2011 This works (and looks in main code most clean to use) but will probably have a lot of overhead. Any opinions on this approach? consolewrite($objUIAutomation.getrootelement.CurrentClassName & @CRLF) But then I have to generate stuff this way and wrapping all methods/properties of CUIAutomation interfaces expandcollapse popup_UIAutomationStart() func _UIAutomationStart() ;~ The main object with acces to the windows automation api 3.0 $objUIAutomation = _CUIAutomation() If IsObj($objUIAutomation) Then ConsoleWrite("At least it seems we have the core object to start with" & @CRLF) EndIf ;~ Try to get the desktop as a generic reference/global for all samples $oDesktop=$objUIAutomation.getrootelement If IsObj($oDesktop) Then ConsoleWrite("At least it seems I have the desktop as a frequently used starting point" & @CRLF) consolewrite($objUIAutomation.getrootelement.CurrentClassName & @CRLF) EndIf EndFunc Func _CUIAutomation() Local $oObj = _AutoItObject_Create() _AutoItObject_AddProperty($oObj, "__default__") _AutoItObject_AddMethod($oObj, "GetRootElement","_CUIAutomation_GetRootElement") $oObj.__default__ =_AutoItObject_ObjCreate($sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation) Return $oObj EndFunc ;==>CUIAutomation func _CUIAutomation_GetRootElement($self) local $aRet local $oObj $aRet = $self.__default__.GetRootElement(0) $oObj=_IUIAutomationElement() $oObj.__default__ =_AutoItObject_WrapperCreate($aRet[1], $dtagIUIAutomationElement) return $oObj EndFunc func _IUIAutomationElement() Local $oObj = _AutoItObject_Create() _AutoItObject_AddProperty($oObj, "__default__") _AutoItObject_AddMethod($oObj, "CurrentClassName","_IUIAutomationElement_CurrentClassName") Return $oObj EndFunc ;==>AutomationElement func _IUIAutomationElement_CurrentClassName($self) local $aRet $aRet = $self.__default__.CurrentClassName(0) return $aRet[1] endfunc FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
junkew Posted January 6, 2013 Author Share Posted January 6, 2013 see also FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
pineapple1175 Posted May 3, 2013 Share Posted May 3, 2013 (edited) Hi Junkew, I learned a lot from your post, by this, I want to ask, "CUIAutomation.au3" you attached on 17-05-2011, if this is the final version, any changes after 17-05-2011, would you please kindly attach again? I would like to use your library to operate office ribbon controls, as you know, the "CommandBar" object cannot get controls in ribbon toolbar, so I think the CUIAutomation COM object will help me do this. Thanks~~ Edited May 3, 2013 by pineapple1175 Link to comment Share on other sites More sharing options...
junkew Posted May 5, 2013 Author Share Posted May 5, 2013 Its the latest version. Only intention I have is to rewrite to objcreateinterface see reference FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets 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