Что нового

Создание объекта при наследовании интерфейса

InnI

AutoIT Гуру
Сообщения
4,912
Репутация
1,429
Есть объект с описанием интерфейса IExample (создаётся, работает)
Код:
$sCLSID = "{00000000-0000-0000-0000-00000000}"

$sIID_IExample = "{11111111-1111-1111-1111-11111111}"
$dtag_IExample = "Method1 hresult(int);" & _
                 "Method2 hresult(int);" & _
                 "Method3 hresult(int);"

$oObj = ObjCreateInterface($sCLSID, $sIID_IExample, $dtag_IExample)
$oObj.Method3()
Есть интерфейс, наследованный от IExample. Как описать данный интерфейс? Нужно ли добавлять полностью описание родителя или достаточно только добавленных методов? И, соответственно, как создать объект с доступом к методам родительского интерфейса? Пробовал так - не работает
Код:
$sIID_IExample2 = "{22222222-2222-2222-2222-22222222}"
$dtag_IExample2 = _      ; $dtag_IExample & _ ; <= нужно ли ?
                  "Method4 hresult(int);" & _
                  "Method5 hresult(int);"

$oObj = ObjCreateInterface($sCLSID, $sIID_IExample, $dtag_IExample) ; объект создаётся
$oObj2 = ObjCreateInterface($oObj, $sIID_IExample2, $dtag_IExample2, False) ; объект создаётся
$oObj2.Method3() ; метод не находит
$oObj2.Method4() ; Exit code 3221225477
 

inververs

AutoIT Гуру
Сообщения
2,135
Репутация
465
Да нужно полностью описывать, единственно не нужно описывать методы интерфейса IUnknown, т.к 4 параметром функции ObjCreateInterface стоит True, и он как раз добавит их автоматически.
 
Автор
I

InnI

AutoIT Гуру
Сообщения
4,912
Репутация
1,429
inververs
нужно полностью описывать
Описал полностью - всё равно не находит методы.

При создании этого объекта в функции ObjCreateInterface() первым параметром что нужно указывать? Предварительно созданный объект-родитель или что-то другое? И нужно ли менять последний параметр на False, если создаём от родительского?
 

inververs

AutoIT Гуру
Сообщения
2,135
Репутация
465
А что вы пытаетесь сделать? Создать собственный объект или вызывать методы уже известного (полученного ранее)? Если собственный - то поищите темы Viktor1703, у него есть примеры, или же найдите UDF AutoItObject.au3 - там есть весь функционал.

InnI [?]
При создании этого объекта в функции ObjCreateInterface() первым параметром что нужно указывать?
В первом параметре можно передать: объект, указатель на объект, или CLSID (ProgID) существующего компонента.
Смотря что у вас есть - то и передавайте. Но чаще всего вам нужен указатель на объект.

И нужно ли менять последний параметр на False, если создаём от родительского?
Третий параметр указывает на то, наследуется ли интерфейс от IUnknown, и в 99% случаев его не нужно указывать и оставлять по умолчанию.
(Т.к все интерфейсы наследуются от IUnknown)




Добавлено:
Сообщение автоматически объединено:

Тут как бы нет такого понятия как родительский - дочерний (Формально он конечно есть), поэтому, если вы видите что интерфейс наследуется от другого, то вам нужно в описании создать полную структуру из всех описаний всех родителей итп и так пока в родителях не окажется IUnknown. И "дочернему" объекту станут доступны все методы "родителей"


Добавлено:
Сообщение автоматически объединено:

К примеру, вот интерфейс: INetConnectionProps, он наследуется от интерфейса IDispatch, поэтому, описание его должно быть таким:
Код:
Global Const $dtag_INetConnectionProps = $dtag_IDispatch & _
		'get_Guid hresult(wstr*);' & _; 		/* [retval][out] */ __RPC__deref_out_opt BSTR *pbstrGuid
		'get_Name hresult(wstr*);' & _; 		/* [retval][out] */ __RPC__deref_out_opt BSTR *pbstrName
		'get_DeviceName hresult(wstr*);' & _; 	/* [retval][out] */ __RPC__deref_out_opt BSTR *pbstrDeviceName
		'get_Status hresult(int*);' & _; 		/* [retval][out] */ __RPC__out NETCON_STATUS *pStatus
		'get_MediaType hresult(int*);' & _; 	/* [retval][out] */ __RPC__out NETCON_MEDIATYPE *pMediaType
		'get_Characteristics hresult(dword*);'; /* [retval][out] */ __RPC__out DWORD *pdwFlags
 
Автор
I

InnI

AutoIT Гуру
Сообщения
4,912
Репутация
1,429
inververs
что вы пытаетесь сделать?
На Win8 добавился новый интерфейс IUIAutomation2. Вот его описание из UIAutomationClient.h
Код:
#ifndef __IUIAutomation2_INTERFACE_DEFINED__
#define __IUIAutomation2_INTERFACE_DEFINED__

/* interface IUIAutomation2 */
/* [unique][uuid][object] */ 


EXTERN_C const IID IID_IUIAutomation2;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    MIDL_INTERFACE("34723aff-0c9d-49d0-9896-7ab52df8cd8a")
    IUIAutomation2 : public IUIAutomation
    {
    public:
        virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_AutoSetFocus( 
            /* [retval][out] */ __RPC__out BOOL *autoSetFocus) = 0;
        
        virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_AutoSetFocus( 
            /* [in] */ BOOL autoSetFocus) = 0;
        
        virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_ConnectionTimeout( 
            /* [retval][out] */ __RPC__out DWORD *timeout) = 0;
        
        virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_ConnectionTimeout( 
            /* [in] */ DWORD timeout) = 0;
        
        virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_TransactionTimeout( 
            /* [retval][out] */ __RPC__out DWORD *timeout) = 0;
        
        virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_TransactionTimeout( 
            /* [in] */ DWORD timeout) = 0;
        
    };
    
    
