Jump to content
Bilgus

ITypeInfo to extract information about the characteristics and capabilities of objects from type libraries

Recommended Posts

Bilgus
Posted (edited)

I was Playing around With AutoIt this evening and wondered how hard it would be to get typeinfo like the COM Viewers do only using AutoIt

Turns out it was pretty easy.

A Few Notes:

CAarray info is unfinished I didn't have any objects to test it on so I left it Limited.

The Object must have IDispatch exposed (ITypeInfo is derivative)

Its Just a proof of concept Run with it but don't carry scissors

ITypeInfoCOM.au3

Spoiler
;Bilgus 2018
;ITypeInfoCOM
#include <WinAPI.au3>

; === IDispatch interface ===

; http://msdn.microsoft.com/en-us/library/windows/desktop/ms221608(v=vs.85).aspx

; Exposes objects, methods and properties to programming tools and other applications that support Automation.
; COM components implement the IDispatch interface to enable access by Automation clients, such as Visual Basic.

Global Const $sIID_IDispatch = "{00020400-0000-0000-C000-000000000046}"
Global Const $dtag_IDispatch = _
        "GetTypeInfoCount hresult(dword*);" & _ ; Retrieves the number of type information interfaces that an object provides (either 0 or 1).
        "GetTypeInfo hresult(dword;dword;ptr*);" & _ ; Gets the type information for an object.
        "GetIDsOfNames hresult(ptr;ptr;dword;dword;ptr);" & _ ; Maps a single member and an optional set of argument names to a corresponding set of integer DISPIDs, which can be used on subsequent calls to Invoke.
        "Invoke hresult(dword;ptr;dword;word;ptr;ptr;ptr;ptr);" ; Provides access to properties and methods exposed by an object.

; === ITypeInfo interface ===

;https://msdn.microsoft.com/en-us/library/windows/desktop/ms221696(v=vs.85).aspx

;Used for reading information about objects.
;For example, an object browser tool can use ITypeInfo to extract information about the characteristics and capabilities of objects from type libraries

Global Const $sIID_ITypeInfo = "{00020401-0000-0000-C000-000000000046}"
Global Const $tRIID_ITypeInfo = _WinAPI_GUIDFromString($sIID_ITypeInfo)

Global Const $dtag_ITypeInfo = _
        "GetTypeAttr hresult(ptr*);" & _ ;Retrieves a TYPEATTR structure that contains the attributes of the type description
        "GetTypeComp hresult(ptr*);" & _ ;Retrieves the ITypeComp interface for the type description, which enables a client compiler to bind to the type description's members
        "GetFuncDesc hresult(uint;ptr*;);" & _ ;Retrieves the FUNCDESC structure that contains information about a specified function
        "GetVarDesc hresult(uint;ptr*);" & _ ;Retrieves a VARDESC structure that describes the specified variable
        "GetNames hresult(long;ptr;uint;uint*);" & _ ;Retrieves the variable with the specified member ID or the name of the property or method and the parameters that correspond to the specified function ID
        "GetRefTypeOfImplType hresult(dword;ptr);" & _ ;If a type description describes a COM class, it retrieves the type description of the implemented interface types
        "GetImplTypeFlags hresult(uint;int*);" & _ ;Retrieves the IMPLTYPEFLAGS enumeration for one implemented interface or base interface in a type description
        "GetIDsOfNames hresult(ptr;uint;long*);" & _ ;Maps between member names and member IDs, and parameter names and parameter IDs
        "Invoke hresult(ptr;long;word;ptr;ptr;ptr;uint*);" & _ ;Invokes a method, or accesses a property of an object, that implements the interface described by the type description
        "GetDocumentation hresult(long;ptr;ptr;dword*;ptr);" & _ ;Retrieves the documentation string, the complete Help file name and path, and the context ID for the Help topic for a specified type description
        "GetDllEntry hresult(long;int;ptr;ptr;word*);" & _ ;Retrieves a description or specification of an entry point for a function in a DLL
        "GetRefTypeInfo hresult(dword;ptr*);" & _ ;If a type description references other type descriptions, it retrieves the referenced type descriptions
        "AddressOfMember hresult(long;int;ptr);" & _ ;Retrieves the addresses of static functions or variables, such as those defined in a DLL
        "CreateInstance hresult(ptr;clsid;ptr);" & _ ;Creates a new instance of a type that describes a component object class (coclass)
        "GetMops hresult(long;ptr);" & _ ;Retrieves marshaling information
        "GetContainingTypeLib hresult(ptr;uint*);" & _ ;Retrieves the containing type library and the index of the type description within that type library
        "ReleaseTypeAttr none(ptr);" & _ ;Releases a TYPEATTR previously returned by ITypeInfo::GetTypeAttr
        "ReleaseFuncDesc none(ptr);" & _ ;Releases a FUNCDESC previously returned by ITypeInfo::GetFuncDesc
        "ReleaseVarDesc none(ptr);" ;Releases a VARDESC previously returned by ITypeInfo::GetVarDesc

Global Enum $VT_EMPTY = 0, $VT_NULL = 1, $VT_I2 = 2, $VT_I4 = 3, $VT_R4 = 4, _
        $VT_R8 = 5, $VT_CY = 6, $VT_DATE = 7, $VT_BSTR = 8, $VT_DISPATCH = 9, _
        $VT_ERROR = 10, $VT_BOOL = 11, $VT_VARIANT = 12, $VT_UNKNOWN = 13, _
        $VT_DECIMAL = 14, $VT_I1 = 16, $VT_UI1 = 17, $VT_UI2 = 18, $VT_UI4 = 19, _
        $VT_I8 = 20, $VT_UI8 = 21, $VT_INT = 22, $VT_UINT = 23, $VT_VOID = 24, _
        $VT_HRESULT = 25, $VT_PTR = 26, $VT_SAFEARRAY = 27, $VT_CARRAY = 28, _
        $VT_USERDEFINED = 29, $VT_LPSTR = 30, $VT_LPWSTR = 31, $VT_FILETIME = 64, _
        $VT_BLOB = 65, $VT_STREAM = 66, $VT_STORAGE = 67, $VT_STREAMED_OBJECT = 68, _
        $VT_STORED_OBJECT = 69, $VT_BLOB_OBJECT = 70, $VT_CF = 71, $VT_CLSID = 72, _
        $VT_VECTOR = 0x1000, $VT_ARRAY = 0x2000, $VT_BYREF = 0x4000, $VT_RESERVED = 0x8000, _
        $VT_ILLEGAL = 0xffff, $VT_ILLEGALMASKED = 0xfff, $VT_TYPEMASK = 0xfff

Global Enum Step *2 $TYPEFLAG_FAPPOBJECT = 0x1, $TYPEFLAG_FCANCREATE, $TYPEFLAG_FLICENSED, _
        $TYPEFLAG_FPREDECLID, $TYPEFLAG_FHIDDEN, $TYPEFLAG_FCONTROL, $TYPEFLAG_FDUAL, _
        $TYPEFLAG_FNONEXTENSIBLE, $TYPEFLAG_FOLEAUTOMATION, $TYPEFLAG_FRESTRICTED, _
        $TYPEFLAG_FAGGREGATABLE, $TYPEFLAG_FREPLACEABLE, $TYPEFLAG_FDISPATCHABLE, _
        $TYPEFLAG_FREVERSEBIND, $TYPEFLAG_FPROXY

Global Const $tagIDLDESC = "STRUCT;dword dwRESERVEDIDL;ushort wIDLFlags;ENDSTRUCT;"

Global Const $tagTYPEDESC = "STRUCT;ptr lpdesc;ushort vt;ENDSTRUCT;"
Global Const $tagTYPEDESC_HREF = "dword hreftype;" ; &UNION^

Global Const $tagPARAMDESC = "STRUCT;ptr pparamdescex;ushort wParamFlags;ENDSTRUCT;"

Global Const $tagELEMDESC = "STRUCT;" & $tagTYPEDESC & $tagPARAMDESC & "ENDSTRUCT;" ;&UNIONS
Global Const $SIZEOF_tagElemDesc = DllStructGetSize(DllStructCreate($tagELEMDESC))

Global Const $tagTYPEATTR = _
        "STRUCT;" & _
        $tagGUID & _
        ";dword lcid;" & _
        "dword dwReserved;" & _
        "long memidConstructor;" & _
        "long memidDestructor;" & _
        "ptr lpstrSchema;" & _
        "ulong cbSizeInstance;" & _
        "int typekind;" & _
        "word cFuncs;" & _
        "word cVars;" & _
        "word cImplTypes;" & _
        "word cbSizeVft;" & _
        "word cbAlignment;" & _
        "word wTypeFlags;" & _
        "word wMajorVerNum;" & _
        "word wMinorVerNum;" & _
        $tagTYPEDESC & _
        $tagIDLDESC & _
        "ENDSTRUCT;"

Global Const $tagFUNCDESC = _
        "STRUCT;" & _
        "long memid;" & _
        "ptr lprgscode;" & _
        "ptr lprgelemdescParam;" & _
        "int funckind;" & _
        "int invkind;" & _
        "int callconv;" & _
        "short cParams;" & _
        "short cParamsOpt;" & _
        "short oVft;" & _
        "short cScodes;" & _
        $tagELEMDESC & _
        "word wFuncFlags;" & _
        "ENDSTRUCT;"

Func __SysFreeString($pBstr)
    DllCall("OleAut32.dll", "NONE", "SysFreeString", "ptr", $pBstr)
    Return SetError(@error, 0, (@error = 0))
EndFunc   ;==>__SysFreeString

