junkew Posted December 27, 2012 Share Posted December 27, 2012 (edited) [edit 06 jan 2013] Actually its more about ObjCreateInterface and interfaces icm with structIf I have in C++ the definitionElementFromPoint hresult([in] tagPOINT ;[out] IUIAutomationElement **)How would this translate to ObjCreateInterface syntax?"ElementFromPoint hresult(struct;ptr*);"and in code using it without getting the pointer$objUIAutomation.ElementFromPoint($tStruct,$pUIElement) ;~ $objUIAutomation.ElementFromPoint(DllStructGetPtr($tStruct),$pUIElement)trying to get this work based onBased on the answers trancexx gave the main issue resolvedfull working example1. copy / paste and save script2. run script3. hover with the mouse and where you are interested in an object just press ctrl+m4. escape to exitexpandcollapse popup#include <WinAPI.au3> HotKeySet("{ESC}", "Close") ; Set ESC as a hotkey to exit the script. HotKeySet("^m", "GetElementInfo") ; Set Hotkey Ctrl+M ;~ http://www.autoitscript.com/forum/topic/128406-interface-autoitobject-iuiautomation/ ;~ http://msdn.microsoft.com/en-us/library/windows/desktop/ff625914(v=vs.85).aspx Global $oDesktop, $pDesktop ;Desktop will be frequently the starting point Global $oUIElement, $pUIElement ;Used frequently to get an element Global Const $sCLSID_CUIAutomation="{FF48DBA4-60EF-4201-AA87-54103EEF594E}" Global Const $sIID_IUIAutomation="{30CBE57D-D9D0-452A-AB13-7AC5AC4825EE}" Global $dtagIUIAutomation = "CompareElements hresult(ptr;ptr;long*);" & _ ;CompareElements hresult([in] IUIAutomationElement *;[in] IUIAutomationElement *;[out] int ) "CompareRuntimeIds hresult(ptr;ptr;long*);" & _ ;CompareRuntimeIds hresult([in] ne ;[in] ne ;[out] int ) "GetRootElement hresult(ptr*);" & _ ;GetRootElement hresult([out] IUIAutomationElement **) "ElementFromHandle hresult(none;ptr*);" & _ ;ElementFromHandle hresult([in] void ;[out] IUIAutomationElement **) "ElementFromPoint hresult(struct;ptr*);" & _ ;ElementFromPoint hresult([in] tagPOINT ;[out] IUIAutomationElement **) "GetFocusedElement hresult(ptr*);" & _ ;GetFocusedElement hresult([out] IUIAutomationElement **) "GetRootElementBuildCache hresult(ptr;ptr*);" & _ ;GetRootElementBuildCache hresult([in] IUIAutomationCacheRequest *;[out] IUIAutomationElement **) "ElementFromHandleBuildCache hresult(none;ptr;ptr*);" & _ ;ElementFromHandleBuildCache hresult([in] void ;[in] IUIAutomationCacheRequest *;[out] IUIAutomationElement **) "ElementFromPointBuildCache hresult(none;ptr;ptr*);" & _ ;ElementFromPointBuildCache hresult([in] tagPOINT ;[in] IUIAutomationCacheRequest *;[out] IUIAutomationElement **) "GetFocusedElementBuildCache hresult(ptr;ptr*);" & _ ;GetFocusedElementBuildCache hresult([in] IUIAutomationCacheRequest *;[out] IUIAutomationElement **) "CreateTreeWalker hresult(ptr;ptr*);" & _ ;CreateTreeWalker hresult([in] IUIAutomationCondition *;[out] IUIAutomationTreeWalker **) "ControlViewWalker hresult(ptr*);" & _ ;ControlViewWalker hresult([out] IUIAutomationTreeWalker **) "ContentViewWalker hresult(ptr*);" & _ ;ContentViewWalker hresult([out] IUIAutomationTreeWalker **) "RawViewWalker hresult(ptr*);" & _ ;RawViewWalker hresult([out] IUIAutomationTreeWalker **) "RawViewCondition hresult(ptr*);" & _ ;RawViewCondition hresult([out] IUIAutomationCondition **) "ControlViewCondition hresult(ptr*);" & _ ;ControlViewCondition hresult([out] IUIAutomationCondition **) "ContentViewCondition hresult(ptr*);" & _ ;ContentViewCondition hresult([out] IUIAutomationCondition **) "CreateCacheRequest hresult(ptr*);" & _ ;CreateCacheRequest hresult([out] IUIAutomationCacheRequest **) "CreateTrueCondition hresult(ptr*);" & _ ;CreateTrueCondition hresult([out] IUIAutomationCondition **) "CreateFalseCondition hresult(ptr*);" & _ ;CreateFalseCondition hresult([out] IUIAutomationCondition **) "CreatePropertyCondition hresult(int;variant;ptr*);" & _ ;CreatePropertyCondition hresult([in] int ;[in] variant ;[out] IUIAutomationCondition **) "CreatePropertyConditionEx hresult(int;variant;long;ptr*);" & _ ;CreatePropertyConditionEx hresult([in] int ;[in] variant ;[in] PropertyConditionFlags ;[out] IUIAutomationCondition **) "CreateAndCondition hresult(ptr;ptr;ptr*);" & _ ;CreateAndCondition hresult([in] IUIAutomationCondition *;[in] IUIAutomationCondition *;[out] IUIAutomationCondition **) "CreateAndConditionFromArray hresult(ptr;ptr*);" & _ ;CreateAndConditionFromArray hresult([in] IUIAutomationCondition ;[out] IUIAutomationCondition **) "CreateAndConditionFromNativeArray hresult(ptr;int;ptr*);" & _ ;CreateAndConditionFromNativeArray hresult([in] IUIAutomationCondition **;[in] int ;[out] IUIAutomationCondition **) "CreateOrCondition hresult(ptr;ptr;ptr*);" & _ ;CreateOrCondition hresult([in] IUIAutomationCondition *;[in] IUIAutomationCondition *;[out] IUIAutomationCondition **) "CreateOrConditionFromArray hresult(ptr;ptr*);" & _ ;CreateOrConditionFromArray hresult([in] IUIAutomationCondition ;[out] IUIAutomationCondition **) "CreateOrConditionFromNativeArray hresult(ptr;int;ptr*);" & _ ;CreateOrConditionFromNativeArray hresult([in] IUIAutomationCondition **;[in] int ;[out] IUIAutomationCondition **) "CreateNotCondition hresult(ptr;ptr*);" & _ ;CreateNotCondition hresult([in] IUIAutomationCondition *;[out] IUIAutomationCondition **) "AddAutomationEventHandler hresult(int;ptr;long;ptr;ptr);" & _ ;AddAutomationEventHandler hresult([in] int ;[in] IUIAutomationElement *;[in] TreeScope ;[in] IUIAutomationCacheRequest *;[in] IUIAutomationEventHandler *) "RemoveAutomationEventHandler hresult(int;ptr;ptr);" & _ ;RemoveAutomationEventHandler hresult([in] int ;[in] IUIAutomationElement *;[in] IUIAutomationEventHandler *) "AddPropertyChangedEventHandlerNativeArray hresult(ptr;long;ptr;ptr;int;int);" & _ ;AddPropertyChangedEventHandlerNativeArray hresult([in] IUIAutomationElement *;[in] TreeScope ;[in] IUIAutomationCacheRequest *;[in] IUIAutomationpropertychangedEventHandler *;[in] int ;[in] int ) "AddPropertyChangedEventHandler hresult(ptr;long;ptr;ptr;ptr);" & _ ;AddPropertyChangedEventHandler hresult([in] IUIAutomationElement *;[in] TreeScope ;[in] IUIAutomationCacheRequest *;[in] IUIAutomationpropertychangedEventHandler *;[in] ne ) "RemovePropertyChangedEventHandler hresult(ptr;ptr);" & _ ;RemovePropertyChangedEventHandler hresult([in] IUIAutomationElement *;[in] IUIAutomationpropertychangedEventHandler *) "AddStructureChangedEventHandler hresult(ptr;long;ptr;ptr);" & _ ;AddStructureChangedEventHandler hresult([in] IUIAutomationElement *;[in] TreeScope ;[in] IUIAutomationCacheRequest *;[in] IUIAutomationStructureChangedEventHandler *) "RemoveStructureChangedEventHandler hresult(ptr;ptr);" & _ ;RemoveStructureChangedEventHandler hresult([in] IUIAutomationElement *;[in] IUIAutomationStructureChangedEventHandler *) "AddFocusChangedEventHandler hresult(ptr;ptr);" & _ ;AddFocusChangedEventHandler hresult([in] IUIAutomationCacheRequest *;[in] IUIAutomationfocusChangedEventHandler *) "RemoveFocusChangedEventHandler hresult(ptr);" & _ ;RemoveFocusChangedEventHandler hresult([in] IUIAutomationfocusChangedEventHandler *) "RemoveAllEventHandlers hresult();" & _ ;RemoveAllEventHandlers hresult() "IntNativeArrayToSafeArray hresult(int;int;ptr*);" & _ ;IntNativeArrayToSafeArray hresult([in] int ;[in] int ;[out] ne ) "IntSafeArrayToNativeArray hresult(ptr;int*;int*);" & _ ;IntSafeArrayToNativeArray hresult([in] ne ;[out] int ;[out] int ) "RectToVariant hresult(none;variant*);" & _ ;RectToVariant hresult([in] tagRECT ;[out] variant ) "VariantToRect hresult(variant;none*);" & _ ;VariantToRect hresult([in] variant ;[out] tagRECT *) "SafeArrayToRectNativeArray hresult(ptr;none*;int*);" & _ ;SafeArrayToRectNativeArray hresult([in] ne ;[out] tagRECT **;[out] int ) "CreateProxyFactoryEntry hresult(ptr;ptr*);" & _ ;CreateProxyFactoryEntry hresult([in] IUIAutomationProxyFactory *;[out] IUIAutomationProxyFactoryEntry **) "ProxyFactoryMapping hresult(ptr*);" & _ ;ProxyFactoryMapping hresult([out] IUIAutomationProxyFactoryMapping **) "GetPropertyProgrammaticName hresult(int;bstr*);" & _ ;GetPropertyProgrammaticName hresult([in] int ;[out] bstr ) "GetPatternProgrammaticName hresult(int;bstr*);" & _ ;GetPatternProgrammaticName hresult([in] int ;[out] bstr ) "PollForPotentialSupportedPatterns hresult(ptr;ptr*;ptr*);" & _ ;PollForPotentialSupportedPatterns hresult([in] IUIAutomationElement *;[out] ne ;[out] ne ) "PollForPotentialSupportedProperties hresult(ptr;ptr*;ptr*);" & _ ;PollForPotentialSupportedProperties hresult([in] IUIAutomationElement *;[out] ne ;[out] ne ) "CheckNotSupported hresult(variant;long*);" & _ ;CheckNotSupported hresult([in] variant ;[out] int ) "ReservedNotSupportedValue hresult(ptr*);" & _ ;ReservedNotSupportedValue hresult([out] iunknown ) "ReservedMixedAttributeValue hresult(ptr*);" & _ ;ReservedMixedAttributeValue hresult([out] iunknown ) "ElementFromIAccessible hresult(none;int;ptr*);" & _ ;ElementFromIAccessible hresult([in] IAccessible *;[in] int ;[out] IUIAutomationElement **) "ElementFromIAccessibleBuildCache hresult(none;int;ptr;ptr*);" ;ElementFromIAccessibleBuildCache hresult([in] IAccessible *;[in] int ;[in] IUIAutomationCacheRequest *;[out] IUIAutomationElement **) ;=============================================================================== Global Const $sIID_IUIAutomationElement="{D22108AA-8AC5-49A5-837B-37BBB3D7591E}" Global $dtagIUIAutomationElement = "SetFocus hresult();" & _ ;SetFocus hresult() "GetRuntimeId hresult(ptr*);" & _ ;GetRuntimeId hresult([out] ne ) "FindFirst hresult(long;ptr;ptr*);" & _ ;FindFirst hresult([in] TreeScope ;[in] IUIAutomationCondition *;[out] IUIAutomationElement **) "FindAll hresult(long;ptr;ptr*);" & _ ;FindAll hresult([in] TreeScope ;[in] IUIAutomationCondition *;[out] IUIAutomationElementArray **) "FindFirstBuildCache hresult(long;ptr;ptr;ptr*);" & _ ;FindFirstBuildCache hresult([in] TreeScope ;[in] IUIAutomationCondition *;[in] IUIAutomationCacheRequest *;[out] IUIAutomationElement **) "FindAllBuildCache hresult(long;ptr;ptr;ptr*);" & _ ;FindAllBuildCache hresult([in] TreeScope ;[in] IUIAutomationCondition *;[in] IUIAutomationCacheRequest *;[out] IUIAutomationElementArray **) "BuildUpdatedCache hresult(ptr;ptr*);" & _ ;BuildUpdatedCache hresult([in] IUIAutomationCacheRequest *;[out] IUIAutomationElement **) "GetCurrentPropertyValue hresult(int;variant*);" & _ ;GetCurrentPropertyValue hresult([in] int ;[out] variant ) "GetCurrentPropertyValueEx hresult(int;long;variant*);" & _ ;GetCurrentPropertyValueEx hresult([in] int ;[in] int ;[out] variant ) "GetCachedPropertyValue hresult(int;variant*);" & _ ;GetCachedPropertyValue hresult([in] int ;[out] variant ) "GetCachedPropertyValueEx hresult(int;long;variant*);" & _ ;GetCachedPropertyValueEx hresult([in] int ;[in] int ;[out] variant ) "GetCurrentPatternAs hresult(int;none;none*);" & _ ;GetCurrentPatternAs hresult([in] int ;[in] GUID *;[out] void ) "GetCachedPatternAs hresult(int;none;none*);" & _ ;GetCachedPatternAs hresult([in] int ;[in] GUID *;[out] void ) "GetCurrentPattern hresult(int;ptr*);" & _ ;GetCurrentPattern hresult([in] int ;[out] iunknown ) "GetCachedPattern hresult(int;ptr*);" & _ ;GetCachedPattern hresult([in] int ;[out] iunknown ) "GetCachedParent hresult(ptr*);" & _ ;GetCachedParent hresult([out] IUIAutomationElement **) "GetCachedChildren hresult(ptr*);" & _ ;GetCachedChildren hresult([out] IUIAutomationElementArray **) "CurrentProcessId hresult(int*);" & _ ;CurrentProcessId hresult([out] int ) "CurrentControlType hresult(int*);" & _ ;CurrentControlType hresult([out] int ) "CurrentLocalizedControlType hresult(bstr*);" & _ ;CurrentLocalizedControlType hresult([out] bstr ) "CurrentName hresult(bstr*);" & _ ;CurrentName hresult([out] bstr ) "CurrentAcceleratorKey hresult(bstr*);" & _ ;CurrentAcceleratorKey hresult([out] bstr ) "CurrentAccessKey hresult(bstr*);" & _ ;CurrentAccessKey hresult([out] bstr ) "CurrentHasKeyboardFocus hresult(long*);" & _ ;CurrentHasKeyboardFocus hresult([out] int ) "CurrentIsKeyboardFocusable hresult(long*);" & _ ;CurrentIsKeyboardFocusable hresult([out] int ) "CurrentIsEnabled hresult(long*);" & _ ;CurrentIsEnabled hresult([out] int ) "CurrentAutomationId hresult(bstr*);" & _ ;CurrentAutomationId hresult([out] bstr ) "CurrentClassName hresult(bstr*);" & _ ;CurrentClassName hresult([out] bstr ) "CurrentHelpText hresult(bstr*);" & _ ;CurrentHelpText hresult([out] bstr ) "CurrentCulture hresult(int*);" & _ ;CurrentCulture hresult([out] int ) "CurrentIsControlElement hresult(long*);" & _ ;CurrentIsControlElement hresult([out] int ) "CurrentIsContentElement hresult(long*);" & _ ;CurrentIsContentElement hresult([out] int ) "CurrentIsPassword hresult(long*);" & _ ;CurrentIsPassword hresult([out] int ) "CurrentNativeWindowHandle hresult(none*);" & _ ;CurrentNativeWindowHandle hresult([out] void ) "CurrentItemType hresult(bstr*);" & _ ;CurrentItemType hresult([out] bstr ) "CurrentIsOffscreen hresult(long*);" & _ ;CurrentIsOffscreen hresult([out] int ) "CurrentOrientation hresult(long*);" & _ ;CurrentOrientation hresult([out] OrientationType *) "CurrentFrameworkId hresult(bstr*);" & _ ;CurrentFrameworkId hresult([out] bstr ) "CurrentIsRequiredForForm hresult(long*);" & _ ;CurrentIsRequiredForForm hresult([out] int ) "CurrentItemStatus hresult(bstr*);" & _ ;CurrentItemStatus hresult([out] bstr ) "CurrentBoundingRectangle hresult(none*);" & _ ;CurrentBoundingRectangle hresult([out] tagRECT *) "CurrentLabeledBy hresult(ptr*);" & _ ;CurrentLabeledBy hresult([out] IUIAutomationElement **) "CurrentAriaRole hresult(bstr*);" & _ ;CurrentAriaRole hresult([out] bstr ) "CurrentAriaProperties hresult(bstr*);" & _ ;CurrentAriaProperties hresult([out] bstr ) "CurrentIsDataValidForForm hresult(long*);" & _ ;CurrentIsDataValidForForm hresult([out] int ) "CurrentControllerFor hresult(ptr*);" & _ ;CurrentControllerFor hresult([out] IUIAutomationElementArray **) "CurrentDescribedBy hresult(ptr*);" & _ ;CurrentDescribedBy hresult([out] IUIAutomationElementArray **) "CurrentFlowsTo hresult(ptr*);" & _ ;CurrentFlowsTo hresult([out] IUIAutomationElementArray **) "CurrentProviderDescription hresult(bstr*);" & _ ;CurrentProviderDescription hresult([out] bstr ) "CachedProcessId hresult(int*);" & _ ;CachedProcessId hresult([out] int ) "CachedControlType hresult(int*);" & _ ;CachedControlType hresult([out] int ) "CachedLocalizedControlType hresult(bstr*);" & _ ;CachedLocalizedControlType hresult([out] bstr ) "CachedName hresult(bstr*);" & _ ;CachedName hresult([out] bstr ) "CachedAcceleratorKey hresult(bstr*);" & _ ;CachedAcceleratorKey hresult([out] bstr ) "CachedAccessKey hresult(bstr*);" & _ ;CachedAccessKey hresult([out] bstr ) "CachedHasKeyboardFocus hresult(long*);" & _ ;CachedHasKeyboardFocus hresult([out] int ) "CachedIsKeyboardFocusable hresult(long*);" & _ ;CachedIsKeyboardFocusable hresult([out] int ) "CachedIsEnabled hresult(long*);" & _ ;CachedIsEnabled hresult([out] int ) "CachedAutomationId hresult(bstr*);" & _ ;CachedAutomationId hresult([out] bstr ) "CachedClassName hresult(bstr*);" & _ ;CachedClassName hresult([out] bstr ) "CachedHelpText hresult(bstr*);" & _ ;CachedHelpText hresult([out] bstr ) "CachedCulture hresult(int*);" & _ ;CachedCulture hresult([out] int ) "CachedIsControlElement hresult(long*);" & _ ;CachedIsControlElement hresult([out] int ) "CachedIsContentElement hresult(long*);" & _ ;CachedIsContentElement hresult([out] int ) "CachedIsPassword hresult(long*);" & _ ;CachedIsPassword hresult([out] int ) "CachedNativeWindowHandle hresult(none*);" & _ ;CachedNativeWindowHandle hresult([out] void ) "CachedItemType hresult(bstr*);" & _ ;CachedItemType hresult([out] bstr ) "CachedIsOffscreen hresult(long*);" & _ ;CachedIsOffscreen hresult([out] int ) "CachedOrientation hresult(long*);" & _ ;CachedOrientation hresult([out] OrientationType *) "CachedFrameworkId hresult(bstr*);" & _ ;CachedFrameworkId hresult([out] bstr ) "CachedIsRequiredForForm hresult(long*);" & _ ;CachedIsRequiredForForm hresult([out] int ) "CachedItemStatus hresult(bstr*);" & _ ;CachedItemStatus hresult([out] bstr ) "CachedBoundingRectangle hresult(none*);" & _ ;CachedBoundingRectangle hresult([out] tagRECT *) "CachedLabeledBy hresult(ptr*);" & _ ;CachedLabeledBy hresult([out] IUIAutomationElement **) "CachedAriaRole hresult(bstr*);" & _ ;CachedAriaRole hresult([out] bstr ) "CachedAriaProperties hresult(bstr*);" & _ ;CachedAriaProperties hresult([out] bstr ) "CachedIsDataValidForForm hresult(long*);" & _ ;CachedIsDataValidForForm hresult([out] int ) "CachedControllerFor hresult(ptr*);" & _ ;CachedControllerFor hresult([out] IUIAutomationElementArray **) "CachedDescribedBy hresult(ptr*);" & _ ;CachedDescribedBy hresult([out] IUIAutomationElementArray **) "CachedFlowsTo hresult(ptr*);" & _ ;CachedFlowsTo hresult([out] IUIAutomationElementArray **) "CachedProviderDescription hresult(bstr*);" & _ ;CachedProviderDescription hresult([out] bstr ) "GetClickablePoint hresult(none*;long*);" ;GetClickablePoint hresult([out] tagPOINT *;[out] int ) ;=============================================================================== ;module UIA_PropertyIds ;=============================================================================== Global Const $UIA_RuntimeIdPropertyId=30000 Global Const $UIA_BoundingRectanglePropertyId=30001 Global Const $UIA_ProcessIdPropertyId=30002 Global Const $UIA_ControlTypePropertyId=30003 Global Const $UIA_LocalizedControlTypePropertyId=30004 Global Const $UIA_NamePropertyId=30005 Global Const $UIA_AcceleratorKeyPropertyId=30006 Global Const $UIA_AccessKeyPropertyId=30007 Global Const $UIA_HasKeyboardFocusPropertyId=30008 Global Const $UIA_IsKeyboardFocusablePropertyId=30009 Global Const $UIA_IsEnabledPropertyId=30010 Global Const $UIA_AutomationIdPropertyId=30011 Global Const $UIA_ClassNamePropertyId=30012 Global Const $UIA_HelpTextPropertyId=30013 Global Const $UIA_ClickablePointPropertyId=30014 Global Const $UIA_CulturePropertyId=30015 Global Const $UIA_IsControlElementPropertyId=30016 Global Const $UIA_IsContentElementPropertyId=30017 Global Const $UIA_LabeledByPropertyId=30018 Global Const $UIA_IsPasswordPropertyId=30019 Global Const $UIA_NativeWindowHandlePropertyId=30020 Global Const $UIA_ItemTypePropertyId=30021 Global Const $UIA_IsOffscreenPropertyId=30022 Global Const $UIA_OrientationPropertyId=30023 Global Const $UIA_FrameworkIdPropertyId=30024 Global Const $UIA_IsRequiredForFormPropertyId=30025 Global Const $UIA_ItemStatusPropertyId=30026 Global Const $UIA_IsDockPatternAvailablePropertyId=30027 Global Const $UIA_IsExpandCollapsePatternAvailablePropertyId=30028 Global Const $UIA_IsGridItemPatternAvailablePropertyId=30029 Global Const $UIA_IsGridPatternAvailablePropertyId=30030 Global Const $UIA_IsInvokePatternAvailablePropertyId=30031 Global Const $UIA_IsMultipleViewPatternAvailablePropertyId=30032 Global Const $UIA_IsRangeValuePatternAvailablePropertyId=30033 Global Const $UIA_IsScrollPatternAvailablePropertyId=30034 Global Const $UIA_IsScrollItemPatternAvailablePropertyId=30035 Global Const $UIA_IsSelectionItemPatternAvailablePropertyId=30036 Global Const $UIA_IsSelectionPatternAvailablePropertyId=30037 Global Const $UIA_IsTablePatternAvailablePropertyId=30038 Global Const $UIA_IsTableItemPatternAvailablePropertyId=30039 Global Const $UIA_IsTextPatternAvailablePropertyId=30040 Global Const $UIA_IsTogglePatternAvailablePropertyId=30041 Global Const $UIA_IsTransformPatternAvailablePropertyId=30042 Global Const $UIA_IsValuePatternAvailablePropertyId=30043 Global Const $UIA_IsWindowPatternAvailablePropertyId=30044 Global Const $UIA_ValueValuePropertyId=30045 Global Const $UIA_ValueIsReadOnlyPropertyId=30046 Global Const $UIA_RangeValueValuePropertyId=30047 Global Const $UIA_RangeValueIsReadOnlyPropertyId=30048 Global Const $UIA_RangeValueMinimumPropertyId=30049 Global Const $UIA_RangeValueMaximumPropertyId=30050 Global Const $UIA_RangeValueLargeChangePropertyId=30051 Global Const $UIA_RangeValueSmallChangePropertyId=30052 Global Const $UIA_ScrollHorizontalScrollPercentPropertyId=30053 Global Const $UIA_ScrollHorizontalViewSizePropertyId=30054 Global Const $UIA_ScrollVerticalScrollPercentPropertyId=30055 Global Const $UIA_ScrollVerticalViewSizePropertyId=30056 Global Const $UIA_ScrollHorizontallyScrollablePropertyId=30057 Global Const $UIA_ScrollVerticallyScrollablePropertyId=30058 Global Const $UIA_SelectionselectionPropertyId=30059 Global Const $UIA_SelectionCanSelectMultiplePropertyId=30060 Global Const $UIA_SelectionIsSelectionRequiredPropertyId=30061 Global Const $UIA_GridRowCountPropertyId=30062 Global Const $UIA_GridColumnCountPropertyId=30063 Global Const $UIA_GridItemRowPropertyId=30064 Global Const $UIA_GridItemColumnPropertyId=30065 Global Const $UIA_GridItemRowSpanPropertyId=30066 Global Const $UIA_GridItemColumnSpanPropertyId=30067 Global Const $UIA_GridItemContainingGridPropertyId=30068 Global Const $UIA_DockDockPositionPropertyId=30069 Global Const $UIA_ExpandCollapseExpandCollapseStatePropertyId=30070 Global Const $UIA_MultipleViewCurrentViewPropertyId=30071 Global Const $UIA_MultipleViewSupportedViewsPropertyId=30072 Global Const $UIA_WindowCanMaximizePropertyId=30073 Global Const $UIA_WindowCanMinimizePropertyId=30074 Global Const $UIA_WindowWindowVisualStatePropertyId=30075 Global Const $UIA_WindowWindowInteractionStatePropertyId=30076 Global Const $UIA_WindowIsModalPropertyId=30077 Global Const $UIA_WindowIsTopmostPropertyId=30078 Global Const $UIA_SelectionItemIsSelectedPropertyId=30079 Global Const $UIA_SelectionItemSelectionContainerPropertyId=30080 Global Const $UIA_TableRowHeadersPropertyId=30081 Global Const $UIA_TableColumnHeadersPropertyId=30082 Global Const $UIA_TableRowOrColumnMajorPropertyId=30083 Global Const $UIA_TableItemRowHeaderItemsPropertyId=30084 Global Const $UIA_TableItemColumnHeaderItemsPropertyId=30085 Global Const $UIA_ToggleToggleStatePropertyId=30086 Global Const $UIA_TransformCanMovePropertyId=30087 Global Const $UIA_TransformCanResizePropertyId=30088 Global Const $UIA_TransformCanRotatePropertyId=30089 Global Const $UIA_IsLegacyIAccessiblePatternAvailablePropertyId=30090 Global Const $UIA_LegacyIAccessibleChildIdPropertyId=30091 Global Const $UIA_LegacyIAccessibleNamePropertyId=30092 Global Const $UIA_LegacyIAccessibleValuePropertyId=30093 Global Const $UIA_LegacyIAccessibleDescriptionPropertyId=30094 Global Const $UIA_LegacyIAccessibleRolePropertyId=30095 Global Const $UIA_LegacyIAccessibleStatePropertyId=30096 Global Const $UIA_LegacyIAccessibleHelpPropertyId=30097 Global Const $UIA_LegacyIAccessibleKeyboardShortcutPropertyId=30098 Global Const $UIA_LegacyIAccessibleSelectionPropertyId=30099 Global Const $UIA_LegacyIAccessibleDefaultActionPropertyId=30100 Global Const $UIA_AriaRolePropertyId=30101 Global Const $UIA_AriaPropertiesPropertyId=30102 Global Const $UIA_IsDataValidForFormPropertyId=30103 Global Const $UIA_ControllerForPropertyId=30104 Global Const $UIA_DescribedByPropertyId=30105 Global Const $UIA_FlowsToPropertyId=30106 Global Const $UIA_ProviderDescriptionPropertyId=30107 Global Const $UIA_IsItemContainerPatternAvailablePropertyId=30108 Global Const $UIA_IsVirtualizedItemPatternAvailablePropertyId=30109 Global Const $UIA_IsSynchronizedInputPatternAvailablePropertyId=30110 ;~ The main object with acces to the windows automation api 3.0 Global $objUIAutomation = ObjCreateInterface($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 $objUIAutomation.GetRootElement($pDesktop) ;~ $oDesktop = ObjCreateInterface($pDesktop, $dtagIUIAutomationElement) ;~ If IsObj($oDesktop) Then ;~ ConsoleWrite("At least it seems I have the desktop as a frequently used starting point" & @CRLF) ;~ EndIf $oDesktop = ObjCreateInterface($pDesktop, $sIID_IUIAutomationElement,$dtagIUIAutomationElement) If IsObj($oDesktop) Then ConsoleWrite("At least it seems I have the desktop as a frequently used starting point" & "[" & getPVal($oDesktop, $UIA_NamePropertyId) & "][" & getPVal($oDesktop, $UIA_ClassNamePropertyId) & "]" & @CRLF) EndIf $objUIAutomation.GetFocusedElement($pUIElement) $oUIElement = ObjCreateInterface($pUIElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement) If IsObj($oUIElement) Then ConsoleWrite("At least we have an focused element " & "[" & getPVal($oUIElement, $UIA_NamePropertyId) & "][" & getPVal($oUIElement, $UIA_ClassNamePropertyId) & "]" & @CRLF) EndIf while True sleep(100) WEnd Func GetElementInfo() Local $hWnd Local $tStruct = DllStructCreate($tagPOINT) ; Create a structure that defines the point to be checked. ;~ Local $tStruct =_AutoItObject_DllStructCreate($tagPoint) ToolTip("") $x=MouseGetPos(0) $y=MouseGetPos(1) DllStructSetData($tStruct, "x", $x) DllStructSetData($tStruct, "y", $y) ;~ consolewrite(DllStructGetData($tStruct,"x") & DllStructGetData($tStruct,"y")) ;~ consolewrite("Mouse position is retrieved " & @crlf) $objUIAutomation.ElementFromPoint($tStruct,$pUIElement) ;~ $objUIAutomation.ElementFromPoint(DllStructGetPtr($tStruct),$pUIElement) ;~ consolewrite("Element from point is passed, trying to convert to object ") $oUIElement = objcreateinterface($pUIElement,$sIID_IUIAutomationElement, $dtagIUIAutomationElement) If IsObj($oUIElement) Then ConsoleWrite("At least we have an element " & "[" & getPVal($oUIElement, $UIA_NamePropertyId) & "][" & getPVal($oUIElement, $UIA_ClassNamePropertyId) & "]" & @CRLF) EndIf EndFunc ;==>Example Func Close() Exit EndFunc ;==>Close ;~ Just return a single property or if its an array string them together func getPVal($obj, $id) local $tval local $tStr local $aCall $obj.GetCurrentPropertyValue($Id,$tVal) ;~ $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 Edited January 6, 2013 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...
trancexx Posted December 29, 2012 Share Posted December 29, 2012 (edited) Struct is complex type that can't be handled trivially. Bynary code for handling depends on several factors, the main of which is bitness. The other factor is declared content of the structure. This means that different structures are handled differently inside 32 bit and 64 bit binary code and even on the same one the content of the struct defines the handling. For someone not to think there is no order, this is all docummented by Microsoft for their systems. That's how some compiler can compile things right. I advise you to switch to built-in ObjCreateInterface() because it has unique ability to accept "struct" type and process structures correctly when invoking metods of the interface that require it. Anything else is pure improvisation even when made to work correctly. Edited December 29, 2012 by trancexx ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
junkew Posted January 6, 2013 Author Share Posted January 6, 2013 (edited) So probably you are saying that I do not need autoitobject for using interfaces in this example IUIautomation.So I can rebuild everything from threadin a better way with using ObjCreateInterfaceNeed some help as I do not get below to work (subtracted from the other thread the relevant parts from CUIAUTOMATION.AU3 so this below code can work independently)Intention is just based on UIAutomationCore.DLL to see if everything can work including the ElementFromPoint partQuestions on below (coming from the AutoitObject syntax)1. It doesn't work (probably because of taking to much from the Autoitobject syntax)a. I get the overall object of automationb. I do not get the root element to $desktop (should I change syntax like ptr* to idispatch?)c. When b is working I proved that I have access to an ui automation elementd. Then next step is to use alternative methods to get elements to be able to call the elementfrompointmoved example code to initial post Edited January 6, 2013 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...
trancexx Posted January 6, 2013 Share Posted January 6, 2013 (edited) Yes, this is the main difference - there is no array on return of the method. For example, small chunk of code you have problem with should be like this:;~ Try to get the desktop as a generic reference/global for all samples Local $pAutomationElement $objUIAutomation.GetRootElement($pAutomationElement) $oDesktop = ObjCreateInterface($pAutomationElement, $dtagIUIAutomationElement)Do you understand the difference? Instead of passing 0 and collecting from the returned array, now you collect directly to variable byref. You pass some variable $pAutomationElement to the GetRootElement method and it fills it with data (you said it was pointer when defining the interface) for you. Then you use that pointer to create desktop object. Edited January 6, 2013 by trancexx ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
junkew Posted January 6, 2013 Author Share Posted January 6, 2013 thx.problems are resolved and first post modified with working code example.(some spying on objects accessible with UIAutomation)Troubles I had (/have) are the small differences in syntaxSo when I have struct in the interface I do not have to code$objUIAutomation.ElementFromPoint($tStruct,$pUIElement) Should remove $objUIAutomation.ElementFromPoint(DllStructGetPtr($tStruct),$pUIElement) Once I have more time I will rewrite the CUIAutomation.AU3 thread with objCreateInterface 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 April 14, 2013 Author Share Posted April 14, 2013 A little more difficult then I thought. Help is appreciated. How do I translate this AutoITObject syntax to the objCreateInterface? This is AutoITObject syntax ;~ Focus Changed Handler Global $oFCEHandler = _AutoItObject_ObjectFromDtag("_MyHandler_", $dtagIUIAutomationfocusChangedEventHandler) $objUIAutomation.AddFocusChangedEventHandler(0, $oFCEHandler.__ptr__) ** How to change this to ObjCreateInterface? ;~ Focus Changed Handler Global $oFCEHandler = ObjCreateInterface("_MyHandler_", $dtagIUIAutomationfocusChangedEventHandler) If IsObj($oFCEHandler) Then ConsoleWrite("At least we have an focus handler " & @CRLF) EndIf $objUIAutomation.AddFocusChangedEventHandler(0, $oFCEHandler) 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