#else 	/* C style interface */

    typedef struct IUIAutomation2Vtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE *QueryInterface )( 
            __RPC__in IUIAutomation2 * This,
            /* [in] */ __RPC__in REFIID riid,
            /* [annotation][iid_is][out] */ 
            _COM_Outptr_  void **ppvObject);
        
        ULONG ( STDMETHODCALLTYPE *AddRef )( 
            __RPC__in IUIAutomation2 * This);
        
        ULONG ( STDMETHODCALLTYPE *Release )( 
            __RPC__in IUIAutomation2 * This);
        
        HRESULT ( STDMETHODCALLTYPE *CompareElements )( 
            __RPC__in IUIAutomation2 * This,
            /* [in] */ __RPC__in_opt IUIAutomationElement *el1,
            /* [in] */ __RPC__in_opt IUIAutomationElement *el2,
            /* [retval][out] */ __RPC__out BOOL *areSame);
        
        HRESULT ( STDMETHODCALLTYPE *CompareRuntimeIds )( 
            __RPC__in IUIAutomation2 * This,
            /* [in] */ __RPC__in SAFEARRAY * runtimeId1,
            /* [in] */ __RPC__in SAFEARRAY * runtimeId2,
            /* [retval][out] */ __RPC__out BOOL *areSame);
        
        HRESULT ( STDMETHODCALLTYPE *GetRootElement )( 
            __RPC__in IUIAutomation2 * This,
            /* [retval][out] */ __RPC__deref_out_opt IUIAutomationElement **root);
        
        HRESULT ( STDMETHODCALLTYPE *ElementFromHandle )( 
            __RPC__in IUIAutomation2 * This,
            /* [in] */ __RPC__in UIA_HWND hwnd,
            /* [retval][out] */ __RPC__deref_out_opt IUIAutomationElement **element);
        
        HRESULT ( STDMETHODCALLTYPE *ElementFromPoint )( 
            __RPC__in IUIAutomation2 * This,
            /* [in] */ POINT pt,
            /* [retval][out] */ __RPC__deref_out_opt IUIAutomationElement **element);
        
        HRESULT ( STDMETHODCALLTYPE *GetFocusedElement )( 
            __RPC__in IUIAutomation2 * This,
            /* [retval][out] */ __RPC__deref_out_opt IUIAutomationElement **element);
        
        HRESULT ( STDMETHODCALLTYPE *GetRootElementBuildCache )( 
            __RPC__in IUIAutomation2 * This,
            /* [in] */ __RPC__in_opt IUIAutomationCacheRequest *cacheRequest,
            /* [retval][out] */ __RPC__deref_out_opt IUIAutomationElement **root);
        
        HRESULT ( STDMETHODCALLTYPE *ElementFromHandleBuildCache )( 
            __RPC__in IUIAutomation2 * This,
            /* [in] */ __RPC__in UIA_HWND hwnd,
            /* [in] */ __RPC__in_opt IUIAutomationCacheRequest *cacheRequest,
            /* [retval][out] */ __RPC__deref_out_opt IUIAutomationElement **element);
        
        HRESULT ( STDMETHODCALLTYPE *ElementFromPointBuildCache )( 
            __RPC__in IUIAutomation2 * This,
            /* [in] */ POINT pt,
            /* [in] */ __RPC__in_opt IUIAutomationCacheRequest *cacheRequest,
            /* [retval][out] */ __RPC__deref_out_opt IUIAutomationElement **element);
        
        HRESULT ( STDMETHODCALLTYPE *GetFocusedElementBuildCache )( 
            __RPC__in IUIAutomation2 * This,
            /* [in] */ __RPC__in_opt IUIAutomationCacheRequest *cacheRequest,
            /* [retval][out] */ __RPC__deref_out_opt IUIAutomationElement **element);
        
        HRESULT ( STDMETHODCALLTYPE *CreateTreeWalker )( 
            __RPC__in IUIAutomation2 * This,
            /* [in] */ __RPC__in_opt IUIAutomationCondition *pCondition,
            /* [retval][out] */ __RPC__deref_out_opt IUIAutomationTreeWalker **walker);
        
        /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_ControlViewWalker )( 
            __RPC__in IUIAutomation2 * This,
            /* [retval][out] */ __RPC__deref_out_opt IUIAutomationTreeWalker **walker);
        
        /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_ContentViewWalker )( 
            __RPC__in IUIAutomation2 * This,
            /* [retval][out] */ __RPC__deref_out_opt IUIAutomationTreeWalker **walker);
        
        /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_RawViewWalker )( 
            __RPC__in IUIAutomation2 * This,
            /* [retval][out] */ __RPC__deref_out_opt IUIAutomationTreeWalker **walker);
        
        /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_RawViewCondition )( 
            __RPC__in IUIAutomation2 * This,
            /* [retval][out] */ __RPC__deref_out_opt IUIAutomationCondition **condition);
        
        /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_ControlViewCondition )( 
            __RPC__in IUIAutomation2 * This,
            /* [retval][out] */ __RPC__deref_out_opt IUIAutomationCondition **condition);
        
        /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_ContentViewCondition )( 
            __RPC__in IUIAutomation2 * This,
            /* [retval][out] */ __RPC__deref_out_opt IUIAutomationCondition **condition);
        
        HRESULT ( STDMETHODCALLTYPE *CreateCacheRequest )( 
            __RPC__in IUIAutomation2 * This,
            /* [retval][out] */ __RPC__deref_out_opt IUIAutomationCacheRequest **cacheRequest);
        
        HRESULT ( STDMETHODCALLTYPE *CreateTrueCondition )( 
            __RPC__in IUIAutomation2 * This,
            /* [retval][out] */ __RPC__deref_out_opt IUIAutomationCondition **newCondition);
        
        HRESULT ( STDMETHODCALLTYPE *CreateFalseCondition )( 
            __RPC__in IUIAutomation2 * This,
            /* [retval][out] */ __RPC__deref_out_opt IUIAutomationCondition **newCondition);
        
        HRESULT ( STDMETHODCALLTYPE *CreatePropertyCondition )( 
            __RPC__in IUIAutomation2 * This,
            /* [in] */ PROPERTYID propertyId,
            /* [in] */ VARIANT value,
            /* [retval][out] */ __RPC__deref_out_opt IUIAutomationCondition **newCondition);
        
        HRESULT ( STDMETHODCALLTYPE *CreatePropertyConditionEx )( 
            __RPC__in IUIAutomation2 * This,
            /* [in] */ PROPERTYID propertyId,
            /* [in] */ VARIANT value,
            /* [in] */ enum PropertyConditionFlags flags,
            /* [retval][out] */ __RPC__deref_out_opt IUIAutomationCondition **newCondition);
        
        HRESULT ( STDMETHODCALLTYPE *CreateAndCondition )( 
            __RPC__in IUIAutomation2 * This,
            /* [in] */ __RPC__in_opt IUIAutomationCondition *condition1,
            /* [in] */ __RPC__in_opt IUIAutomationCondition *condition2,
            /* [retval][out] */ __RPC__deref_out_opt IUIAutomationCondition **newCondition);
        
        HRESULT ( STDMETHODCALLTYPE *CreateAndConditionFromArray )( 
            __RPC__in IUIAutomation2 * This,
            /* [in] */ __RPC__in_opt SAFEARRAY * conditions,
            /* [retval][out] */ __RPC__deref_out_opt IUIAutomationCondition **newCondition);
        
        HRESULT ( STDMETHODCALLTYPE *CreateAndConditionFromNativeArray )( 
            __RPC__in IUIAutomation2 * This,
            /* [size_is][in] */ __RPC__in_ecount_full(conditionCount) IUIAutomationCondition **conditions,
            /* [in] */ int conditionCount,
            /* [retval][out] */ __RPC__deref_out_opt IUIAutomationCondition **newCondition);
        
        HRESULT ( STDMETHODCALLTYPE *CreateOrCondition )( 
            __RPC__in IUIAutomation2 * This,
            /* [in] */ __RPC__in_opt IUIAutomationCondition *condition1,
            /* [in] */ __RPC__in_opt IUIAutomationCondition *condition2,
            /* [retval][out] */ __RPC__deref_out_opt IUIAutomationCondition **newCondition);
        
        HRESULT ( STDMETHODCALLTYPE *CreateOrConditionFromArray )( 
            __RPC__in IUIAutomation2 * This,
            /* [in] */ __RPC__in_opt SAFEARRAY * conditions,
            /* [retval][out] */ __RPC__deref_out_opt IUIAutomationCondition **newCondition);
        
        HRESULT ( STDMETHODCALLTYPE *CreateOrConditionFromNativeArray )( 
            __RPC__in IUIAutomation2 * This,
            /* [size_is][in] */ __RPC__in_ecount_full(conditionCount) IUIAutomationCondition **conditions,
            /* [in] */ int conditionCount,
            /* [retval][out] */ __RPC__deref_out_opt IUIAutomationCondition **newCondition);
        
        HRESULT ( STDMETHODCALLTYPE *CreateNotCondition )( 
            __RPC__in IUIAutomation2 * This,
            /* [in] */ __RPC__in_opt IUIAutomationCondition *condition,
            /* [retval][out] */ __RPC__deref_out_opt IUIAutomationCondition **newCondition);
        
        HRESULT ( STDMETHODCALLTYPE *AddAutomationEventHandler )( 
            __RPC__in IUIAutomation2 * This,
            /* [in] */ EVENTID eventId,
            /* [in] */ __RPC__in_opt IUIAutomationElement *element,
            /* [in] */ enum TreeScope scope,
            /* [in] */ __RPC__in_opt IUIAutomationCacheRequest *cacheRequest,
            /* [in] */ __RPC__in_opt IUIAutomationEventHandler *handler);
        
        HRESULT ( STDMETHODCALLTYPE *RemoveAutomationEventHandler )( 
            __RPC__in IUIAutomation2 * This,
            /* [in] */ EVENTID eventId,
            /* [in] */ __RPC__in_opt IUIAutomationElement *element,
            /* [in] */ __RPC__in_opt IUIAutomationEventHandler *handler);
        
        HRESULT ( STDMETHODCALLTYPE *AddPropertyChangedEventHandlerNativeArray )( 
            __RPC__in IUIAutomation2 * This,
            /* [in] */ __RPC__in_opt IUIAutomationElement *element,
            /* [in] */ enum TreeScope scope,
            /* [in] */ __RPC__in_opt IUIAutomationCacheRequest *cacheRequest,
            /* [in] */ __RPC__in_opt IUIAutomationPropertyChangedEventHandler *handler,
            /* [size_is][in] */ __RPC__in_ecount_full(propertyCount) PROPERTYID *propertyArray,
            /* [in] */ int propertyCount);
        
        HRESULT ( STDMETHODCALLTYPE *AddPropertyChangedEventHandler )( 
            __RPC__in IUIAutomation2 * This,
            /* [in] */ __RPC__in_opt IUIAutomationElement *element,
            /* [in] */ enum TreeScope scope,
            /* [in] */ __RPC__in_opt IUIAutomationCacheRequest *cacheRequest,
            /* [in] */ __RPC__in_opt IUIAutomationPropertyChangedEventHandler *handler,
            /* [in] */ __RPC__in SAFEARRAY * propertyArray);
        
        HRESULT ( STDMETHODCALLTYPE *RemovePropertyChangedEventHandler )( 
            __RPC__in IUIAutomation2 * This,
            /* [in] */ __RPC__in_opt IUIAutomationElement *element,
            /* [in] */ __RPC__in_opt IUIAutomationPropertyChangedEventHandler *handler);
        
        HRESULT ( STDMETHODCALLTYPE *AddStructureChangedEventHandler )( 
            __RPC__in IUIAutomation2 * This,
            /* [in] */ __RPC__in_opt IUIAutomationElement *element,
            /* [in] */ enum TreeScope scope,
            /* [in] */ __RPC__in_opt IUIAutomationCacheRequest *cacheRequest,
            /* [in] */ __RPC__in_opt IUIAutomationStructureChangedEventHandler *handler);
        
        HRESULT ( STDMETHODCALLTYPE *RemoveStructureChangedEventHandler )( 
            __RPC__in IUIAutomation2 * This,
            /* [in] */ __RPC__in_opt IUIAutomationElement *element,
            /* [in] */ __RPC__in_opt IUIAutomationStructureChangedEventHandler *handler);
        
        HRESULT ( STDMETHODCALLTYPE *AddFocusChangedEventHandler )( 
            __RPC__in IUIAutomation2 * This,
            /* [in] */ __RPC__in_opt IUIAutomationCacheRequest *cacheRequest,
            /* [in] */ __RPC__in_opt IUIAutomationFocusChangedEventHandler *handler);
        
        HRESULT ( STDMETHODCALLTYPE *RemoveFocusChangedEventHandler )( 
            __RPC__in IUIAutomation2 * This,
            /* [in] */ __RPC__in_opt IUIAutomationFocusChangedEventHandler *handler);
        
        HRESULT ( STDMETHODCALLTYPE *RemoveAllEventHandlers )( 
            __RPC__in IUIAutomation2 * This);
        
        HRESULT ( STDMETHODCALLTYPE *IntNativeArrayToSafeArray )( 
            __RPC__in IUIAutomation2 * This,
            /* [size_is][in] */ __RPC__in_ecount_full(arrayCount) int *array,
            /* [in] */ int arrayCount,
            /* [retval][out] */ __RPC__deref_out_opt SAFEARRAY * *safeArray);
        
        HRESULT ( STDMETHODCALLTYPE *IntSafeArrayToNativeArray )( 
            __RPC__in IUIAutomation2 * This,
            /* [in] */ __RPC__in SAFEARRAY * intArray,
            /* [size_is][size_is][out] */ __RPC__deref_out_ecount_full_opt(*arrayCount) int **array,
            /* [retval][out] */ __RPC__out int *arrayCount);
        
        HRESULT ( STDMETHODCALLTYPE *RectToVariant )( 
            __RPC__in IUIAutomation2 * This,
            /* [in] */ RECT rc,
            /* [retval][out] */ __RPC__out VARIANT *var);
        
        HRESULT ( STDMETHODCALLTYPE *VariantToRect )( 
            __RPC__in IUIAutomation2 * This,
            /* [in] */ VARIANT var,
            /* [retval][out] */ __RPC__out RECT *rc);
        
        HRESULT ( STDMETHODCALLTYPE *SafeArrayToRectNativeArray )( 
            __RPC__in IUIAutomation2 * This,
            /* [in] */ __RPC__in SAFEARRAY * rects,
            /* [size_is][size_is][out] */ __RPC__deref_out_ecount_full_opt(*rectArrayCount) RECT **rectArray,
            /* [retval][out] */ __RPC__out int *rectArrayCount);
        
        HRESULT ( STDMETHODCALLTYPE *CreateProxyFactoryEntry )( 
            __RPC__in IUIAutomation2 * This,
            /* [in] */ __RPC__in_opt IUIAutomationProxyFactory *factory,
            /* [retval][out] */ __RPC__deref_out_opt IUIAutomationProxyFactoryEntry **factoryEntry);
        
        /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_ProxyFactoryMapping )( 
            __RPC__in IUIAutomation2 * This,
            /* [retval][out] */ __RPC__deref_out_opt IUIAutomationProxyFactoryMapping **factoryMapping);
        
        HRESULT ( STDMETHODCALLTYPE *GetPropertyProgrammaticName )( 
            __RPC__in IUIAutomation2 * This,
            /* [in] */ PROPERTYID property,
            /* [retval][out] */ __RPC__deref_out_opt BSTR *name);
        
        HRESULT ( STDMETHODCALLTYPE *GetPatternProgrammaticName )( 
            __RPC__in IUIAutomation2 * This,
            /* [in] */ PATTERNID pattern,
            /* [retval][out] */ __RPC__deref_out_opt BSTR *name);
        
        HRESULT ( STDMETHODCALLTYPE *PollForPotentialSupportedPatterns )( 
            __RPC__in IUIAutomation2 * This,
            /* [in] */ __RPC__in_opt IUIAutomationElement *pElement,
            /* [out] */ __RPC__deref_out_opt SAFEARRAY * *patternIds,
            /* [out] */ __RPC__deref_out_opt SAFEARRAY * *patternNames);
        
        HRESULT ( STDMETHODCALLTYPE *PollForPotentialSupportedProperties )( 
            __RPC__in IUIAutomation2 * This,
            /* [in] */ __RPC__in_opt IUIAutomationElement *pElement,
            /* [out] */ __RPC__deref_out_opt SAFEARRAY * *propertyIds,
            /* [out] */ __RPC__deref_out_opt SAFEARRAY * *propertyNames);
        
        HRESULT ( STDMETHODCALLTYPE *CheckNotSupported )( 
            __RPC__in IUIAutomation2 * This,
            /* [in] */ VARIANT value,
            /* [retval][out] */ __RPC__out BOOL *isNotSupported);
        
        /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_ReservedNotSupportedValue )( 
            __RPC__in IUIAutomation2 * This,
            /* [retval][out] */ __RPC__deref_out_opt IUnknown **notSupportedValue);
        
        /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_ReservedMixedAttributeValue )( 
            __RPC__in IUIAutomation2 * This,
            /* [retval][out] */ __RPC__deref_out_opt IUnknown **mixedAttributeValue);
        
        HRESULT ( STDMETHODCALLTYPE *ElementFromIAccessible )( 
            __RPC__in IUIAutomation2 * This,
            /* [in] */ __RPC__in_opt IAccessible *accessible,
            /* [in] */ int childId,
            /* [retval][out] */ __RPC__deref_out_opt IUIAutomationElement **element);
        
        HRESULT ( STDMETHODCALLTYPE *ElementFromIAccessibleBuildCache )( 
            __RPC__in IUIAutomation2 * This,
            /* [in] */ __RPC__in_opt IAccessible *accessible,
            /* [in] */ int childId,
            /* [in] */ __RPC__in_opt IUIAutomationCacheRequest *cacheRequest,
            /* [retval][out] */ __RPC__deref_out_opt IUIAutomationElement **element);
        
        /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_AutoSetFocus )( 
            __RPC__in IUIAutomation2 * This,
            /* [retval][out] */ __RPC__out BOOL *autoSetFocus);
        
        /* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_AutoSetFocus )( 
            __RPC__in IUIAutomation2 * This,
            /* [in] */ BOOL autoSetFocus);
        
        /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_ConnectionTimeout )( 
            __RPC__in IUIAutomation2 * This,
            /* [retval][out] */ __RPC__out DWORD *timeout);
        
        /* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_ConnectionTimeout )( 
            __RPC__in IUIAutomation2 * This,
            /* [in] */ DWORD timeout);
        
        /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_TransactionTimeout )( 
            __RPC__in IUIAutomation2 * This,
            /* [retval][out] */ __RPC__out DWORD *timeout);
        
        /* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_TransactionTimeout )( 
            __RPC__in IUIAutomation2 * This,
            /* [in] */ DWORD timeout);
        
        END_INTERFACE
    } IUIAutomation2Vtbl;

    interface IUIAutomation2
    {
        CONST_VTBL struct IUIAutomation2Vtbl *lpVtbl;
    };

    