Func Extract_Interface_Functions(ByRef $oITypeInfo)
    ;Returns Functions and their parameters in AutoIt Array => return_type Function (int, uint*,Custom_TYPE...)
    Local $iResult, $iCtFuncs
    Local $aFunctions[0]

    Local $tTypeAttr = Get_ITypeInfo_Attr($oITypeInfo)

    If (Not @error) Then
        $iCtFuncs = DllStructGetData($tTypeAttr, "cFuncs") ;How many functions
        ReDim $aFunctions[$iCtFuncs] ;Init our Function array

        $oITypeInfo.ReleaseTypeAttr(DllStructGetPtr($tTypeAttr)) ;Important! Release TYPEATTR
    EndIf

    For $i = 0 To $iCtFuncs - 1
        Local $sReturnType, $sFunctionName, $sParameterTypes
        Local $pFuncDesc, $sPrefix

        $iResult = $oITypeInfo.GetFuncDesc($i, $pFuncDesc) ;Get Pointer to FUNCDESC
        If (Not $iResult) And $pFuncDesc Then
            Local $tFuncDesc = DllStructCreate($tagFUNCDESC, $pFuncDesc)
            Local $iCtParams = DllStructGetData($tFuncDesc, "cParams") ;How many parameters (arguments)

            $sFunctionName = Get_FunctionName(DllStructGetData($tFuncDesc, "memid"), $oITypeInfo) ;Member ID identifies function

            If (Not @error) Then
                $sReturnType = StringifyTypeDesc(DllStructGetPtr($tFuncDesc, "lpdesc"), $oITypeInfo) ;Return Type

                If DllStructGetData($tFuncDesc, "invkind") = 2 Then
                    $sPrefix = "get_"
                ElseIf DllStructGetData($tFuncDesc, "invkind") = 4 Then
                    $sPrefix = "set_"
                Else
                    $sPrefix = ""
                EndIf

                $sFunctionName = $sPrefix & $sFunctionName ;Add get or set on getters/setters

                $sParameterTypes = Get_ParameterList(DllStructGetData($tFuncDesc, "lprgelemdescParam"), $iCtParams, $oITypeInfo)

                $aFunctions[$i] = $sReturnType & " " & $sFunctionName & " (" & $sParameterTypes & ")"
            EndIf

            $oITypeInfo.ReleaseFuncDesc($pFuncDesc) ;Important! Release FUNCDESC
        Else
            ConsoleWriteError("Error Retrieving Function Description: " & Hex($iResult) & @CRLF)
        EndIf
    Next
    Return $aFunctions
EndFunc   ;==>Extract_Interface_Functions

Func Get_FunctionName($iMemberId, $oITypeInfo)
    Local $iError, $sFunctionName, $iResult

    Local $aWstrName = WstrCreate_pp() ;**WSTR
    Local $ppWstr = WstrGetPointer_pp($aWstrName)
    If (Not @error) Then
        $iResult = $oITypeInfo.GetDocumentation($iMemberId, $ppWstr, Null, Null, Null) ;Get the Function Name
    EndIf

    If (Not @error) And (Not $iResult) And $aWstrName[0] Then
        $sFunctionName = WstrExtract_pp($aWstrName) ;Function Name **WSTR
        __SysFreeString($aWstrName[0]) ; Free the BSTR
    Else
        $iError = 1
    EndIf
    Return SetError($iError, $iResult, $sFunctionName)
EndFunc   ;==>Get_FunctionName

Func Get_ITypeInfo_Attr(ByRef $oITypeInfo)
    ;Retrieves $tTypeAttr
    Local $tTypeAttr, $pTypeAttr, $iError

    If (Not $oITypeInfo.GetTypeAttr($pTypeAttr)) And $pTypeAttr Then
        $tTypeAttr = DllStructCreate($tagTYPEATTR, $pTypeAttr)
    Else
        $iError = 1
    EndIf

    Return SetError($iError, 0, $tTypeAttr)
EndFunc   ;==>Get_ITypeInfo_Attr

Func Get_ITypeInfo_Interface($oObject)
    ;Retrieves $oITypeInfo
    Local $iError, $iResult
    Local $pITypeInfo, $oITypeInfo

    While True
        If (Not IsObj($oObject)) Then
            ConsoleWrite("Init Error: Invalid Object")
            $iError = 1
            ExitLoop
        EndIf

        If ObjName($oObject, 1) <> "InterfaceDispatch" Then
            $oObject = ObjCreateInterface($oObject, $sIID_IDispatch, $dtag_IDispatch) ;Try To get IDispatch
        EndIf

        If ObjName($oObject, 1) <> "InterfaceDispatch" Then
            ConsoleWrite("Init Error: Not InterfaceDispatch based")
            $iError = 2
            ExitLoop
        EndIf

        $iResult = $oObject.GetTypeInfo(0, 0, $pITypeInfo)
        If $pITypeInfo Then $oITypeInfo = ObjCreateInterface($pITypeInfo, $sIID_ITypeInfo, $dtag_ITypeInfo)

        If $iResult Or (Not IsObj($oITypeInfo)) Then
            ConsoleWrite("Init Error: Failed to retrieve interface")
            $iError = 3
            ExitLoop
        EndIf
        ExitLoop
    WEnd
    Return SetError($iError, $iResult, $oITypeInfo)
EndFunc   ;==>Get_ITypeInfo_Interface

Func Get_ParameterList($pElemDesc, $iCtParams, $oITypeInfo)
    Local $sParameterTypes, $sType
    For $i = 0 To $iCtParams - 1
        ;We have to manually move the pointer by $SIZEOF_tagElemDesc for each parameter
        $sType = StringifyTypeDesc($pElemDesc + ($i * $SIZEOF_tagElemDesc), $oITypeInfo)
        If $i > 0 Then $sParameterTypes &= ", "
        $sParameterTypes &= $sType ;Param type
    Next
    Return $sParameterTypes
EndFunc   ;==>Get_ParameterList

Func StringifyCustomType($pTypeDesc_hRef, ByRef $oITypeInfo)
    ;Sean Baxter, COM Automation: Type Information (Part II)
    ;http://yanaware.com/com4me/typeinfo2.php-author=Sean%20BAXTER&mail=spec@ript.net&url=http---ript.net-~spec-&idTute=13.htm
    Local $sString = "UnknownCustomType"
    ;$tagTYPEDESC_HREF is Union with $tagTYPEDESC
    Local $tTypeDesc_hRef = DllStructCreate($tagTYPEDESC_HREF, $pTypeDesc_hRef)

    Local $iHrefType = DllStructGetData($tTypeDesc_hRef, "hreftype")

    Local $pCustTypeInfo

    While $iHrefType

        If $oITypeInfo.GetRefTypeInfo($iHrefType, $pCustTypeInfo) Or (Not $pCustTypeInfo) Then ExitLoop

        Local $oITypeInfo_Custom = ObjCreateInterface($pCustTypeInfo, $sIID_ITypeInfo, $dtag_ITypeInfo)

        If IsObj($oITypeInfo_Custom) Then
            Local $aWstrName = WstrCreate_pp() ;**WSTR

            Local $ppWstr = WstrGetPointer_pp($aWstrName)
            If @error Then ExitLoop

            If $oITypeInfo_Custom.GetDocumentation(-1, $ppWstr, Null, Null, Null) Then ExitLoop
            $sString = WstrExtract_pp($aWstrName) ;Parameter Name **WSTR
        EndIf
        ExitLoop
    WEnd

    Return $sString

EndFunc   ;==>StringifyCustomType

Func StringifyTypeDesc($pElemDesc, ByRef $oITypeInfo)
    ;Sean Baxter, COM Automation: Type Information (Part II)
    ;http://yanaware.com/com4me/typeinfo2.php-author=Sean%20BAXTER&mail=spec@ript.net&url=http---ript.net-~spec-&idTute=13.htm
    Local $tElemDesc = DllStructCreate($tagELEMDESC, $pElemDesc)

    Local $iVariantType = BitAND(DllStructGetData($tElemDesc, "vt"), 0xFFFF)

    If $iVariantType = $VT_PTR Then
        Return StringifyTypeDesc(DllStructGetData($tElemDesc, "lpdesc"), $oITypeInfo) & "*"

    ElseIf $iVariantType = $VT_SAFEARRAY Then
        Return "SAFEARRAY( " & StringifyTypeDesc(DllStructGetData($tElemDesc, "lpdesc"), $oITypeInfo) * ")"

    ElseIf $iVariantType = $VT_CARRAY Then
        ;Not Finished...Needs Sizes
        ;oss<< StringifyTypeDesc(&typeDesc->lpadesc->tdescElem, pTypeInfo);
        ;for(int dim(0); typeDesc->lpadesc->cDims; ++dim)
        ;    oss<< '['<< typeDesc->lpadesc->rgbounds[dim].lLbound<< "..."
        ;        << (typeDesc->lpadesc->rgbounds[dim].cElements +
        ;        typeDesc->lpadesc->rgbounds[dim].lLbound - 1)<< ']';
        ;return oss.str();
        MsgBox(0, "CARRAY", "Not Finished...Needs Sizes")
        Return "CARRAY " & StringifyTypeDesc(DllStructGetData($tElemDesc, "lpdesc"), $oITypeInfo)

    ElseIf $iVariantType = $VT_USERDEFINED Then
        Return StringifyCustomType($pElemDesc, $oITypeInfo)
    EndIf

    Return VariantArgToString($iVariantType)
EndFunc   ;==>StringifyTypeDesc