#ifdef COBJMACROS


#define IUIAutomation2_QueryInterface(This,riid,ppvObject)	\
    ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) 

#define IUIAutomation2_AddRef(This)	\
    ( (This)->lpVtbl -> AddRef(This) ) 

#define IUIAutomation2_Release(This)	\
    ( (This)->lpVtbl -> Release(This) ) 


#define IUIAutomation2_CompareElements(This,el1,el2,areSame)	\
    ( (This)->lpVtbl -> CompareElements(This,el1,el2,areSame) ) 

#define IUIAutomation2_CompareRuntimeIds(This,runtimeId1,runtimeId2,areSame)	\
    ( (This)->lpVtbl -> CompareRuntimeIds(This,runtimeId1,runtimeId2,areSame) ) 

#define IUIAutomation2_GetRootElement(This,root)	\
    ( (This)->lpVtbl -> GetRootElement(This,root) ) 

#define IUIAutomation2_ElementFromHandle(This,hwnd,element)	\
    ( (This)->lpVtbl -> ElementFromHandle(This,hwnd,element) ) 

#define IUIAutomation2_ElementFromPoint(This,pt,element)	\
    ( (This)->lpVtbl -> ElementFromPoint(This,pt,element) ) 

#define IUIAutomation2_GetFocusedElement(This,element)	\
    ( (This)->lpVtbl -> GetFocusedElement(This,element) ) 