Func VariantArgToString($iVariantType)
    Switch ($iVariantType)
        ;VARIANT/VARIANTARG compatible types
        Case $VT_I2
            Return "short"
        Case $VT_I4
            Return "long"
        Case $VT_R4
            Return "float"
        Case $VT_R8
            Return "double"
        Case $VT_CY
            Return "CY"
        Case $VT_DATE
            Return "date"
        Case $VT_BSTR
            Return "bstr"
        Case $VT_DISPATCH
            Return "IDispatch*"
        Case $VT_ERROR
            Return "scode"
        Case $VT_BOOL
            Return "VARIANT_BOOL"
        Case $VT_VARIANT
            Return "variant"
        Case $VT_UNKNOWN
            Return "IUnknown*"
        Case $VT_DECIMAL
            Return "decimal"
        Case $VT_I1
            Return "char"
        Case $VT_UI1
            Return "byte"
        Case $VT_UI2
            Return "ushort"
        Case $VT_UI4
            Return "ulong"
        Case $VT_I8
            Return "int64"
        Case $VT_UI8
            Return "uint64"
        Case $VT_INT
            Return "int"
        Case $VT_UINT
            Return "UINT"
        Case $VT_VOID
            Return "void"
        Case $VT_HRESULT
            Return "hresult"
        Case $VT_LPSTR
            Return "char*"
        Case $VT_LPWSTR
            Return "wchar_t*"
        Case Else
            Return "!ERROR!"
    EndSwitch
EndFunc   ;==>VariantArgToString

Func WstrCreate_pp()
    ;Creates a Pointer to Pointer to **WSTR
    Local $aWstrObj[2]
    $aWstrObj[1] = DllStructCreate("ptr pointer")
    $aWstrObj[0] = DllStructGetPtr($aWstrObj[1])
    Return $aWstrObj
EndFunc   ;==>WstrCreate_pp

Func WstrGetPointer_pp($aWstrObj)
    Local $pPointer = 0, $iError
    If UBound($aWstrObj) = 2 Then
        $pPointer = $aWstrObj[0]
    EndIf

    If (Not IsPtr($pPointer)) Then
        $iError = 1
        $pPointer = 0
    EndIf
    Return SetError($iError, 0, $pPointer)
EndFunc   ;==>WstrGetPointer_pp

Func WstrExtract_pp($aWstrObj)
    ;Extracts Wstr from pointer to pointer to **WSTR
    Local $sString
    If UBound($aWstrObj) = 2 Then
        Local $pPointer = DllStructGetData($aWstrObj[1], "pointer")
        If IsPtr($pPointer) Then
            Local $tWstr = DllStructCreate("wchar data[65536]", $pPointer)
            $sString = DllStructGetData($tWstr, "data")
        EndIf
    EndIf
    Return $sString
EndFunc   ;==>WstrExtract_pp

 

ITypeInfoTest.au3

Spoiler
;TypeInfo
#include <ITypeInfoCOM.au3>
#include <array.au3>

Global Const $sCLSID_HNetCfg_FwPolicy2 = "{E2B3C97F-6AE1-41AC-817A-F6F92166D7DD}"
Global Const $sIID_INetFwPolicy2 = "{98325047-C671-4174-8D81-DEFCD3F03186}"
;Global $oObject = ObjCreateInterface($sCLSID_HNetCfg_FwPolicy2, $sIID_INetFwPolicy2, $dtag_IDispatch)

Global Const $sCLSID_HNetCfg_FwRule = "{2C5BC43E-3369-4C33-AB0C-BE9469677AF4}"
Global Const $sIID_INetFwRule2 = "{9C27C8DA-189B-4DDE-89F7-8B39A316782C}"
;Global $oObject = ObjCreateInterface($sCLSID_HNetCfg_FwRule, $sIID_INetFwRule2, $dtag_IDispatch)

Global Const $sCLSID_ShellWindows  = "{9BA05972-F6A8-11CF-A442-00A0C90A8F39}"
Global Const $sIID_IShellWindows  = "{85CB6900-4D95-11CF-960C-0080C7F4EE85}"
;Global $oObject = ObjCreateInterface($sCLSID_ShellWindows, $sIID_IShellWindows, $dtag_IDispatch)

Global Const $sCLSID_InternetExplorerV1 = "{0002DF01-0000-0000-C000-000000000046}"
Global Const $sIID_IWebBrowserApp  = "{0002DF05-0000-0000-C000-000000000046}"
;Global $oObject = ObjCreateInterface($sCLSID_InternetExplorerV1, $sIID_IWebBrowserApp, $dtag_IDispatch)

Global Const $sIID_IWebBrowser  = "{EAB22AC1-30C1-11CF-A7EB-0000C05BAE0B}"
;Global $oObject = ObjCreateInterface($sCLSID_InternetExplorerV1, $sIID_IWebBrowser, $dtag_IDispatch)

Global Const $sIID_IWebBrowser2  = "{D30C1661-CDAF-11D0-8A3E-00C04FC9E26E}"
;Global $oObject = ObjCreateInterface($sCLSID_InternetExplorerV1, $sIID_IWebBrowser2, $dtag_IDispatch)

Global Const $sCLSID_MSDDSIconControl80 = "{77D2C926-7779-11D8-9070-00065B840D9C}"
Global Const $sIID_IDdsIcon = "{77D2C924-7779-11D8-9070-00065B840D9C}"
;Global $oObject = ObjCreateInterface($sCLSID_MSDDSIconControl80, $sIID_IDdsIcon, $dtag_IDispatch)


;Global $oObject = ObjCreate("HNetCfg.FwMgr")
;Global $oObject = ObjCreate("HNetCfg.FwRule")
;Global $oObject = ObjCreate("HNetCfg.FwPolicy2")
;Global $oObject = ObjCreate("shell.application")
Global $oObject = ObjCreate("MediaPlayer.MediaPlayer.1")

Local $oITypeInfo = Get_ITypeInfo_Interface($oObject)

Local $tTypeAttr = Get_ITypeInfo_Attr($oITypeInfo)

Local $aTypeAttr = TypeAttrToArray($tTypeAttr)
$oITypeInfo.ReleaseTypeAttr(DllStructGetPtr($tTypeAttr)) ;Don't Forget to free

ConsoleWrite("Type Attributes:" & @CRLF)
ConsoleWrite(PrintArray($aTypeAttr) & @CRLF)

Local $aFunctions = Extract_Interface_Functions($oITypeInfo)
ConsoleWrite("Functions:" & @CRLF)
ConsoleWrite(PrintArray($aFunctions) & @CRLF)

Exit

Func AlignmentToString($iAlignment)
    Local $sAlignment
    Switch $iAlignment
        Case 0
            $sAlignment = "64K Boundary"
        Case 1
            $sAlignment = "Normal"
        Case Else
            $sAlignment = "Align on Byte " & $iAlignment
    EndSwitch
    Return $sAlignment
EndFunc   ;==>AlignmentToString

Func PrintArray($aArr)
    $sRet = ""
    If IsArray($aArr) Then
        For $i = 0 To UBound($aArr) - 1
            $sRet &= $aArr[$i] & @CRLF
        Next
    EndIf
    Return $sRet
EndFunc   ;==>PrintArray

Func TypeAttrToArray($tTypeAttr)
    Local $aTypeAttr[9]
    $aTypeAttr[0] = "IId = " & _WinAPI_StringFromGUID(DllStructGetPtr($tTypeAttr, "Data1"))
    $aTypeAttr[1] = "Type Kind = " & TypeKindToString(DllStructGetData($tTypeAttr, "typekind"))
    $aTypeAttr[2] = "Functions = " & DllStructGetData($tTypeAttr, "cFuncs")
    $aTypeAttr[3] = "Variables = " & DllStructGetData($tTypeAttr, "cVars")
    $aTypeAttr[4] = "Interfaces = " & DllStructGetData($tTypeAttr, "cImplTypes")
    $aTypeAttr[5] = "Type Flags = " & TypeFlagsToString(DllStructGetData($tTypeAttr, "wTypeFlags"))
    $aTypeAttr[6] = "VTBL Sz = " & DllStructGetData($tTypeAttr, "cbSizeVft")
    $aTypeAttr[7] = "Alignment = " & AlignmentToString(DllStructGetData($tTypeAttr, "cbAlignment"))
    $aTypeAttr[8] = "Ver = " & DllStructGetData($tTypeAttr, "wMajorVerNum") & "." & DllStructGetData($tTypeAttr, "wMinorVerNum")
    Return $aTypeAttr
EndFunc   ;==>TypeAttrToArray

Func TypeFlagsToString($iTypeFlags)
    Local $sTypeFlags
    $sTypeFlags &= (BitAND($iTypeFlags, $TYPEFLAG_FAPPOBJECT) ? "APPOBJECT " : "")
    $sTypeFlags &= (BitAND($iTypeFlags, $TYPEFLAG_FCANCREATE) ? "CANCREATE " : "")
    $sTypeFlags &= (BitAND($iTypeFlags, $TYPEFLAG_FLICENSED) ? "LICENSED " : "")
    $sTypeFlags &= (BitAND($iTypeFlags, $TYPEFLAG_FPREDECLID) ? "PREDECLID " : "")
    $sTypeFlags &= (BitAND($iTypeFlags, $TYPEFLAG_FHIDDEN) ? "HIDDEN " : "")
    $sTypeFlags &= (BitAND($iTypeFlags, $TYPEFLAG_FCONTROL) ? "CONTROL " : "")
    $sTypeFlags &= (BitAND($iTypeFlags, $TYPEFLAG_FDUAL) ? "DUAL " : "")
    $sTypeFlags &= (BitAND($iTypeFlags, $TYPEFLAG_FNONEXTENSIBLE) ? "NONEXTENSIBLE " : "")
    $sTypeFlags &= (BitAND($iTypeFlags, $TYPEFLAG_FOLEAUTOMATION) ? "OLEAUTOMATION " : "")
    $sTypeFlags &= (BitAND($iTypeFlags, $TYPEFLAG_FRESTRICTED) ? "RESTRICTED " : "")
    $sTypeFlags &= (BitAND($iTypeFlags, $TYPEFLAG_FAGGREGATABLE) ? "AGGREGATABLE " : "")
    $sTypeFlags &= (BitAND($iTypeFlags, $TYPEFLAG_FREPLACEABLE) ? "REPLACEABLE " : "")
    $sTypeFlags &= (BitAND($iTypeFlags, $TYPEFLAG_FDISPATCHABLE) ? "DISPATCHABLE " : "")
    $sTypeFlags &= (BitAND($iTypeFlags, $TYPEFLAG_FREVERSEBIND) ? "REVERSEBIND " : "")
    $sTypeFlags &= (BitAND($iTypeFlags, $TYPEFLAG_FPROXY) ? "PROXY" : "")
    Return $sTypeFlags