#define IUIAutomation2_GetRootElementBuildCache(This,cacheRequest,root)	\
    ( (This)->lpVtbl -> GetRootElementBuildCache(This,cacheRequest,root) ) 

#define IUIAutomation2_ElementFromHandleBuildCache(This,hwnd,cacheRequest,element)	\
    ( (This)->lpVtbl -> ElementFromHandleBuildCache(This,hwnd,cacheRequest,element) ) 

#define IUIAutomation2_ElementFromPointBuildCache(This,pt,cacheRequest,element)	\
    ( (This)->lpVtbl -> ElementFromPointBuildCache(This,pt,cacheRequest,element) ) 

#define IUIAutomation2_GetFocusedElementBuildCache(This,cacheRequest,element)	\
    ( (This)->lpVtbl -> GetFocusedElementBuildCache(This,cacheRequest,element) ) 

#define IUIAutomation2_CreateTreeWalker(This,pCondition,walker)	\
    ( (This)->lpVtbl -> CreateTreeWalker(This,pCondition,walker) ) 

#define IUIAutomation2_get_ControlViewWalker(This,walker)	\
    ( (This)->lpVtbl -> get_ControlViewWalker(This,walker) ) 

#define IUIAutomation2_get_ContentViewWalker(This,walker)	\
    ( (This)->lpVtbl -> get_ContentViewWalker(This,walker) ) 