EndFunc   ;==>TypeFlagsToString

Func TypeKindToString($iTypeKind)
    If $iTypeKind < 0 Or $iTypeKind > 8 Then Return "ERROR"
    Local $aTypeKind[9] = ["ENUM", "RECORD", "MODULE", "INTERFACE", "DISPATCH", "COCLASS", "ALIAS", "UNION", "MAX"]
    Return $aTypeKind[$iTypeKind]
EndFunc   ;==>TypeKindToString

 

 

Output IWebBrowserApp

Spoiler

Type Attributes:
IId = {D30C1661-CDAF-11D0-8A3E-00C04FC9E26E}
Type Kind = INTERFACE
Functions = 19
Variables = 0
Interfaces = 1
Type Flags = HIDDEN DUAL OLEAUTOMATION DISPATCHABLE 
VTBL Sz = 284
Alignment = Align on Byte 4
Ver = 0.0

Functions:
hresult Navigate2 (variant*, variant*, variant*, variant*, variant*)
hresult QueryStatusWB (OLECMDID, OLECMDF*)
hresult ExecWB (OLECMDID, OLECMDEXECOPT, variant*, variant*)
hresult ShowBrowserBar (variant*, variant*, variant*)
hresult get_ReadyState (tagREADYSTATE*)
hresult get_Offline (VARIANT_BOOL*)
hresult set_Offline (VARIANT_BOOL)
hresult get_Silent (VARIANT_BOOL*)
hresult set_Silent (VARIANT_BOOL)
hresult get_RegisterAsBrowser (VARIANT_BOOL*)
hresult set_RegisterAsBrowser (VARIANT_BOOL)
hresult get_RegisterAsDropTarget (VARIANT_BOOL*)
hresult set_RegisterAsDropTarget (VARIANT_BOOL)
hresult get_TheaterMode (VARIANT_BOOL*)
hresult set_TheaterMode (VARIANT_BOOL)
hresult get_AddressBar (VARIANT_BOOL*)
hresult set_AddressBar (VARIANT_BOOL)
hresult get_Resizable (VARIANT_BOOL*)
hresult set_Resizable (VARIANT_BOOL)

 

Output ObjCreate(MediaPlayer.MediaPlayer.1)

Spoiler

Type Attributes:
IId = {20D4F5E0-5475-11D2-9774-0000F80855E6}
Type Kind = DISPATCH
Functions = 192
Variables = 0
Interfaces = 1
Type Flags = DUAL DISPATCHABLE 
VTBL Sz = 28
Alignment = Align on Byte 4
Ver = 0.0

Functions:
void QueryInterface (GUID*, void**)
ulong AddRef ()
ulong Release ()
void GetTypeInfoCount (UINT*)
void GetTypeInfo (UINT, ulong, void**)
void GetIDsOfNames (GUID*, char**, UINT, ulong, long*)
void Invoke (long, GUID*, ulong, ushort, DISPPARAMS*, variant*, EXCEPINFO*, UINT*)
double get_CurrentPosition ()
void set_CurrentPosition (double)
double get_Duration ()
long get_ImageSourceWidth ()
long get_ImageSourceHeight ()
long get_MarkerCount ()
VARIANT_BOOL get_CanScan ()
VARIANT_BOOL get_CanSeek ()
VARIANT_BOOL get_CanSeekToMarkers ()
long get_CurrentMarker ()
void set_CurrentMarker (long)
bstr get_FileName ()
void set_FileName (bstr)
bstr get_SourceLink ()
date get_CreationDate ()
bstr get_ErrorCorrection ()
long get_Bandwidth ()
long get_SourceProtocol ()
long get_ReceivedPackets ()
long get_RecoveredPackets ()
long get_LostPackets ()
long get_ReceptionQuality ()
long get_BufferingCount ()
VARIANT_BOOL get_IsBroadcast ()
long get_BufferingProgress ()
bstr get_ChannelName ()
bstr get_ChannelDescription ()
bstr get_ChannelURL ()
bstr get_ContactAddress ()
bstr get_ContactPhone ()
bstr get_ContactEmail ()
double get_BufferingTime ()
void set_BufferingTime (double)
VARIANT_BOOL get_AutoStart ()
void set_AutoStart (VARIANT_BOOL)
VARIANT_BOOL get_AutoRewind ()
void set_AutoRewind (VARIANT_BOOL)
double get_Rate ()
void set_Rate (double)
VARIANT_BOOL get_SendKeyboardEvents ()
void set_SendKeyboardEvents (VARIANT_BOOL)
VARIANT_BOOL get_SendMouseClickEvents ()
void set_SendMouseClickEvents (VARIANT_BOOL)
VARIANT_BOOL get_SendMouseMoveEvents ()
void set_SendMouseMoveEvents (VARIANT_BOOL)
long get_PlayCount ()
void set_PlayCount (long)
VARIANT_BOOL get_ClickToPlay ()
void set_ClickToPlay (VARIANT_BOOL)
VARIANT_BOOL get_AllowScan ()
void set_AllowScan (VARIANT_BOOL)
VARIANT_BOOL get_EnableContextMenu ()
void set_EnableContextMenu (VARIANT_BOOL)
long get_CursorType ()
void set_CursorType (long)
long get_CodecCount ()
VARIANT_BOOL get_AllowChangeDisplaySize ()
void set_AllowChangeDisplaySize (VARIANT_BOOL)
VARIANT_BOOL get_IsDurationValid ()
long get_OpenState ()
VARIANT_BOOL get_SendOpenStateChangeEvents ()
void set_SendOpenStateChangeEvents (VARIANT_BOOL)
VARIANT_BOOL get_SendWarningEvents ()
void set_SendWarningEvents (VARIANT_BOOL)
VARIANT_BOOL get_SendErrorEvents ()
void set_SendErrorEvents (VARIANT_BOOL)
MPPlayStateConstants get_PlayState ()
VARIANT_BOOL get_SendPlayStateChangeEvents ()
void set_SendPlayStateChangeEvents (VARIANT_BOOL)
MPDisplaySizeConstants get_DisplaySize ()
void set_DisplaySize (MPDisplaySizeConstants)
VARIANT_BOOL get_InvokeURLs ()
void set_InvokeURLs (VARIANT_BOOL)
bstr get_BaseURL ()
void set_BaseURL (bstr)
bstr get_DefaultFrame ()
void set_DefaultFrame (bstr)
VARIANT_BOOL get_HasError ()
bstr get_ErrorDescription ()
long get_ErrorCode ()
VARIANT_BOOL get_AnimationAtStart ()
void set_AnimationAtStart (VARIANT_BOOL)
VARIANT_BOOL get_TransparentAtStart ()
void set_TransparentAtStart (VARIANT_BOOL)
long get_Volume ()
void set_Volume (long)
long get_Balance ()
void set_Balance (long)
MPReadyStateConstants get_ReadyState ()
double get_SelectionStart ()
void set_SelectionStart (double)
double get_SelectionEnd ()
void set_SelectionEnd (double)
VARIANT_BOOL get_ShowDisplay ()
void set_ShowDisplay (VARIANT_BOOL)
VARIANT_BOOL get_ShowControls ()
void set_ShowControls (VARIANT_BOOL)
VARIANT_BOOL get_ShowPositionControls ()
void set_ShowPositionControls (VARIANT_BOOL)
VARIANT_BOOL get_ShowTracker ()
void set_ShowTracker (VARIANT_BOOL)
VARIANT_BOOL get_EnablePositionControls ()
void set_EnablePositionControls (VARIANT_BOOL)
VARIANT_BOOL get_EnableTracker ()
void set_EnableTracker (VARIANT_BOOL)
VARIANT_BOOL get_Enabled ()
void set_Enabled (VARIANT_BOOL)
OLE_COLOR get_DisplayForeColor ()
void set_DisplayForeColor (OLE_COLOR)
OLE_COLOR get_DisplayBackColor ()
void set_DisplayBackColor (OLE_COLOR)
MPDisplayModeConstants get_DisplayMode ()
void set_DisplayMode (MPDisplayModeConstants)
VARIANT_BOOL get_VideoBorder3D ()
void set_VideoBorder3D (VARIANT_BOOL)
long get_VideoBorderWidth ()
void set_VideoBorderWidth (long)
OLE_COLOR get_VideoBorderColor ()
void set_VideoBorderColor (OLE_COLOR)
VARIANT_BOOL get_ShowGotoBar ()
void set_ShowGotoBar (VARIANT_BOOL)
VARIANT_BOOL get_ShowStatusBar ()
void set_ShowStatusBar (VARIANT_BOOL)
VARIANT_BOOL get_ShowCaptioning ()
void set_ShowCaptioning (VARIANT_BOOL)
VARIANT_BOOL get_ShowAudioControls ()
void set_ShowAudioControls (VARIANT_BOOL)
bstr get_CaptioningID ()
void set_CaptioningID (bstr)
VARIANT_BOOL get_Mute ()
void set_Mute (VARIANT_BOOL)
VARIANT_BOOL get_CanPreview ()
VARIANT_BOOL get_PreviewMode ()
void set_PreviewMode (VARIANT_BOOL)
VARIANT_BOOL get_HasMultipleItems ()
long get_Language ()
void set_Language (long)
long get_AudioStream ()
void set_AudioStream (long)
bstr get_SAMIStyle ()
void set_SAMIStyle (bstr)
bstr get_SAMILang ()
void set_SAMILang (bstr)
bstr get_SAMIFileName ()
void set_SAMIFileName (bstr)
long get_StreamCount ()
bstr get_ClientId ()
long get_ConnectionSpeed ()
VARIANT_BOOL get_AutoSize ()
void set_AutoSize (VARIANT_BOOL)
VARIANT_BOOL get_EnableFullScreenControls ()
void set_EnableFullScreenControls (VARIANT_BOOL)
IDispatch* get_ActiveMovie ()
IDispatch* get_NSPlay ()
VARIANT_BOOL get_WindowlessVideo ()
void set_WindowlessVideo (VARIANT_BOOL)
void set_Play ()
void set_Stop ()
void set_Pause ()
double set_GetMarkerTime (long)
bstr set_GetMarkerName (long)
void set_AboutBox ()
VARIANT_BOOL set_GetCodecInstalled (long)
bstr set_GetCodecDescription (long)
bstr set_GetCodecURL (long)
bstr set_GetMoreInfoURL (MPMoreInfoType)
bstr set_GetMediaInfoString (MPMediaInfoType)
void set_Cancel ()
void set_Open (bstr)
VARIANT_BOOL set_IsSoundCardEnabled ()
void set_Next ()
void set_Previous ()
void set_StreamSelect (long)
void set_FastForward ()
void set_FastReverse ()
bstr set_GetStreamName (long)
long set_GetStreamGroup (long)
VARIANT_BOOL set_GetStreamSelected (long)
IMediaPlayerDvd* get_DVD ()
bstr get_GetMediaParameter (long, bstr)
bstr get_GetMediaParameterName (long, long)
long get_EntryCount ()
long get_GetCurrentEntry ()
void get_SetCurrentEntry (long)
void get_ShowDialog (MPShowDialogConstants)

 