#define IUIAutomation2_get_RawViewWalker(This,walker)	\
    ( (This)->lpVtbl -> get_RawViewWalker(This,walker) ) 

#define IUIAutomation2_get_RawViewCondition(This,condition)	\
    ( (This)->lpVtbl -> get_RawViewCondition(This,condition) ) 

#define IUIAutomation2_get_ControlViewCondition(This,condition)	\
    ( (This)->lpVtbl -> get_ControlViewCondition(This,condition) ) 

#define IUIAutomation2_get_ContentViewCondition(This,condition)	\
    ( (This)->lpVtbl -> get_ContentViewCondition(This,condition) ) 

#define IUIAutomation2_CreateCacheRequest(This,cacheRequest)	\
    ( (This)->lpVtbl -> CreateCacheRequest(This,cacheRequest) ) 

#define IUIAutomation2_CreateTrueCondition(This,newCondition)	\
    ( (This)->lpVtbl -> CreateTrueCondition(This,newCondition) ) 

#define IUIAutomation2_CreateFalseCondition(This,newCondition)	\
    ( (This)->lpVtbl -> CreateFalseCondition(This,newCondition) ) 

#define IUIAutomation2_CreatePropertyCondition(This,propertyId,value,newCondition)	\
    ( (This)->lpVtbl -> CreatePropertyCondition(This,propertyId,value,newCondition) ) 

#define IUIAutomation2_CreatePropertyConditionEx(This,propertyId,value,flags,newCondition)	\
    ( (This)->lpVtbl -> CreatePropertyConditionEx(This,propertyId,value,flags,newCondition) ) 

#define IUIAutomation2_CreateAndCondition(This,condition1,condition2,newCondition)	\
    ( (This)->lpVtbl -> CreateAndCondition(This,condition1,condition2,newCondition) ) 

#define IUIAutomation2_CreateAndConditionFromArray(This,conditions,newCondition)	\
    ( (This)->lpVtbl -> CreateAndConditionFromArray(This,conditions,newCondition) ) 

#define IUIAutomation2_CreateAndConditionFromNativeArray(This,conditions,conditionCount,newCondition)	\
    ( (This)->lpVtbl -> CreateAndConditionFromNativeArray(This,conditions,conditionCount,newCondition) ) 

#define IUIAutomation2_CreateOrCondition(This,condition1,condition2,newCondition)	\
    ( (This)->lpVtbl -> CreateOrCondition(This,condition1,condition2,newCondition) ) 

#define IUIAutomation2_CreateOrConditionFromArray(This,conditions,newCondition)	\
    ( (This)->lpVtbl -> CreateOrConditionFromArray(This,conditions,newCondition) ) 

#define IUIAutomation2_CreateOrConditionFromNativeArray(This,conditions,conditionCount,newCondition)	\
    ( (This)->lpVtbl -> CreateOrConditionFromNativeArray(This,conditions,conditionCount,newCondition) ) 

#define IUIAutomation2_CreateNotCondition(This,condition,newCondition)	\
    ( (This)->lpVtbl -> CreateNotCondition(This,condition,newCondition) ) 

#define IUIAutomation2_AddAutomationEventHandler(This,eventId,element,scope,cacheRequest,handler)	\
    ( (This)->lpVtbl -> AddAutomationEventHandler(This,eventId,element,scope,cacheRequest,handler) ) 

#define IUIAutomation2_RemoveAutomationEventHandler(This,eventId,element,handler)	\
    ( (This)->lpVtbl -> RemoveAutomationEventHandler(This,eventId,element,handler) ) 

#define IUIAutomation2_AddPropertyChangedEventHandlerNativeArray(This,element,scope,cacheRequest,handler,propertyArray,propertyCount)	\
    ( (This)->lpVtbl -> AddPropertyChangedEventHandlerNativeArray(This,element,scope,cacheRequest,handler,propertyArray,propertyCount) ) 

#define IUIAutomation2_AddPropertyChangedEventHandler(This,element,scope,cacheRequest,handler,propertyArray)	\
    ( (This)->lpVtbl -> AddPropertyChangedEventHandler(This,element,scope,cacheRequest,handler,propertyArray) ) 

#define IUIAutomation2_RemovePropertyChangedEventHandler(This,element,handler)	\
    ( (This)->lpVtbl -> RemovePropertyChangedEventHandler(This,element,handler) ) 

#define IUIAutomation2_AddStructureChangedEventHandler(This,element,scope,cacheRequest,handler)	\
    ( (This)->lpVtbl -> AddStructureChangedEventHandler(This,element,scope,cacheRequest,handler) ) 

#define IUIAutomation2_RemoveStructureChangedEventHandler(This,element,handler)	\
    ( (This)->lpVtbl -> RemoveStructureChangedEventHandler(This,element,handler) ) 

#define IUIAutomation2_AddFocusChangedEventHandler(This,cacheRequest,handler)	\
    ( (This)->lpVtbl -> AddFocusChangedEventHandler(This,cacheRequest,handler) ) 

#define IUIAutomation2_RemoveFocusChangedEventHandler(This,handler)	\
    ( (This)->lpVtbl -> RemoveFocusChangedEventHandler(This,handler) ) 

#define IUIAutomation2_RemoveAllEventHandlers(This)	\
    ( (This)->lpVtbl -> RemoveAllEventHandlers(This) ) 

#define IUIAutomation2_IntNativeArrayToSafeArray(This,array,arrayCount,safeArray)	\
    ( (This)->lpVtbl -> IntNativeArrayToSafeArray(This,array,arrayCount,safeArray) ) 

#define IUIAutomation2_IntSafeArrayToNativeArray(This,intArray,array,arrayCount)	\
    ( (This)->lpVtbl -> IntSafeArrayToNativeArray(This,intArray,array,arrayCount) ) 