Edited by Bilgus
  • Like 1

Share this post


Link to post
Share on other sites
mLipok

maybe this:

 

 

 

  • Thanks 1

Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2018-03-17

Share this post


Link to post
Share on other sites
Bilgus

@mLipok The First link is in a similar vein it looks to be parsing the TLB, Whereas this is using the interfaces directly

Not sure what the second link is supposed to point to

Thanks, It's nice to see other examples..

Share this post


Link to post
Share on other sites
Bilgus

Not sure why I hadn't tried this before but I guess you can use ObjCreateInterface with an existing interface

Global $oObject = ObjCreate("MediaPlayer.MediaPlayer.1")
        ;...IDispatch isn't exposed ATM
        
        If ObjName($oObject, 1) <> "InterfaceDispatch" Then
            $oObject = ObjCreateInterface($oObject, $sIID_IDispatch, $dtag_IDispatch) ;Try To get IDispatch
        EndIf
        ;...IDispatch is exposed

Added to example in first post

Share this post


Link to post
Share on other sites
ptrex
Posted (edited)

@Bilgus

Very nice ! It will be useful for the .NET CLR UDF as well

I see you reused some the CLR.au3 code

Global Const $sIID_IDispatch = "{00020400-0000-0000-C000-000000000046}"
Global Const $dtag_IDispatch = _
        "GetTypeInfoCount hresult(dword*);" & _ ; Retrieves the number of type information interfaces that an object provides (either 0 or 1).
        "GetTypeInfo hresult(dword;dword;ptr*);" & _ ; Gets the type information for an object.
        "GetIDsOfNames hresult(ptr;ptr;dword;dword;ptr);" & _ ; Maps a single member and an optional set of argument names to a corresponding set of integer DISPIDs, which can be used on subsequent calls to Invoke.
        "Invoke hresult(dword;ptr;dword;word;ptr;ptr;ptr;ptr);" ; Provides access to properties and methods exposed by an object.

 

Rgds,

ptrex

Edited by ptrex
  • Thanks 1

Share this post


Link to post
Share on other sites
Bilgus

I actually got that from LarsJ's Explorer Udf's but the mentioned UDF could be the original source

Share this post


Link to post
Share on other sites
Bilgus

@ptrex Thanks for the hint on your .Net Clr Udf those interface defines, safearray.au3 and variant.au3 would have saved me quite a bit of coding between this and the FwPolicy2 Udf I posted

Share this post


Link to post
Share on other sites
ptrex

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Similar Content

    • Bilgus
      By Bilgus
      ; NetFirewallPolicy2 COM UDF Library for AutoIt3
      ; AutoIt Version : 3.3.14.5
      ; Description ...: Windows Firewall Policy2 Interface, Provides access to the firewall policy for Windows Vista+
      Including Test Script 
      _NetFw_Get_CurrentProfileTypes                           Retrieves the currently active firewall profile(s) _NetFw_Get_FirewallEnabled                               Indicates whether a firewall is enabled locally _NetFw_Put_FirewallEnabled                               Specifies whether a firewall is enabled locally _NetFw_Get_ExcludedInterfaces                            Indicates a list of interfaces on which firewall settings are excluded _NetFw_Put_ExcludedInterfaces                            Specifies a list of interfaces on which firewall settings are excluded _NetFw_Get_BlockAllInboundTraffic                        Indicates whether the firewall should not allow inbound traffic _NetFw_Put_BlockAllInboundTraffic                        Specifies whether the firewall should not allow inbound traffic _NetFw_Get_NotificationsDisabled                         Indicates whether interactive firewall notifications are disabled _NetFw_Put_NotificationsDisabled                         Specifies whether interactive firewall notifications are disabled _NetFw_Get_UnicastResponsesToMulticastBroadcastDisabled  Indicates whether the firewall should not allow unicast responses to multicast and broadcast traffic _NetFw_Put_UnicastResponsesToMulticastBroadcastDisabled  Specifies whether the firewall should not allow unicast responses to multicast and broadcast traffic _NetFw_Get_Rules                                         Retrieves the interface to collection of firewall rules _NetFw_Get_ServiceRestriction                            Retrieves the interface used to access the Windows Service Hardening store _NetFw_EnableRuleGroup                                   Enables or disables a specified group of firewall rules _NetFw_IsRuleGroupEnabled                                Determines whether a specified group of firewall rules are enabled or disabled for the current profile _NetFw_RestoreLocalFirewallDefaults                      Restores the local firewall configuration to its default state _NetFw_Get_DefaultInboundAction                          Indicates the default action for inbound traffic _NetFw_Put_DefaultInboundAction                          Specifies the default action for inbound traffic _NetFw_Get_DefaultOutboundAction                         Indicates the default action for outbound traffic _NetFw_Put_DefaultOutboundAction                         Specifies the default action for outbound traffic _NetFw_Get_IsRuleGroupCurrentlyEnabled                   Determines whether a specified group of firewall rules are enabled or disabled for the current profile _NetFw_Get_LocalPolicyModifyState                        Determines if adding or setting a rule or group of rules will take effect in the current firewall profile  
      UDF:
      Test Script:
       
    • Bilgus
      By Bilgus
       IGroupPolicyObject interface
      ;;IGroupPolicyObject #RequireAdmin #include-once #include <WinAPIConstants.au3> ; $S_OK #include <WinAPIReg.au3> ;_WinAPI_GetRegKeyNameByHandle Global Enum $GPO_SECTION_ROOT = 0x0, $GPO_SECTION_USER, $GPO_SECTION_MACHINE Global Enum $GPO_OPEN_LOAD_REGISTRY = 0x1, $GPO_OPEN_READ_ONLY Global Enum $GPO_OPTION_DISABLE_USER = 0x1, $GPO_OPTION_DISABLE_MACHINE Global Enum $GPOTypeLocal = 0x0, $GPOTypeRemote, $GPOTypeDS, $GPOTypeLocalUser, $GPOTypeLocalGroup Global Const $sCLSID_GroupPolicyObject = "{EA502722-A23D-11D1-A7D3-0000F87571E3}" Global Const $sIID_IGroupPolicyObject = "{EA502723-A23D-11D1-A7D3-0000F87571E3}" Global Const $dtag_IGroupPolicyObject = _ "New hresult(wstr;wstr;dword);" & _ ; Creates a new GPO in the Active Directory with the specified display name. "OpenDSGPO hresult(wstr;dword);" & _ ; Opens the specified GPO and optionally loads the registry information. "OpenLocalMachineGPO hresult(dword);" & _ ; Opens the default GPO for the computer and optionally loads the registry information. "OpenRemoteMachineGPO hresult(wstr;dword);" & _ ; Opens the default GPO for the specified remote computer and optionally loads the registry information. "Save hResult(bool;bool;ptr;ptr);" & _ ; Saves the specified registry policy settings to disk and updates the revision number of the GPO. "Delete hresult();" & _ ; Deletes the GPO. "GetName hResult(wstr;int);" & _ ; Retrieves the unique name for the GPO. "GetDisplayName hResult(wstr;int);" & _ ; Retrieves the display name for the GPO. "SetDisplayName hresult(wstr);" & _ ; Sets the display name for the GPO. "GetPath hResult(wstr;int);" & _ ; Retrieves the path to the GPO. "GetDSPath hresult(dword;wstr;int);" & _ ; Retrieves the Active Directory path to the root of the specified GPO section. "GetFileSysPath hresult(dword;wstr;int);" & _ ; Retrieves the file system path (UNC format) to the root of the specified GPO section. "GetRegistryKey hresult(dword;handle);" & _ ; Retrieves a handle to the root of the registry key for the specified GPO section. "GetOptions hResult(dword*);" & _ ; Retrieves the options for the GPO. "SetOptions hresult(dword;dword);" & _ ; Sets the options for the GPO. "GetType hResult(dword*);" & _ ; Retrieves type information for the GPO being edited. "GetMachineName hResult(wstr;int);" & _ ; Retrieves the computer name of the remote GPO. "GetPropertySheetPages hresult(ptr;uint*);" ; Retrieves the property sheet pages associated with the GPO. Test() Func Test() Local $iResult Local $oIGroupPolicy Local $aGpoType[5] = ["Local", "Remote", "Active Directory", "LocalUser", "LocalGroup"] $oIGroupPolicy = ObjCreateInterface($sCLSID_GroupPolicyObject, $sIID_IGroupPolicyObject, $dtag_IGroupPolicyObject) While True If Not IsObj($oIGroupPolicy) Then ConsoleWrite("Failed To Retrieve Interface") $iResult = $E_NOINTERFACE ExitLoop Else ConsoleWrite("Success: " & ObjName($oIGroupPolicy, 1) & @CRLF) EndIf Local $sLoc, $sPath, $sName, $iType $tKey = DllStructCreate("handle hKey") $iResult = $oIGroupPolicy.OpenLocalMachineGPO(BitOR($GPO_OPEN_LOAD_REGISTRY, $GPO_OPEN_READ_ONLY)) If $iResult <> $S_OK Then ExitLoop $iResult = $oIGroupPolicy.GetDisplayName($sLoc, 65535) If $iResult <> $S_OK Then ExitLoop $iResult = $oIGroupPolicy.GetName($sName, 65535) If $iResult <> $S_OK Then ExitLoop ConsoleWrite($sLoc & " : " & $sName & @CRLF) $iResult = $oIGroupPolicy.GetPath($sPath, 65535) If $iResult <> $S_OK Then ExitLoop $iResult = $oIGroupPolicy.GetType($iType) If $iResult <> $S_OK Then ExitLoop ConsoleWrite($sPath & @CRLF) $iResult = $oIGroupPolicy.GetType($iType) If $iResult <> $S_OK Then ExitLoop ConsoleWrite("Type: " & $aGpoType[$iType] & @CRLF) $iResult = $oIGroupPolicy.GetRegistryKey($GPO_SECTION_USER, DllStructGetPtr($tKey)) If $iResult <> $S_OK Then ExitLoop ConsoleWrite(_WinAPI_GetRegKeyNameByHandle(DllStructGetData($tKey, "hKey")) & @CRLF) ExitLoop WEnd Return SetError($iResult, 0, ($iResult = $S_OK)) EndFunc ;==>Test Note: Not well tested..
    • Fenzik
      By Fenzik
       Hello all"
      I have curious problem with com object implementation of Sapi 5.1.
      In some cases }Some Voice engines] the metods for retrieve the voice parameters fails with error :Member not exists:.
      But the Retrieved Voice object can speak the given text, so It exists and work.
      Example of this type of Engine can be this one: http://download.kobavision.be/KobaSpeech3/KobaSpeech 3 With Vocalizer Serena - English (Great Britain).exe (can work as demo)
      So my question is> Is there some way to workaround or solve this issue?
      What i tryed:
      1. Typical use of Sapi.spvoice object:
      $oMyError = ObjEvent("AutoIt.Error","MyErrFunc"); Install a custom error handler
       
        $spvoice = ObjCreate("sapi.spvoice")
      for $voice in $spvoice.getvoices()
        msgbox(0, "Voice", $voice.getdescription())
      next
      Func MyErrFunc()
      $HexNumber = hex($oMyError.number, 8)
      Msgbox(0,"","We intercepted a COM Error !" & @CRLF &"Number is: " & $HexNumber & @CRLF &"Windescription is: " & $oMyError.windescription)
      SetError(1)
      Endfunc

      2. Implement workaround based on Nvda Screen reader sapi5 Library at https://github.com/nvaccess/nvda/blob/master/source/synthDrivers/sapi5.py
      Thys code in Pascal should work, so i tryed to reproduce it in Autoit.
      Pascal code just as example:
                   SOTokens:=SpVoice.GetVoices('','');
                   for i:=0 to SOTokens.Count-1 do
                   try
                        SOToken:=SOTokens.Item(I); s:=SOToken.GetDescription(0);
      end
      In Autoit I tryed it like this:
      $oMyError = ObjEvent("AutoIt.Error","MyErrFunc"); Install a custom error handler
        $spvoice = ObjCreate("sapi.spvoice")
      for $i = 0 to $spvoice.getvoices.count-1
      $name = $spvoice.getvoices.item($i).getdescription
      msgbox(0,"Voice", $name)
      next
      Func MyErrFunc()
      $HexNumber = hex($oMyError.number, 8)
      Msgbox(0,"","We intercepted a COM Error !" & @CRLF &"Number is: " & $HexNumber & @CRLF &"Windescription is: " & $oMyError.windescription)
      SetError(1)
      Endfunc
      Both of this methods returning same Error ("Member not exists.").
      Thanks a lot for help.
      Znefyg
    • gillesg
      By gillesg
      Hello,
       
      Is there a way to get all the properties and method of a COM object thru Autoit.
      I am looking in a way of display the imbricated structure of object and method.
       
      Example of COm objects are "itunes.application", "Shell.application" and so on.
      The idea is to have a code looking like
      $objtobrowse = objcreate("itunes.application") if isobj($objtobrowse) then $colItems = $objtobrowse.buildinproperty For $objItem In $colItems ConsoleWrite($objItem.<Name> & " - " & $objItem.<Value> & @CRLF) Next EndIf  
    • timmalos
      By timmalos
      Hey all.
      I'm a little stuck starting with COM interfacing with Microsoft OneNote.
      The msdn doc is there : https://msdn.microsoft.com/en-us/library/office/jj680118.aspx?f=255&MSPPError=-2147217396
      I found, with the OleViewer what I need to access :
      // Generated .IDL file (by the OLE/COM Object Viewer) // // typelib filename: 3 [ uuid(0EA692EE-BB50-4E3C-AEF0-356D91732725), version(1.1), helpstring("Microsoft OneNote 15.0 Object Library"), custom(DE77BA64-517C-11D1-A2DA-0000F8773CE9, 134218339), custom(DE77BA63-517C-11D1-A2DA-0000F8773CE9, 2147483647), custom(DE77BA65-517C-11D1-A2DA-0000F8773CE9, Created by MIDL version 8.00.0611 at Mon Jan 18 19:14:07 2038 ), custom(0F21F359-AB84-41E8-9A78-36D110E6D2F9, Microsoft.Office.Interop.OneNote.dll) ] library OneNote { // TLib : // TLib : OLE Automation : {00020430-0000-0000-C000-000000000046} importlib("stdole2.tlb"); // Forward declare all types defined in this typelib interface IQuickFilingDialog; interface IQuickFilingDialogCallback; interface IApplication; interface Windows; interface Window; dispinterface IOneNoteEvents; typedef [uuid(552E0E02-B287-4EC6-9CC0-4BA019EE5EA1)] enum { hsSelf = 0, hsChildren = 1, hsNotebooks = 2, hsSections = 3, hsPages = 4 } HierarchyScope; typedef [uuid(41C8F6EA-0AF0-4A4F-99E9-5EB01EBFC9A3)] enum { heNone = 0, heNotebooks = 1, heSectionGroups = 2, heSections = 4, hePages = 8 } HierarchyElement; typedef [uuid(4DB67B4F-CC7D-45B5-88FE-569AE5798FF2)] enum { rrtNone = 0, rrtFiling = 1, rrtSearch = 2, rrtLinks = 3 } RecentResultType; typedef [uuid(B5EB9D34-5278-4D8A-AE1F-2F88EA56BBCE)] enum { cftNone = 0, cftNotebook = 1, cftFolder = 2, cftSection = 3 } CreateFileType; typedef [uuid(D6E78E55-7EE7-4A31-BF3E-B01E819599BA)] enum { piBasic = 0, piBinaryData = 1, piSelection = 2, piFileType = 4, piBinaryDataSelection = 3, piBinaryDataFileType = 5, piSelectionFileType = 6, piAll = 7 } PageInfo; typedef [uuid(D6166973-3665-4EDB-94B0-77C65C34B51C)] enum { pfOneNote = 0, pfOneNotePackage = 1, pfMHTML = 2, pfPDF = 3, pfXPS = 4, pfWord = 5, pfEMF = 6, pfHTML = 7, pfOneNote2007 = 8 } PublishFormat; typedef [uuid(E195F3E3-8EC3-4A67-81FE-DDBEC2B42D3F)] enum { slBackUpFolder = 0, slUnfiledNotesSection = 1, slDefaultNotebookFolder = 2 } SpecialLocation; typedef [uuid(452D048E-7F61-4258-94B9-A39E19C290DA)] enum { flEMail = 0, flContacts = 1, flTasks = 2, flMeetings = 3, flWebContent = 4, flPrintOuts = 5 } FilingLocation; typedef [uuid(82FC5A95-FEB7-4242-95E1-369C5DFE3F49)] enum { fltNamedSectionNewPage = 0, fltCurrentSectionNewPage = 1, fltCurrentPage = 2, fltNamedPage = 4 } FilingLocationType; typedef [uuid(226CC8E6-1ED0-4770-A7F1-A80BB4DDF07B)] enum { npsDefault = 0, npsBlankPageWithTitle = 1, npsBlankPageNoTitle = 2 } NewPageStyle; typedef [uuid(B67BC7E1-91B9-4F50-8471-77C76F8D63D6)] enum { dlDefault = 0xffffffff, dlNone = 0, dlLeft = 1, dlRight = 2, dlTop = 3, dlBottom = 4 } DockLocation; typedef [uuid(68555133-B62F-4490-9D66-9E9BFC68F6C6)] enum { xs2007 = 0, xs2010 = 1, xs2013 = 2, xsCurrent = 2 } XMLSchema; typedef [uuid(1ECC88B3-6D2B-4EDD-8DD5-BB11E5D34C09)] enum { tcsExpanded = 0, tcsCollapsed = 1 } TreeCollapsedStateType; typedef [uuid(13F18B04-E76F-42E0-97E6-8B6ABF38B484)] enum { nfoLocal = 1, nfoNetwork = 2, nfoWeb = 4, nfoNoWacUrl = 8 } NotebookFilterOutType; [ odl, uuid(1D12BD3F-89B6-4077-AA2C-C9DC2BCA42F9), helpstring("IQuickFilingUI Interface"), dual, oleautomation ] interface IQuickFilingDialog : IDispatch { [id(00000000), propget] HRESULT Title([out, retval] BSTR* bstrTitle); [id(00000000), propput] HRESULT Title([in] BSTR bstrTitle); [id(0x00000001), propget] HRESULT Description([out, retval] BSTR* bstrDescription); [id(0x00000001), propput] HRESULT Description([in] BSTR bstrDescription); [id(0x00000002), propget] HRESULT CheckboxText([out, retval] BSTR* bstrText); [id(0x00000002), propput] HRESULT CheckboxText([in] BSTR bstrText); [id(0x00000003), propget] HRESULT CheckboxState([out, retval] VARIANT_BOOL* pfChecked); [id(0x00000003), propput] HRESULT CheckboxState([in] VARIANT_BOOL pfChecked); [id(0x00000004), propget] HRESULT WindowHandle([out, retval] uint64* pHWNDWindow); [id(0x00000005), propget] HRESULT TreeDepth([out, retval] HierarchyElement* pTreeDepth); [id(0x00000005), propput] HRESULT TreeDepth([in] HierarchyElement pTreeDepth); [id(0x00000006), propget] HRESULT ParentWindowHandle([out, retval] uint64* pHWNDParentWindow); [id(0x00000006), propput] HRESULT ParentWindowHandle([in] uint64 pHWNDParentWindow); [id(0x00000007), propget] HRESULT Position([out, retval] tagPOINT* pPoint); [id(0x00000007), propput] HRESULT Position([in] tagPOINT pPoint); [id(0x00000008)] HRESULT SetRecentResults( [in] RecentResultType recentResults, [in] VARIANT_BOOL fShowCurrentSection, [in] VARIANT_BOOL fShowCurrentPage, [in] VARIANT_BOOL fShowUnfiledNotes); [id(0x0000000a)] HRESULT AddButton( [in] BSTR bstrText, [in] HierarchyElement allowedElements, [in] HierarchyElement allowedReadOnlyElements, [in] VARIANT_BOOL fDefault); [id(0x0000000b)] HRESULT Run([in] IQuickFilingDialogCallback* piCallback); [id(0x0000000c), propget] HRESULT SelectedItem([out, retval] BSTR* pbstrSelectedNodeID); [id(0x0000000d), propget] HRESULT PressedButton([out, retval] unsigned long* pButtonIndex); [id(0x0000000e), propput] HRESULT TreeCollapsedState([in] TreeCollapsedStateType rhs); [id(0x0000000f), propput] HRESULT NotebookFilterOut([in] NotebookFilterOutType rhs); [id(0x00000010)] HRESULT ShowCreateNewNotebook(); [id(0x00000011)] HRESULT AddInitialEditor(BSTR initialEditor); [id(0x00000012)] HRESULT ClearInitialEditors(); [id(0x00000013)] HRESULT ShowSharingHyperlink(); }; typedef struct tagtagPOINT { long x; long y; } tagPOINT; [ odl, uuid(627EA7B4-95B5-4980-84C1-9D20DA4460B1), helpstring("IQuickFilingDialogCallback Interface"), dual, oleautomation ] interface IQuickFilingDialogCallback : IDispatch { [id(0x60020000)] HRESULT OnDialogClosed([in] IQuickFilingDialog* dialog); }; [ odl, uuid(452AC71A-B655-4967-A208-A4CC39DD7949), helpstring("IApplication Interface"), dual, oleautomation ] interface IApplication : IDispatch { [id(0x60020000)] HRESULT GetHierarchy( [in] BSTR bstrStartNodeID, [in] HierarchyScope hsScope, [out] BSTR* pbstrHierarchyXmlOut, [in, optional, defaultvalue(2)] XMLSchema xsSchema); [id(0x60020001)] HRESULT UpdateHierarchy( [in] BSTR bstrChangesXmlIn, [in, optional, defaultvalue(2)] XMLSchema xsSchema); [id(0x60020002)] HRESULT OpenHierarchy( [in] BSTR bstrPath, [in] BSTR bstrRelativeToObjectID, [out] BSTR* pbstrObjectID, [in, optional, defaultvalue(0)] CreateFileType cftIfNotExist); [id(0x60020003)] HRESULT DeleteHierarchy( [in] BSTR bstrObjectID, [in, optional, defaultvalue(00:00:00)] DATE dateExpectedLastModified, [in, optional, defaultvalue(0)] VARIANT_BOOL deletePermanently); [id(0x60020004)] HRESULT CreateNewPage( [in] BSTR bstrSectionID, [out] BSTR* pbstrPageID, [in, optional, defaultvalue(0)] NewPageStyle npsNewPageStyle); [id(0x60020005)] HRESULT CloseNotebook( [in] BSTR bstrNotebookID, [in, optional, defaultvalue(0)] VARIANT_BOOL force); [id(0x60020006)] HRESULT GetHierarchyParent( [in] BSTR bstrObjectID, [out] BSTR* pbstrParentID); [id(0x60020007)] HRESULT GetPageContent( [in] BSTR bstrPageID, [out] BSTR* pbstrPageXmlOut, [in, optional, defaultvalue(0)] PageInfo pageInfoToExport, [in, optional, defaultvalue(2)] XMLSchema xsSchema); [id(0x60020008)] HRESULT UpdatePageContent( [in] BSTR bstrPageChangesXmlIn, [in, optional, defaultvalue(00:00:00)] DATE dateExpectedLastModified, [in, optional, defaultvalue(2)] XMLSchema xsSchema, [in, optional, defaultvalue(0)] VARIANT_BOOL force); [id(0x60020009)] HRESULT GetBinaryPageContent( [in] BSTR bstrPageID, [in] BSTR bstrCallbackID, [out] BSTR* pbstrBinaryObjectB64Out); [id(0x6002000a)] HRESULT DeletePageContent( [in] BSTR bstrPageID, [in] BSTR bstrObjectID, [in, optional, defaultvalue(00:00:00)] DATE dateExpectedLastModified, [in, optional, defaultvalue(0)] VARIANT_BOOL force); [id(0x6002000b)] HRESULT NavigateTo( [in] BSTR bstrHierarchyObjectID, [in, optional, defaultvalue("")] BSTR bstrObjectID, [in, optional, defaultvalue(0)] VARIANT_BOOL fNewWindow); [id(0x6002000c)] HRESULT NavigateToUrl( [in] BSTR bstrUrl, [in, optional, defaultvalue(0)] VARIANT_BOOL fNewWindow); [id(0x6002000d)] HRESULT Publish( [in] BSTR bstrHierarchyID, [in] BSTR bstrTargetFilePath, [in, optional, defaultvalue(0)] PublishFormat pfPublishFormat, [in, optional, defaultvalue("")] BSTR bstrCLSIDofExporter); [id(0x6002000e)] HRESULT OpenPackage( [in] BSTR bstrPathPackage, [in] BSTR bstrPathDest, [out] BSTR* pbstrPathOut); [id(0x6002000f)] HRESULT GetHyperlinkToObject( [in] BSTR bstrHierarchyID, [in] BSTR bstrPageContentObjectID, [out] BSTR* pbstrHyperlinkOut); [id(0x60020010)] HRESULT FindPages( [in] BSTR bstrStartNodeID, [in] BSTR bstrSearchString, [out] BSTR* pbstrHierarchyXmlOut, [in, optional, defaultvalue(0)] VARIANT_BOOL fIncludeUnindexedPages, [in, optional, defaultvalue(0)] VARIANT_BOOL fDisplay, [in, optional, defaultvalue(2)] XMLSchema xsSchema); [id(0x60020011)] HRESULT FindMeta( [in] BSTR bstrStartNodeID, [in] BSTR bstrSearchStringName, [out] BSTR* pbstrHierarchyXmlOut, [in, optional, defaultvalue(0)] VARIANT_BOOL fIncludeUnindexedPages, [in, optional, defaultvalue(2)] XMLSchema xsSchema); [id(0x60020012)] HRESULT GetSpecialLocation( [in] SpecialLocation slToGet, [out] BSTR* pbstrSpecialLocationPath); [id(0x60020013)] HRESULT MergeFiles( [in] BSTR bstrBaseFile, [in] BSTR bstrClientFile, [in] BSTR bstrServerFile, [in] BSTR bstrTargetFile); [id(0x60020014)] HRESULT QuickFiling([out, retval] IQuickFilingDialog** ppiDialog); [id(0x60020015)] HRESULT SyncHierarchy([in] BSTR bstrHierarchyID); [id(0x60020016)] HRESULT SetFilingLocation( [in] FilingLocation flToSet, [in] FilingLocationType fltToSet, [in] BSTR bstrFilingSectionID); [id(0x00000064), propget] HRESULT Windows([out, retval] Windows** ppONWindows); [id(0x00000066), propget, hidden] HRESULT Dummy1([out, retval] VARIANT_BOOL* pBool); [id(0x60020019)] HRESULT MergeSections( [in] BSTR bstrSectionSourceId, [in] BSTR bstrSectionDestinationId); [id(0x00000068), propget] HRESULT COMAddIns([out, retval] IDispatch** ppiComAddins); [id(0x00000069), propget] HRESULT LanguageSettings([out, retval] IDispatch** ppiLanguageSettings); [id(0x6002001c)] HRESULT GetWebHyperlinkToObject( [in] BSTR bstrHierarchyID, [in] BSTR bstrPageContentObjectID, [out] BSTR* pbstrHyperlinkOut); }; [ odl, uuid(6D4B9C3E-CC05-493F-85E2-43D1006DF96A), helpstring("List of our Windows Interface"), dual, oleautomation ] interface Windows : IDispatch { [id(00000000), propget] HRESULT Item( [in] unsigned long Index, [out, retval] Window** Item); [id(0x00000001), propget] HRESULT Count([out, retval] unsigned long* Count); [id(0xfffffffc), propget] HRESULT _NewEnum([out, retval] IUnknown** _NewEnum); [id(0x00000003), propget] HRESULT CurrentWindow([out, retval] Window** ppCurrentWindow); }; [ odl, uuid(8E8304B8-CBD1-44F8-B0E8-89C625B2002E), helpstring("Window Interface"), dual, oleautomation ] interface Window : IDispatch { [id(00000000), propget] HRESULT WindowHandle([out, retval] uint64* pHWNDWindow); [id(0x00000001), propget] HRESULT CurrentPageId([out, retval] BSTR* pbstrPageObjectId); [id(0x00000002), propget] HRESULT CurrentSectionId([out, retval] BSTR* pbstrSectionObjectId); [id(0x00000003), propget] HRESULT CurrentSectionGroupId([out, retval] BSTR* pbstrSectionObjectId); [id(0x00000004), propget] HRESULT CurrentNotebookId([out, retval] BSTR* pbstrNotebookObjectId); [id(0x00000009)] HRESULT NavigateTo( [in] BSTR bstrHierarchyObjectID, [in, optional, defaultvalue("0")] BSTR bstrObjectID); [id(0x0000000a), propget] HRESULT FullPageView([out, retval] VARIANT_BOOL* pIsFullPageView); [id(0x0000000a), propput] HRESULT FullPageView(VARIANT_BOOL pIsFullPageView); [id(0x0000000b), propget] HRESULT Active([out, retval] VARIANT_BOOL* pIsActive); [id(0x0000000b), propput] HRESULT Active(VARIANT_BOOL pIsActive); [id(0x0000000d), propget] HRESULT DockedLocation([out, retval] DockLocation* pDockLocation); [id(0x0000000d), propput] HRESULT DockedLocation(DockLocation pDockLocation); [id(0x0000000e), propget] HRESULT Application([out, retval] IApplication** ppiApp); [id(0x0000000f), propget] HRESULT SideNote([out, retval] VARIANT_BOOL* pIsSideNote); [id(0x00000010)] HRESULT NavigateToUrl([in] BSTR bstrUrl); [id(0x00000011)] HRESULT SetDockedLocation( [in] DockLocation DockLocation, [in] tagPOINT ptMonitor); }; [ uuid(E2E1511D-502D-4BD0-8B3A-8A89A05CDCAE), helpstring("IOneNoteEvents Interface"), nonextensible ] dispinterface IOneNoteEvents { properties: methods: [id(0x00000001)] void OnNavigate(); [id(0x00000002)] void OnHierarchyChange([in] BSTR bstrActivePageID); }; [ uuid(D7FAC39E-7FF1-49AA-98CF-A1DDD316337E), version(1.0), helpstring("Application Class") ] coclass Application { [default] interface IApplication; [default, source] dispinterface IOneNoteEvents; }; typedef [uuid(D3F5A756-4BAC-4D3D-9BAF-90935121AAA6)] enum { hrMalformedXML = 0x80042000, hrInvalidXML = 0x80042001, hrCreatingSection = 0x80042002, hrOpeningSection = 0x80042003, hrSectionDoesNotExist = 0x80042004, hrPageDoesNotExist = 0x80042005, hrFileDoesNotExist = 0x80042006, hrInsertingImage = 0x80042007, hrInsertingInk = 0x80042008, hrInsertingHtml = 0x80042009, hrNavigatingToPage = 0x8004200a, hrSectionReadOnly = 0x8004200b, hrPageReadOnly = 0x8004200c, hrInsertingOutlineText = 0x8004200d, hrPageObjectDoesNotExist = 0x8004200e, hrBinaryObjectDoesNotExist = 0x8004200f, hrLastModifiedDateDidNotMatch = 0x80042010, hrGroupDoesNotExist = 0x80042011, hrPageDoesNotExistInGroup = 0x80042012, hrNoActiveSelection = 0x80042013, hrObjectDoesNotExist = 0x80042014, hrNotebookDoesNotExist = 0x80042015, hrInsertingFile = 0x80042016, hrInvalidName = 0x80042017, hrFolderDoesNotExist = 0x80042018, hrInvalidQuery = 0x80042019, hrFileAlreadyExists = 0x8004201a, hrSectionEncryptedAndLocked = 0x8004201b, hrDisabledByPolicy = 0x8004201c, hrNotYetSynchronized = 0x8004201d, hrLegacySection = 0x8004201e, hrMergeFailed = 0x8004201f, hrInvalidXMLSchema = 0x80042020, hrFutureContentLoss = 0x80042022, hrTimeOut = 0x80042023, hrRecordingInProgress = 0x80042024, hrUnknownLinkedNoteState = 0x80042025, hrNoShortNameForLinkedNote = 0x80042026, hrNoFriendlyNameForLinkedNote = 0x80042027, hrInvalidLinkedNoteUri = 0x80042028, hrInvalidLinkedNoteThumbnail = 0x80042029, hrImportLNTThumbnailFailed = 0x8004202a, hrUnreadDisabledForNotebook = 0x8004202b, hrInvalidSelection = 0x8004202c, hrConvertFailed = 0x8004202d, hrRecycleBinEditFailed = 0x8004202e, hrAppInModalUI = 0x80042030 } Error; [ uuid(DC67E480-C3CB-49F8-8232-60B0C2056C8E), version(1.0), helpstring("Application2 Class") ] coclass Application2 { [default] interface IApplication; [default, source] dispinterface IOneNoteEvents; }; }; So far, I didn't manage to be able to interact with it : There is my code (based on same issue someone had in 2011
      #AutoIt3Wrapper_UseX64=n #include <Array.au3> #include "AutoItObject\AutoItObject.au3" ;=============================================================================== ;interface "OneNoteIApplication" Global Const $sCLSID_OneNoteApplication = "{0039FFEC-A022-4232-8274-6B34787BFC27}" Global Const $sIID_IOneNoteApplication = "{2DA16203-3F58-404F-839D-E4CDE7DD0DED}" ; Definition Global $dtagIOneNoteWindows = $dtagIDispatch Global $dtagIOneNoteApplication = $dtagIDispatch & _ "GetHierarchy hresult(bstr;dword;bstr*);" & _ "UpdateHierarchy hresult(bstr);" & _ "OpenHierarchy hresult(bstr;bstr;bstr*;dword);" & _ "DeleteHierarchy hresult(bstr;double);" & _ "CreateNewPage hresult(bstr;bstr*;dword);" & _ "CloseNotebook hresult(bstr);" & _ "GetHierarchyParent hresult(bstr;bstr*);" & _ "GetPageContent hresult(bstr;bstr*;dword);" & _ "UpdatePageContent hresult(bstr;double);" & _ "GetBinaryPageContent hresult(bstr;bstr;bstr*);" & _ "DeletePageContent hresult(bstr;bstr;dword);" & _ "NavigateTo hresult(bstr;bstr;bool);" & _ "Publish hresult(bstr;bstr;dword;bstr);" & _ "OpenPackage hresult(bstr;bstr;bstr*);" & _ "GetHyperlinkToObject hresult(bstr;bstr;bstr*);" & _ "FindPages hresult(bstr;bstr;bstr*;bool;bool);" & _ "FindMeta hresult(bstr;bstr;bstr*;bool);" & _ "GetSpecialLocation hresult(dword;bstr*);" ; List Global $ltagIOneNoteApplication = $ltagIDispatch & _ "GetHierarchy;" & _ "UpdateHierarchy;" & _ "OpenHierarchy;" & _ "DeleteHierarchy;" & _ "CreateNewPage;" & _ "CloseNotebook;" & _ "GetHierarchyParent;" & _ "GetPageContent;" & _ "UpdatePageContent;" & _ "GetBinaryPageContent;" & _ "DeletePageContent;" & _ "NavigateTo;" & _ "Publish;" & _ "OpenPackage;" & _ "GetHyperlinkToObject;" & _ "FindPages;" & _ "FindMeta;" & _ "GetSpecialLocation;" ;=============================================================================== _AutoItObject_StartUp() Global $objOneNote = ObjCreate("OneNote.Application") Global $pOneNote = _AutoItObject_IDispatchToPtr($objOneNote) _AutoItObject_IUnknownAddRef($objOneNote) Global $oOneNote = _AutoItObject_WrapperCreate($pOneNote, $dtagIOneNoteWindows) ;~ Global $oOnenote = ObjCreateInterface($sCLSID_OneNoteApplication,$sIID_IOneNoteApplication,$dtagIOneNoteApplication,True) ;~ ; Check if object is created: If Not IsObj($oOneNote) Then MsgBox(48, "Error", "Object not created. Something is wrong.") Exit EndIf $aCall = $oOneNote.GetTypeInfoCount(0) $iTypeInfoCount = $aCall[1] ConsoleWrite("$iTypeInfoCount = " & $iTypeInfoCount & @CRLF) $Window = $oOneNote.Windows ;~ ConsoleWrite("Test = " & $Window.CurrentPageId & @CRLF) $str = "onenote:///R:\Software\OneNote%20EOD\EOD%20Scrum\Sprint%20136.one#section-id={D2EB7AEB-362B-490A-9CE0-0B9316DF0DAD}&end" $hBSTR = DllCall("oleaut32.dll", "ptr", "SysAllocString", "wstr", $str) $aCall = $oOnenote.NavigateToUrl($hBSTR[0])  
      Can someone help me to go in the good direction? I'm a little lost with what's needed, (CLSID and IID whereas I have only a UUID and can't find a good starting doc online)
      Thanks a lot,
       
×