#define IUIAutomation2_RectToVariant(This,rc,var)	\
    ( (This)->lpVtbl -> RectToVariant(This,rc,var) ) 

#define IUIAutomation2_VariantToRect(This,var,rc)	\
    ( (This)->lpVtbl -> VariantToRect(This,var,rc) ) 

#define IUIAutomation2_SafeArrayToRectNativeArray(This,rects,rectArray,rectArrayCount)	\
    ( (This)->lpVtbl -> SafeArrayToRectNativeArray(This,rects,rectArray,rectArrayCount) ) 

#define IUIAutomation2_CreateProxyFactoryEntry(This,factory,factoryEntry)	\
    ( (This)->lpVtbl -> CreateProxyFactoryEntry(This,factory,factoryEntry) ) 

#define IUIAutomation2_get_ProxyFactoryMapping(This,factoryMapping)	\
    ( (This)->lpVtbl -> get_ProxyFactoryMapping(This,factoryMapping) ) 

#define IUIAutomation2_GetPropertyProgrammaticName(This,property,name)	\
    ( (This)->lpVtbl -> GetPropertyProgrammaticName(This,property,name) ) 

#define IUIAutomation2_GetPatternProgrammaticName(This,pattern,name)	\
    ( (This)->lpVtbl -> GetPatternProgrammaticName(This,pattern,name) ) 

#define IUIAutomation2_PollForPotentialSupportedPatterns(This,pElement,patternIds,patternNames)	\
    ( (This)->lpVtbl -> PollForPotentialSupportedPatterns(This,pElement,patternIds,patternNames) ) 

#define IUIAutomation2_PollForPotentialSupportedProperties(This,pElement,propertyIds,propertyNames)	\
    ( (This)->lpVtbl -> PollForPotentialSupportedProperties(This,pElement,propertyIds,propertyNames) ) 

#define IUIAutomation2_CheckNotSupported(This,value,isNotSupported)	\
    ( (This)->lpVtbl -> CheckNotSupported(This,value,isNotSupported) ) 

#define IUIAutomation2_get_ReservedNotSupportedValue(This,notSupportedValue)	\
    ( (This)->lpVtbl -> get_ReservedNotSupportedValue(This,notSupportedValue) ) 

#define IUIAutomation2_get_ReservedMixedAttributeValue(This,mixedAttributeValue)	\
    ( (This)->lpVtbl -> get_ReservedMixedAttributeValue(This,mixedAttributeValue) ) 

#define IUIAutomation2_ElementFromIAccessible(This,accessible,childId,element)	\
    ( (This)->lpVtbl -> ElementFromIAccessible(This,accessible,childId,element) ) 

#define IUIAutomation2_ElementFromIAccessibleBuildCache(This,accessible,childId,cacheRequest,element)	\
    ( (This)->lpVtbl -> ElementFromIAccessibleBuildCache(This,accessible,childId,cacheRequest,element) ) 


#define IUIAutomation2_get_AutoSetFocus(This,autoSetFocus)	\
    ( (This)->lpVtbl -> get_AutoSetFocus(This,autoSetFocus) ) 

#define IUIAutomation2_put_AutoSetFocus(This,autoSetFocus)	\
    ( (This)->lpVtbl -> put_AutoSetFocus(This,autoSetFocus) ) 

#define IUIAutomation2_get_ConnectionTimeout(This,timeout)	\
    ( (This)->lpVtbl -> get_ConnectionTimeout(This,timeout) ) 

#define IUIAutomation2_put_ConnectionTimeout(This,timeout)	\
    ( (This)->lpVtbl -> put_ConnectionTimeout(This,timeout) ) 

#define IUIAutomation2_get_TransactionTimeout(This,timeout)	\
    ( (This)->lpVtbl -> get_TransactionTimeout(This,timeout) ) 

#define IUIAutomation2_put_TransactionTimeout(This,timeout)	\
    ( (This)->lpVtbl -> put_TransactionTimeout(This,timeout) ) 

#endif /* COBJMACROS */


#endif 	/* C style interface */




#endif 	/* __IUIAutomation2_INTERFACE_DEFINED__ */
Пытаюсь создать этот объект и вызвать метод "родителя" - IUIAutomation
Код:
Global Const $sCLSID_CUIAutomation = "{FF48DBA4-60EF-4201-AA87-54103EEF594E}"

; Windows 7
Global Const $sIID_IUIAutomation = "{30CBE57D-D9D0-452A-AB13-7AC5AC4825EE}"
Global $dtagIUIAutomation = "CompareElements hresult(ptr;ptr;long*);" & _
"CompareRuntimeIds hresult(ptr;ptr;long*);" & _
"GetRootElement hresult(ptr*);" & _
"ElementFromHandle hresult(hwnd;ptr*);" & _
"ElementFromPoint hresult(struct;ptr*);" & _
"GetFocusedElement hresult(ptr*);" & _
"GetRootElementBuildCache hresult(ptr;ptr*);" & _
"ElementFromHandleBuildCache hresult(hwnd;ptr;ptr*);" & _
"ElementFromPointBuildCache hresult(struct;ptr;ptr*);" & _
"GetFocusedElementBuildCache hresult(ptr;ptr*);" & _
"CreateTreeWalker hresult(ptr;ptr*);" & _
"ControlViewWalker hresult(ptr*);" & _
"ContentViewWalker hresult(ptr*);" & _
"RawViewWalker hresult(ptr*);" & _
"RawViewCondition hresult(ptr*);" & _
"ControlViewCondition hresult(ptr*);" & _
"ContentViewCondition hresult(ptr*);" & _
"CreateCacheRequest hresult(ptr*);" & _
"CreateTrueCondition hresult(ptr*);" & _
"CreateFalseCondition hresult(ptr*);" & _
"CreatePropertyCondition hresult(int;variant;ptr*);" & _
"CreatePropertyConditionEx hresult(int;variant;long;ptr*);" & _
"CreateAndCondition hresult(ptr;ptr;ptr*);" & _
"CreateAndConditionFromArray hresult(ptr;ptr*);" & _
"CreateAndConditionFromNativeArray hresult(ptr;int;ptr*);" & _
"CreateOrCondition hresult(ptr;ptr;ptr*);" & _
"CreateOrConditionFromArray hresult(ptr;ptr*);" & _
"CreateOrConditionFromNativeArray hresult(ptr;int;ptr*);" & _
"CreateNotCondition hresult(ptr;ptr*);" & _
"AddAutomationEventHandler hresult(int;ptr;long;ptr;ptr);" & _
"RemoveAutomationEventHandler hresult(int;ptr;ptr);" & _
"AddPropertyChangedEventHandlerNativeArray hresult(ptr;long;ptr;ptr;struct*;int);" & _
"AddPropertyChangedEventHandler hresult(ptr;long;ptr;ptr;ptr);" & _
"RemovePropertyChangedEventHandler hresult(ptr;ptr);" & _
"AddStructureChangedEventHandler hresult(ptr;long;ptr;ptr);" & _
"RemoveStructureChangedEventHandler hresult(ptr;ptr);" & _
"AddFocusChangedEventHandler hresult(ptr;ptr);" & _
"RemoveFocusChangedEventHandler hresult(ptr);" & _
"RemoveAllEventHandlers hresult();" & _
"IntNativeArrayToSafeArray hresult(int;int;ptr*);" & _
"IntSafeArrayToNativeArray hresult(ptr;int*;int*);" & _
"RectToVariant hresult(struct;variant*);" & _
"VariantToRect hresult(variant;struct*);" & _
"SafeArrayToRectNativeArray hresult(ptr;struct*;int*);" & _
"CreateProxyFactoryEntry hresult(ptr;ptr*);" & _
"ProxyFactoryMapping hresult(ptr*);" & _
"GetPropertyProgrammaticName hresult(int;bstr*);" & _
"GetPatternProgrammaticName hresult(int;bstr*);" & _
"PollForPotentialSupportedPatterns hresult(ptr;ptr*;ptr*);" & _
"PollForPotentialSupportedProperties hresult(ptr;ptr*;ptr*);" & _
"CheckNotSupported hresult(variant;long*);" & _
"ReservedNotSupportedValue hresult(ptr*);" & _
"ReservedMixedAttributeValue hresult(ptr*);" & _
"ElementFromIAccessible hresult(idispatch;int;ptr*);" & _
"ElementFromIAccessibleBuildCache hresult(iaccessible;int;ptr;ptr*);"

; Windows 8
Global Const $sIID_IUIAutomation2 = "{34723AFF-0C9D-49D0-9896-7AB52DF8CD8A}"
Global $dtagIUIAutomation2 = $dtagIUIAutomation & _
"get_AutoSetFocus hresult(long*);" & _
"put_AutoSetFocus hresult(long);" & _
"get_ConnectionTimeout hresult(dword*);" & _
"put_ConnectionTimeout hresult(dword);" & _
"get_TransactionTimeout hresult(dword*);" & _
"put_TransactionTimeout hresult(dword);"

; Создание объектов
$oUIAutomation = ObjCreateInterface($sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation)
If Not IsObj($oUIAutomation) Then Exit ConsoleWrite("Ошибка создания объекта UIAutomation" & @CRLF)
$oUIAutomation2 = ObjCreateInterface($oUIAutomation, $sIID_IUIAutomation2, $dtagIUIAutomation2)
If Not IsObj($oUIAutomation2) Then Exit ConsoleWrite("Ошибка создания объекта UIAutomation2" & @CRLF)

; Вызов методов
Global $Dword, $hWnd = WinGetHandle(""), $pElement, $pElement2

$oUIAutomation.ElementFromHandle($hWnd, $pElement)
ConsoleWrite("$pElement : " & $pElement & @CRLF)

$oUIAutomation2.ElementFromHandle($hWnd, $pElement2)
ConsoleWrite("$pElement2 : " & $pElement2 & @CRLF)
$oUIAutomation2.get_ConnectionTimeout($Dword)
ConsoleWrite($Dword & @CRLF)
Проверяю на Win10. Этим способом объект не создаётся. Если добавить False
Код:
$oUIAutomation2 = ObjCreateInterface($oUIAutomation, $sIID_IUIAutomation2, $dtagIUIAutomation2, False)
то какой-то объект создаётся, но вызов методов приводит к ошибке.
 

inververs

AutoIT Гуру
Сообщения
2,135
Репутация
465
Все правильно у вас, может в вин10 этот интерфейс не поддерживается? а на win8 работает?
Код:
Local $hr = $oUIAutomation.QueryInterface($sIID_IUIAutomation2, $uiua2)
ConsoleWrite(Hex($hr) & @CRLF)

Возвращает 80004002 - интерфейс не поддерживается.
У меня тоже не заработало Win10


Добавлено:
Сообщение автоматически объединено:

А все понял, смотри https://msdn.microsoft.com/en-us/library/windows/desktop/hh448746(v=vs.85).aspx
Сделали новый класс CUIAutomation8, поэтому:
Код:
Global Const $sCLSID_CUIAutomation8 = "{e22ad333-b25f-460c-83d0-0581107395c9}"
$oUIAutomation2 = ObjCreateInterface($sCLSID_CUIAutomation8, $sIID_IUIAutomation2, $dtagIUIAutomation2)
 
Верх