Inververs

[solved] Help with event notifications for IMbnPinManagerEvents interface

23 posts in this topic

#1 ·  Posted (edited)

Hello. I try to register event handler for for IMbnPinManagerEvents interface.

All goes well, but when event triggered i have in params strange data.

For example in OnGetPinStateComplete in $iRequestID i expect same id, but getting 0 all the time, in $pPinInfo i expect pointer to the structure, but when i fills the structure on this pointer, i have incorrect data in results, and so on...

This is a very specific API and work only whith usb modems, so if you do not have a modem, example does not work, but  I hope that the skilled person will be able to find and show where the error in the code.

I hope for your help. Thanks.

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

 

#include <WinAPI.au3>
#include 'SafeArray.au3'
#Region Const
Global Const $sIID_IUnknown = "{00000000-0000-0000-C000-000000000046}"

Global Const $sIID_IMbnPinManager = '{DCBBBAB6-2005-4BBB-AAEE-338E368AF6FA}'
Global Const $dtag_IMbnPinManager = _
        'GetPinList hresult();' & _
        'GetPin hresult();' & _
        'GetPinState hresult(ulong*);' ;            /* [out] */ __RPC__out ULONG *requestID

Global Const $sIID_IMbnPinManagerEvents = '{DCBBBAB6-2006-4BBB-AAEE-338E368AF6FA}'
Global Const $dtag_IMbnPinManagerEvents = _
        'OnPinListAvailable hresult();' & _
        'OnGetPinStateComplete hresult(' & _
        'ptr;' & _                              ; /* [in] */ __RPC__in_opt  IMbnPinManager *pinManager
        'struct;' & _                           ; /* [in] */ MBN_PIN_INFO   pinInfo
        'ulong;' & _                            ; /* [in] */ ULONG          requestID
        'hresult;)' ;                             /* [in] */ HRESULT        status
Global Const $tRIID_IMbnPinManagerEvents = _WinAPI_GUIDFromString($sIID_IMbnPinManagerEvents)


Global Const $sIID_IConnectionPointContainer = '{B196B284-BAB4-101A-B69C-00AA00341D07}'
Global Const $dtag_IConnectionPointContainer = _
        'EnumConnectionPoints hresult();' & _
        'FindConnectionPoint hresult(clsid;ptr*;);'; /* [in] */ __RPC__in REFIID riid | /* [out] */ __RPC__deref_out_opt IConnectionPoint **ppCP


Global Const $sIID_IConnectionPoint = '{B196B286-BAB4-101A-B69C-00AA00341D07}'
Global Const $dtag_IConnectionPoint = _
        'GetConnectionInterface hresult();' & _
        'GetConnectionPointContainer hresult();' & _
        'Advise hresult(ptr;dword*;);' & _ ;      /* [in] */ __RPC__in_opt IUnknown *pUnkSink,  /* [out] */ __RPC__out DWORD *pdwCookie
        'Unadvise hresult(dword);' & _
        'EnumConnections hresult();'

Global Const $CLSID_MbnInterfaceManager = '{BDFEE05B-4418-11DD-90ED-001C257CCFF1}' ;MbnInterfaceManager
Global Const $sIID_IMbnInterfaceManager = '{DCBBBAB6-201B-4BBB-AAEE-338E368AF6FA}'
Global Const $dtag_IMbnInterfaceManager = _
        'GetInterface hresult();' & _
        'GetInterfaces hresult(ptr*);' ;            /* [retval][ref][out] */ __RPC__deref_out_opt SAFEARRAY * *mbnInterfaces

#EndRegion Const


;~ https://msdn.microsoft.com/en-us/library/windows/desktop/dd430416(v=vs.85).aspx
Local $oMbnInterfaceManager = ObjCreateInterface($CLSID_MbnInterfaceManager, $sIID_IMbnInterfaceManager, $dtag_IMbnInterfaceManager)
If @error Then Exit -@ScriptLineNumber

;https://msdn.microsoft.com/en-us/library/windows/desktop/dd430421%28v=vs.85%29.aspx
Local $p_mbnInterfaces
$oMbnInterfaceManager.GetInterfaces($p_mbnInterfaces)
If @error Or Not $p_mbnInterfaces Then Exit -@ScriptLineNumber

Local $iBound
SafeArrayGetUBound($p_mbnInterfaces, $iBound)
If @error Or $iBound < 0 Then Exit -@ScriptLineNumber

;Get first
Local $p_mbnInterface, $iIndex = 0
SafeArrayGetElement($p_mbnInterfaces, $iIndex, $p_mbnInterface)
If @error Or Not $p_mbnInterface Then Exit -@ScriptLineNumber

;~ https://msdn.microsoft.com/en-us/library/windows/desktop/dd323117(v=vs.85).aspx
Local $oIMbnPinManager = ObjCreateInterface($p_mbnInterface, $sIID_IMbnPinManager, $dtag_IMbnPinManager)
If @error Then Exit -@ScriptLineNumber


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

;~ 1) Get an IConnectionPointContainer interface by calling QueryInterface on an IMbnInterfaceManager object.
;~ 2) Call FindConnectionPoint on the returned interface and pass IID_IMbnPinManagerEvents to riid.
;~ 3) Call Advise on the returned connection point and pass a pointer to an IUnknown interface on an object that implements IMbnPinManagerEvents to pUnk.

;1 STEP
Local $oIConnectionPointContainer = ObjCreateInterface($CLSID_MbnInterfaceManager, $sIID_IConnectionPointContainer, $dtag_IConnectionPointContainer)
If @error Then Exit -@ScriptLineNumber

;2 STEP
Local $p_IConnectionPoint
$oIConnectionPointContainer.FindConnectionPoint($tRIID_IMbnPinManagerEvents, $p_IConnectionPoint)
If @error Or Not $p_IConnectionPoint Then Exit -@ScriptLineNumber

Local $oIConnectionPoint = ObjCreateInterface($p_IConnectionPoint, $sIID_IConnectionPoint, $dtag_IConnectionPoint)
If @error Then Exit -@ScriptLineNumber

;3 STEP
;~ https://msdn.microsoft.com/en-us/library/windows/desktop/dd323119%28v=vs.85%29.aspx
Local $tIMbnPinManagerEvents
Local $oIMbnPinManagerEvents = ObjectFromTag("oIMbnPinManagerEvents_", $dtag_IMbnPinManagerEvents, $tIMbnPinManagerEvents)
If @error Then Exit -@ScriptLineNumber

Local $p_IUnknown = $oIMbnPinManagerEvents()

;~ https://msdn.microsoft.com/en-us/library/windows/desktop/ms678815(v=vs.85).aspx
Local $pdwCookie
$oIConnectionPoint.Advise($p_IUnknown, $pdwCookie)
If @error Or Not $pdwCookie Then
    ConsoleWrite('! Connection was not successfully established' & @CRLF)
    Exit -@ScriptLineNumber
EndIf

;~ 4 STEP
;~ https://msdn.microsoft.com/en-us/library/windows/desktop/dd323117%28v=vs.85%29.aspx
;Call GetPinState and wait events
Local $iRequestID
$oIMbnPinManager.GetPinState($iRequestID)
If @error Or Not $iRequestID Then Exit -@ScriptLineNumber

ConsoleWrite('> Wait events for request: ' & $iRequestID & @CRLF)

AdlibRegister('_exit', 5000)

While 1
    Sleep(250)
WEnd

;Console Output


;~ QueryInterface {0000013D-0000-0000-C000-000000000046}    ;IClientSecurity
;~ QueryInterface {0000001B-0000-0000-C000-000000000046}    ;?
;~ QueryInterface {00000003-0000-0000-C000-000000000046}    ;IMarshal
;~ > Wait events for request: 152
;~ QueryInterface {0000001B-0000-0000-C000-000000000046}    ;?
;~ QueryInterface {00000018-0000-0000-C000-000000000046}    ;IStdMarshalInfo
;~ QueryInterface {00000019-0000-0000-C000-000000000046}    ;IExternalConnection
;~ QueryInterface {4C1E39E1-E3E3-4296-AA86-EC938D896E92}    ;?
;~ QueryInterface {1C733A30-2A1C-11CE-ADE5-00AA0044773D}    ;ICallFactory

;~ + OnGetPinStateComplete event            ;Event fired
;~ > $pIMbnPinManager: 0x00BB9684           ;WHY THE SAME?
;~ > $pPinInfo: 0x00BB9684                  ;WHY THE SAME?
;~ > $iRequestID: 0                         ;0 ?
;~ > $iStatus: 3                            ;3 ?
;~ > pinState: 12208352                     ;bla
;~ > pinType: 1                             ;bla
;~ > attemptsRemaining: 12194924            ;bla

Exit


Func _exit()
    AdlibUnRegister('_exit')
    $oIConnectionPoint.Unadvise($pdwCookie)
    Exit
EndFunc   ;==>_exit


Func oIMbnPinManagerEvents_OnGetPinStateComplete($pSelf, $pIMbnPinManager, $pPinInfo, $iRequestID, $iStatus) ; Ret: long  Par: ptr;struct;ulong;long
;~  https://msdn.microsoft.com/en-us/library/windows/desktop/dd323119%28v=vs.85%29.aspx
    ConsoleWrite('+ OnGetPinStateComplete event' & @CRLF)

    ConsoleWrite('> $pIMbnPinManager: ' & $pIMbnPinManager & @CRLF)
    ConsoleWrite('> $pPinInfo: ' & $pPinInfo & @CRLF)
    ConsoleWrite('> $iRequestID: ' & $iRequestID & @CRLF)
    ConsoleWrite('> $iStatus: ' & $iStatus & @CRLF)

    ;Ok. Now create a MBN_PIN_INFO struct
;~  https://msdn.microsoft.com/en-us/library/windows/desktop/dd323226(v=vs.85).aspx
    Local Static $tagMBN_PIN_INFO = 'struct;dword pinState;dword pinType;ulong attemptsRemaining;endstruct'
    Local $tMBN_PIN_INFO = DllStructCreate($tagMBN_PIN_INFO, $pPinInfo)
    If Not @error Then
        ConsoleWrite('> pinState: ' & DllStructGetData($tMBN_PIN_INFO, 'pinState') & @CRLF)
        ConsoleWrite('> pinType: ' & DllStructGetData($tMBN_PIN_INFO, 'pinType') & @CRLF)
        ConsoleWrite('> attemptsRemaining: ' & DllStructGetData($tMBN_PIN_INFO, 'attemptsRemaining') & @CRLF)
    EndIf

    Return $S_OK
EndFunc   ;==>oIMbnPinManagerEvents_OnGetPinStateComplete


Func oIMbnPinManagerEvents_OnPinListAvailable($pSelf) ; Ret: long
    Return $S_OK
EndFunc   ;==>oIMbnPinManagerEvents_OnPinListAvailable
Func oIMbnPinManagerEvents_QueryInterface($pSelf, $pRIID, $pObj) ; Ret: long  Par: ptr;ptr
    Local $sIID = StringFromGUID($pRIID)
    If $sIID = $sIID_IUnknown Then
        DllStructSetData(DllStructCreate("ptr", $pObj), 1, $pSelf)
        Return $S_OK
    ElseIf $sIID = $sIID_IMbnPinManagerEvents Then
        DllStructSetData(DllStructCreate("ptr", $pObj), 1, $pSelf)
        Return $S_OK
    Else
        ConsoleWrite('QueryInterface ' & $sIID & @CRLF)
        Return $E_NOINTERFACE
    EndIf
EndFunc   ;==>oIMbnPinManagerEvents_QueryInterface
Func oIMbnPinManagerEvents_AddRef($pSelf) ; Ret: dword
    Return 1
EndFunc   ;==>oIMbnPinManagerEvents_AddRef
Func oIMbnPinManagerEvents_Release($pSelf) ; Ret: dword
    Return 1
EndFunc   ;==>oIMbnPinManagerEvents_Release

Func StringFromGUID($pGUID)
    Local $aResult = DllCall("ole32.dll", "int", "StringFromGUID2", "struct*", $pGUID, "wstr", "", "int", 40)
    If @error Then Return SetError(@error, @extended, "")
    Return SetExtended($aResult[0], $aResult[2])
EndFunc   ;==>StringFromGUID

Func ObjectFromTag($sFunctionPrefix, $tagInterface, ByRef $tInterface, $fPrint = False, $bIsUnknown = Default, $sIID = "{00000000-0000-0000-C000-000000000046}") ; last param is IID_IUnknown by default
    If $bIsUnknown = Default Then $bIsUnknown = True
    Local $sInterface = $tagInterface ; copy interface description
    Local $tagIUnknown = "QueryInterface hresult(ptr;ptr*);" & _
            "AddRef dword();" & _
            "Release dword();"
    ; Adding IUnknown methods
    If $bIsUnknown Then $tagInterface = $tagIUnknown & $tagInterface
    ; Below line is really simple even though it looks super complex. It's just written weird to fit in one line, not to steal your attention
    Local $aMethods = StringSplit(StringReplace(StringReplace(StringReplace(StringReplace(StringTrimRight(StringReplace(StringRegExpReplace(StringRegExpReplace($tagInterface, "\w+\*", "ptr"), "\h*(\w+)\h*(\w+\*?)\h*(\((.*?)\))\h*(;|;*\z)", "$1\|$2;$4" & @LF), ";" & @LF, @LF), 1), "object", "idispatch"), "hresult", "long"), "bstr", "ptr"), "variant", "ptr"), @LF, 3)
    Local $iUbound = UBound($aMethods)
    Local $sMethod, $aSplit, $sNamePart, $aTagPart, $sTagPart, $sRet, $sParams, $hCallback
    ; Allocation
    $tInterface = DllStructCreate("int RefCount;int Size;ptr Object;ptr Methods[" & $iUbound & "];int_ptr Callbacks[" & $iUbound & "];ulong_ptr Slots[16]") ; 16 pointer sized elements more to create space for possible private props
    If @error Then Return SetError(1, 0, 0)
    For $i = 0 To $iUbound - 1
        $aSplit = StringSplit($aMethods[$i], "|", 2)
        If UBound($aSplit) <> 2 Then ReDim $aSplit[2]
        $sNamePart = $aSplit[0]
        $sTagPart = $aSplit[1]
        $sMethod = $sFunctionPrefix & $sNamePart
        If $fPrint Then
            Local $iPar = StringInStr($sTagPart, ";", 2), $t
            If $iPar Then
                $t = "Ret: " & StringLeft($sTagPart, $iPar - 1) & "  " & _
                        "Par: " & StringRight($sTagPart, StringLen($sTagPart) - $iPar)
            Else
                $t = "Ret: " & $sTagPart
            EndIf
            Local $s = "Func " & $sMethod & _
                    "( $pSelf ) ; " & $t & @CRLF & _
                    "EndFunc" & @CRLF
            ConsoleWrite($s)
        EndIf
        $aTagPart = StringSplit($sTagPart, ";", 2)
        $sRet = $aTagPart[0]
        $sParams = StringReplace($sTagPart, $sRet, "", 1)
        $sParams = "ptr" & $sParams
        $hCallback = DllCallbackRegister($sMethod, $sRet, $sParams)
        If @error Then
            ConsoleWrite('! ' & @error & ' ' & $sMethod & @CRLF & @CRLF)
        EndIf

        DllStructSetData($tInterface, "Methods", DllCallbackGetPtr($hCallback), $i + 1) ; save callback pointer
        DllStructSetData($tInterface, "Callbacks", $hCallback, $i + 1) ; save callback handle
    Next
    DllStructSetData($tInterface, "RefCount", 1) ; initial ref count is 1
    DllStructSetData($tInterface, "Size", $iUbound) ; number of interface methods
    DllStructSetData($tInterface, "Object", DllStructGetPtr($tInterface, "Methods")) ; Interface method pointers
    Return ObjCreateInterface(DllStructGetPtr($tInterface, "Object"), $sIID, $sInterface, $bIsUnknown) ; pointer that's wrapped into object
EndFunc   ;==>ObjectFromTag

 

 

Edited by Inververs
solved

Share this post


Link to post
Share on other sites



After a quick look at the code, I can see a little mistake. "struct" in definition of IMbnPinManagerEvents interface must be "struct*":

; Replace
'struct;' & _                           ; /* [in] */ MBN_PIN_INFO   pinInfo
; with
'struct*;' & _                           ; /* [in] */ MBN_PIN_INFO   pinInfo

You can try to correct this for a start.

Share this post


Link to post
Share on other sites

If change to struct*, than i get this in OnGetPinStateComplete event:

+ OnGetPinStateComplete event
> $pIMbnPinManager: 0x00933D44
> $pPinInfo: 0x00000000
> $iRequestID: 0
> $iStatus: 3

$pPinInfo became null.

So It did not help

Share this post


Link to post
Share on other sites

What does $iStatus = 3 mean? Since $iStatus <> 0 the operation failed, and that's probably the reason why $pPinInfo and $iRequestID are not set.

As you have managed to create all the interface objects, there seems not to be any obvious errors.

Do you know if this code works? Do you have some C++ code to verify that the code works. If the C++ code works, it's usually possible to get the AutoIt code to work too. On the other hand. If it's not possible to get the C++ code to work, then it's also not possible to have the AutoIt code to work.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

When you create the callback in the parameters you do this.  ptr;ptr;struct;ulong;long. Don't use struct, use ptr instead.

dllcallbackregister remarks says: Uses all DllCall() types except "struct". for that reason you get $pIMbnPinManager same as $pPinInfo. So if you use  ptr;ptr;ptr;ulong;long you should get correct pointer to MBN_PIN_INFO structure.

 

Saludos

 

Edited by Danyfirex
write more

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Honestly, i have no idea what is the status 3
If msdn on this page said, https://msdn.microsoft.com/en-us/library/windows/desktop/dd323119(v=vs.85).aspx
that status  can expect one of the following values:
S_OK
HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED)
E_MBN_SIM_NOT_INSERTED
E_MBN_BAD_SIM

in sdk i can find this constants
E_MBN_SIM_NOT_INSERTED           _HRESULT_TYPEDEF_(0x8054820AL)
E_MBN_BAD_SIM                    _HRESULT_TYPEDEF_(0x80548202L)

but what 3 meen, i dont know.
I am inclined to believe that callback is not working properly.

No working code in C++. I'm trying to make it from scratch, using only the information from the site
But, i have working command in netsh which is able to determine the status of the pin,
and I can not say it uses an this API, or something else.

netsh mbn show pin interface=*
result is:
    Тип ПИН-кода           : Pin1
    Состояние ПИН-кода          : Ввод
    Количество оставшихся попыток: 3
    
What can be translated as:
    Type PIN: Pin1
    Status PIN: Input
    The number of remaining attempts: 3
    
This is very similar to the data that are located in the structure MBN_PIN_INFO

typedef struct MBN_PIN_INFO {
  MBN_PIN_STATE pinState;
  MBN_PIN_TYPE  pinType;
  ULONG         attemptsRemaining;
} MBN_PIN_INFO;

, but as you can see, the access to which I can not get.

Edited by Inververs

Share this post


Link to post
Share on other sites

¿did you read? what I wrote...

Share this post


Link to post
Share on other sites

Danyfirex, so read, did not have time to answer, I'm sorry.

I change to this

Global Const $dtag_IMbnPinManagerEvents = _
        'OnPinListAvailable hresult();' & _
        'OnGetPinStateComplete hresult(' & _
        'ptr;' & _                              ; /* [in] */ __RPC__in_opt  IMbnPinManager *pinManager
        'ptr;' & _                              ; /* [in] */ MBN_PIN_INFO   pinInfo
        'ulong;' & _                            ; /* [in] */ ULONG          requestID
        'hresult;)' ;                             /* [in] */ HRESULT        status

but it still does not work

Share this post


Link to post
Share on other sites
Global Const $dtag_IMbnPinManagerEvents = _
        'OnPinListAvailable hresult();' & _
        'OnGetPinStateComplete hresult(' & _
        'ptr;' & _                              ; /* [in] */ __RPC__in_opt  IMbnPinManager *pinManager
        'ptr;' & _                              ; /* [in] */ MBN_PIN_INFO   pinInfo
        'ulong;' & _                            ; /* [in] */ ULONG          requestID
        'long;)' ;                              /* [in] */ HRESULT      status

It does not work to

Share this post


Link to post
Share on other sites

why you use 5 parameters in oIMbnPinManagerEvents_OnGetPinStateComplete($pSelf, $pIMbnPinManager, $pPinInfo, $iRequestID, $iStatus).? it just say 4 as far I see.

Share this post


Link to post
Share on other sites

someone wrote that

methods for objects created with ObjectFromTag allways have $pSelf as first parameter

Share this post


Link to post
Share on other sites

ObjectFromTag is a function coded by trancexx. There are several versions of this function. It is important to use the latest. But as far as I can see, it is the latest version.

Share this post


Link to post
Share on other sites

I did not know it.  making that I said. You till got $pIMbnPinManager: 0x00BB9684     $pPinInfo: 0x00BB9684 ?

 

Saludos

 

Share this post


Link to post
Share on other sites
Global Const $dtag_IMbnPinManagerEvents = _
        'OnPinListAvailable hresult();' & _
        'OnGetPinStateComplete hresult(' & _
        'ptr;' & _                              ; /* [in] */ __RPC__in_opt  IMbnPinManager *pinManager
        'ptr;' & _                              ; /* [in] */ MBN_PIN_INFO   pinInfo
        'ulong;' & _                            ; /* [in] */ ULONG          requestID
        'long;)' ;                              ; /* [in] */ HRESULT        status

> Wait events for request: 250

This when device pin1 require:
+ OnGetPinStateComplete event
> $pIMbnPinManager: 0x0076A0AC
> $pPinInfo: 0x00000001
> $iRequestID: 2
> $iStatus: 3

Then when device unblocked(pin entered)

> Wait events for request: 251

+ OnGetPinStateComplete event
> $pIMbnPinManager: 0x00B2D09C
> $pPinInfo: 0x00000000
> $iRequestID: 0
> $iStatus: 3

Share this post


Link to post
Share on other sites

These events do not work as expected.
If you take other functions, then everything is OK
This code provides:
> Pin format: MBN_PIN_FORMAT_NUMERIC
> Pin type: MBN_PIN_TYPE_PIN1
> $oIMbnPin.get_PinLengthMin 4
> $oIMbnPin.get_PinLengthMax 8

 

Local Const $MBN_PIN_TYPE_CUSTOM = 0x1, $MBN_PIN_TYPE_PIN1 = 0x2
Local $p_IMbnPin

$oIMbnPinManager.GetPin($MBN_PIN_TYPE_PIN1, $p_IMbnPin)

Local $oIMbnPin = ObjCreateInterface($p_IMbnPin, $sIID_IMbnPin, $dtag_IMbnPin)
If @error Then Exit -@ScriptLineNumber

Local $iPinFormat
$oIMbnPin.get_PinFormat($iPinFormat)

Switch $iPinFormat
    Case 0x0
        ConsoleWrite('> Pin format: ' & 'MBN_PIN_FORMAT_NONE' & @CRLF)
    Case 0x1
        ConsoleWrite('> Pin format: ' & 'MBN_PIN_FORMAT_NUMERIC' & @CRLF)
    Case 0x2
        ConsoleWrite('> Pin format: ' & 'MBN_PIN_FORMAT_ALPHANUMERIC' & @CRLF)
EndSwitch

Local $iPinType
$oIMbnPin.get_PinType($iPinType)
ConsoleWrite('> Pin type: ')
Switch $iPinType
    Case 0x00
        ConsoleWrite('MBN_PIN_TYPE_NONE' & @CRLF)
    Case 0x1
        ConsoleWrite('MBN_PIN_TYPE_CUSTOM' & @CRLF)
    Case 0x2
        ConsoleWrite('MBN_PIN_TYPE_PIN1' & @CRLF)
    Case 0x3
        ConsoleWrite('MBN_PIN_TYPE_PIN2' & @CRLF)
    Case 0x4
        ConsoleWrite('MBN_PIN_TYPE_DEVICE_SIM_PIN' & @CRLF)
    Case 0x5
        ConsoleWrite('MBN_PIN_TYPE_DEVICE_FIRST_SIM_PIN' & @CRLF)
    Case 0x6
        ConsoleWrite('MBN_PIN_TYPE_NETWORK_PIN' & @CRLF)
    Case 0x7
        ConsoleWrite('MBN_PIN_TYPE_NETWORK_SUBSET_PIN' & @CRLF)
    Case 0x8
        ConsoleWrite('MBN_PIN_TYPE_SVC_PROVIDER_PIN' & @CRLF)
    Case 0x9
        ConsoleWrite('MBN_PIN_TYPE_CORPORATE_PIN' & @CRLF)
    Case 0xA
        ConsoleWrite('MBN_PIN_TYPE_SUBSIDY_LOCK' & @CRLF)
EndSwitch

Local $iPinLengthMin, $iPinLengthMax
$oIMbnPin.get_PinLengthMin($iPinLengthMin)
$oIMbnPin.get_PinLengthMax($iPinLengthMax)

ConsoleWrite('> $oIMbnPin.get_PinLengthMin ' & $iPinLengthMin & @CRLF)
ConsoleWrite('> $oIMbnPin.get_PinLengthMax ' & $iPinLengthMax & @CRLF)

 

Share this post


Link to post
Share on other sites

ObjectFromTag is a function coded by trancexx. There are several versions of this function. It is important to use the latest. But as far as I can see, it is the latest version.

yes, correct. and she said this phrase.

Share this post


Link to post
Share on other sites

funnily,  1 2 3 in the parameters

Share this post


Link to post
Share on other sites

Wait, that's exactly what netsh shows. Right?

Then maybe try it like this:

Global Const $dtag_IMbnPinManagerEvents = _
        'OnPinListAvailable hresult();' & _
        'OnGetPinStateComplete hresult(' & _
        'ptr;' & _                              ; /* [in] */ __RPC__in_opt  IMbnPinManager *pinManager

        'int;int;ulong;' & _                           ; /* [in] */ MBN_PIN_INFO   pinInfo

        'ulong;' & _                            ; /* [in] */ ULONG          requestID

        'hresult;)' ;                             /* [in] */ HRESULT        status
        
;...

Func oIMbnPinManagerEvents_OnGetPinStateComplete($pSelf, $pIMbnPinManager, $pinState, $pinType, $attemptsRemaining, $iRequestID, $iStatus)
;~  https://msdn.microsoft.com/en-us/library/windows/desktop/dd323119%28v=vs.85%29.aspx

    ConsoleWrite('+ OnGetPinStateComplete event' & @CRLF)

    ConsoleWrite('> $pIMbnPinManager: ' & $pIMbnPinManager & @CRLF)

    ConsoleWrite('> $pinState: ' & $pinState & @CRLF)
    ConsoleWrite('> $pinType: ' & $pinType & @CRLF)
    ConsoleWrite('> $attemptsRemaining: ' & $attemptsRemaining & @CRLF)

    ConsoleWrite('> $iRequestID: ' & $iRequestID & @CRLF)
    ConsoleWrite('> $iStatus: ' & $iStatus & @CRLF)

    Return $S_OK
EndFunc

 

3 people like this

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

ingenious, it works!

Pin entered:

> Wait events for request: 274

+ OnGetPinStateComplete event
> $pIMbnPinManager: 0x00A2CBEC
> $pinState: 0
> $pinType: 0
> $attemptsRemaining: 3
> $iRequestID: 274
> $iStatus: 0

Pin required:

> Wait events for request: 275
+ OnGetPinStateComplete event
> $pIMbnPinManager: 0x0099AC74
> $pinState: 1
> $pinType: 2
> $attemptsRemaining: 3
> $iRequestID: 275
> $iStatus: 0

trancexx, thanks a lot!

As I understand it, the structure should be expand in dtag...?

 

 

 

Share this post


Link to post
Share on other sites

MSDN play us a joke. nowhere says pointer to  MBN_PIN_INFO just add the parameter as nested way. another Great one Trancexx. 

 

@Inververs could you pass SafeArray.au3. I would like to play a little with your code.

 

Saludos

Share this post


Link to post
Share on other sites

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

    • nhardel
      By nhardel
      So I have been bashing my head in for a couple days and have searched both AutoIT forums and Thwack Forums for an answer.  I understand this could be hard to help sense I can't provide a server for someone to help me test against.  I am trying to use the WinHTTP.au3 to connect with Solarwinds Orion SDK thru REST/JSON api calls.  Here is the documentation that they provide.
      https://github.com/solarwinds/OrionSDK/wiki/REST
      I have been trying just to make a basic connection but for some reason cannot get past the authorization process with WinHTTP.  Here is my test code.
      #Region Includes #include <log4a.au3> #include "WinHttp.au3" #EndRegion Global $sAddress = "https://usandl0213:17778/SolarWinds/InformationService/v3/Json/Query?query=SELECT+NodeID+FROM+Orion.NODES" Global $array_URL = _WinHttpCrackUrl($sAddress) ;~ Row|Col 0 ;~ [0]|https ;~ [1]|2 ;~ [2]|usandl0213 ;~ [3]|17778 ;~ [4]| ;~ [5]| ;~ [6]|/SolarWinds/InformationService/v3/Json/Query ;~ [7]|?query=SELECT+NodeID+FROM+Orion.NODES Global $hOpen = _winhttpOpen() If @error Then _log4a_Fatal("Error intializing the usage of WinHTTP functions") Exit 1 EndIf Global $hConnect = _winhttpConnect($hOpen, $array_URL[2]) If @error Then _log4a_Fatal("Error specifying the initial target server of an HTTP request.") _WinHttpCloseHandle($hOpen) Exit 2 EndIf Global $hRequest = _WinHttpOpenRequest($hConnect, _ "GET", _ "/SolarWinds/InformationService/v3/Json/Query?query=SELECT+NodeID+FROM+Orion.NODES", _ "HTTP/1.1") If @error Then _log4a_Fatal(MsgBox(48, "Error", "Error creating an HTTP request handle.") _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) Exit 3 EndIf _WinHttpAddRequestHeaders($hRequest, "Authorization: Basic YXV0b2l0X2xvZ2luOnRlc3Q=") _WinHttpAddRequestHeaders($hRequest, "User-Agent: curl/7.20.0 (i386-pc-win32) libcurl/7.20.0 OpenSSL/0.9.8l zlib/1.2.3") _WinHttpAddRequestHeaders($hRequest, "Host: usandl0213:17778") _WinHttpAddRequestHeaders($hRequest, "Accept: */*") _WinHttpSendRequest($hRequest) If @error Then MsgBox(48, "Error", "Error sending specified request.") Close_request() Exit 4 EndIf ; Wait for the response _WinHttpReceiveResponse($hRequest) If @error Then MsgBox(48, "Error", "Error waiting for the response from the server.") Close_request() Exit 5 EndIf Global $sChunk, $sData ; See what's returned If _WinHttpQueryDataAvailable($hRequest) Then Global $sHeader = _WinHttpQueryHeaders($hRequest) ;~ ConsoleWrite(@crlf) ConsoleWrite($sHeader & @CRLF) ; Read While 1 $sChunk = _WinHttpReadData($hRequest) If @error Then ExitLoop $sData &= $sChunk WEnd ConsoleWrite($sData & @CRLF) ; print to console Else MsgBox(48, "Error", "Site is experiencing problems.") EndIf Close_request() Func Close_request() ; Close open handles and exit _WinHttpCloseHandle($hRequest) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) EndFunc I am definitely connecting to the server but get a 401 Unauthorized response.  Output of above script:
      Header:
      HTTP/1.1 401 Unauthorized Cache-Control: private Date: Thu, 27 Jul 2017 15:31:21 GMT Content-Length: 1668 Content-Type: text/html; charset=utf-8 Server: Microsoft-IIS/7.5 Set-Cookie: ASP.NET_SessionId=lgwin2qsbbrip2mxg01fot05; path=/; HttpOnly Set-Cookie: TestCookieSupport=Supported; path=/ Set-Cookie: Orion_IsSessionExp=TRUE; expires=Thu, 27-Jul-2017 17:31:21 GMT; path=/ WWW-Authenticate: Negotiate WWW-Authenticate: NTLM X-UA-Compatible: IE=9 X-AspNet-Version: 4.0.30319 X-Powered-By: ASP.NET X-Same-Domain: 1 X-Content-Type-Options: nosniff X-Frame-Options: SAMEORIGIN X-XSS-Protection: 1; mode=block Body:
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head><link rel="stylesheet" type="text/css" href="/orion/js/jquery-1.7.1/jquery-ui.css.i18n.ashx?l=en-US&v=42660.90.L&csd=%23b0b9c5;%23d2ddec;%2392add1;" /> <link rel="stylesheet" type="text/css" href="/orion/styles/orionminreqs.css.i18n.ashx?l=en-US&v=42660.90.L&csd=%23b0b9c5;%23d2ddec;%2392add1;" /> <link rel="stylesheet" type="text/css" href="/webengine/resources/steelblue.css.i18n.ashx?l=en-US&v=42660.90.L&csd=%23b0b9c5;%23d2ddec;%2392add1;" /> <link rel="stylesheet" type="text/css" href="/orion/ipam/res/css/sw-events.css.i18n.ashx?l=en-US&v=42660.90.L&csd=%23b0b9c5;%23d2ddec;%2392add1;" /> <script type="text/javascript" src="/orion/js/orionminreqs.js.i18n.ashx?l=en-US&v=42660.90.L"></script> <script type="text/javascript" src="/orion/js/modernizr/modernizr-2.5.3.js.i18n.ashx?l=en-US&v=42660.90.L"></script> <script type="text/javascript" src="/orion/js/jquery-1.7.1/jquery-1.7.1.framework.min.js.i18n.ashx?l=en-US&v=42660.90.L"></script> <script type="text/javascript">(function(){var de=$(document.documentElement); de.addClass('sw-is-locale-en'); $.each(jQuery.browser,function(k,v){if(v===true){ de.addClass('sw-is-'+k); de.addClass('sw-is-'+k+'-'+parseInt(jQuery.browser.version)); }}); })();</script> <script type="text/javascript">SW.Core.Loader._cbLoaded('jquery');</script> <script type="text/javascript">SW.Core.Date._init(0,-14400000);</script> <title> </title></head> <body> <script> window.location = 'Login.aspx'; </script> </body> </html> To me this looks like it if it is still looking for my credentials.   I did verify that things work as expected using Chrome and REST test client.  I do get certificate errors in IE if I try to go directly.  Bypass certificate issues and page will try to save out to .json file
       
      Looking for any help.
    • mLipok
      By mLipok
      Recently I was working on TeamVierwer API .
      I had a little break, and wanted to check out another platform.
      Here is the result of my attempt:
      #include "GHAPI.au3" _GHAPI_AccessToken('b3e8.....de..........bdc3a0c.....bd27c6f') _GHAPI_GetUser("users/mLipok") _GHAPI_GetUserOrganizations("users/mLipok") _GHAPI_RootEndpoints() and GHAPI.au3
      #include-once #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w 7 #Tidy_Parameters=/sort_funcs /reel #Region GHAPI.au3 - Header ; #INDEX# ======================================================================================================================= ; Title .........: GHAPI UDF ; AutoIt Version : 3.3.10.2++ ; Language ......: English ; Description ...: This is an UDF for for communicate with https://api.github.com via GitHub RESTful API ; Author(s) .....: mLipok ; Modified ......: ; =============================================================================================================================== #cs Title: GHAPI UDF Filename: GHAPI.au3 Description: This is an UDF for for communicate with https://api.github.com via GitHub RESTful API Author: mLipok Modified: Last Update: 2017/05/23 Requirements: AutoIt 3.3.10.2 or higher #ce #EndRegion GHAPI.au3 - Header #Region GHAPI.au3 - Include #include <array.au3> #include <FileConstants.au3> #include <MsgBoxConstants.au3> #EndRegion GHAPI.au3 - Include #Region GHAPI.au3 - Declarations Global $oErrorHandler = ObjEvent("AutoIt.Error", "_GHAPI_ErrFunc") Global $__g_sGitHubAPI_BaseUrl = "https://api.github.com" ; URL of the GitHub API Global $__g_sGitHubAPI_Version = "v3" ; Put the current API version in here Global Enum _ $GHAPI_ERR_SUCCESS, _ $GHAPI_ERR_GENERAL, _ $GHAPI_ERR_COMERROR, _ $GHAPI_ERR_STATUS, _ $GHAPI_ERR_COUNTER Global Enum _ $GHAPI_EXT_DEFAULT, _ $GHAPI_EXT_PARAM1, _ $GHAPI_EXT_PARAM2, _ $GHAPI_EXT_PARAM3, _ $GHAPI_EXT_COUNTER Global Enum _ $GHAPI_RET_SUCCESS, _ $GHAPI_RET_FAILURE, _ $GHAPI_RET_COUNTER #EndRegion GHAPI.au3 - Declarations #Region GHAPI.au3 - API Functions Func _GHAPI_ErrFunc($oError) ; Do anything here. ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _ @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _ @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc ;==>_GHAPI_ErrFunc Func _GHAPI_AccessToken($sParam = Default) ; https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/ ; https://github.com/settings/tokens Local Static $sAccessToken = '' If $sParam <> Default Then $sAccessToken = $sParam Return $sAccessToken EndFunc ;==>_GHAPI_AccessToken Func _GHAPI_GetUser($sUser) Local $oHTTP = __GHAPI_HTTP_Open("GET", $sUser) Local $oJSON = __GHAPI_HTTP_Send($oHTTP) If @error Then Return SetError(@error, @extended, False) #forceref $oJSON EndFunc ;==>_GHAPI_GetUser Func _GHAPI_GetUserOrganizations($sUser) Local $oHTTP = __GHAPI_HTTP_Open("GET", $sUser & '/orgs') Local $oJSON = __GHAPI_HTTP_Send($oHTTP) If @error Then Return SetError(@error, @extended, False) #forceref $oJSON EndFunc ;==>_GHAPI_GetUserOrganizations Func _GHAPI_RootEndpoints() Local $oHTTP = __GHAPI_HTTP_Open("GET", '') Local $oJSON = __GHAPI_HTTP_Send($oHTTP) If @error Then Return SetError(@error, @extended, False) #forceref $oJSON EndFunc ;==>_GHAPI_RootEndpoints #EndRegion GHAPI.au3 - API Functions #Region GHAPI.au3 - INTERNAL Functions Func __GHAPI_HTTP_Open($sMethod, $sCommand, $sURLParameters = '') Local $oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1") Local $sURL = $__g_sGitHubAPI_BaseUrl & "/" & $sCommand & $sURLParameters ;~ __GHAPI_DebugOut("> $sURL=" & $sURL & @CRLF) $oHTTP.Open($sMethod, $sURL, False) If @error Then Return SetError(@error, @extended, Null) $oHTTP.setRequestHeader("Authorization", "Bearer " & _GHAPI_AccessToken()) ; Accept: application/vnd.github.v3+json $oHTTP.setRequestHeader("Accept", "application/vnd.github." & $__g_sGitHubAPI_Version & "+json") ; User-Agent: Awesome-Octocat-App $oHTTP.setRequestHeader("User-Agent", "AutoIt UDF") Return $oHTTP EndFunc ;==>__GHAPI_HTTP_Open Func __GHAPI_HTTP_Send(ByRef $oHTTP, $sSendParameter = Default) If $sSendParameter = Default Then $oHTTP.Send() Else $oHTTP.Send($sSendParameter) EndIf ConsoleWrite('+' & $oHTTP.Status & @CRLF) ConsoleWrite('>' & $oHTTP.StatusText & @CRLF) ConsoleWrite($oHTTP.ResponseText & @CRLF) ConsoleWrite(@CRLF) If @error Then Return SetError(@error, @extended, $GHAPI_RET_FAILURE) ;~ Return SetError($GHAPI_ERR_SUCCESS, $oJSON.Size, $oJSON) EndFunc ;==>__GHAPI_HTTP_Send #EndRegion GHAPI.au3 - INTERNAL Functions #Region GHAPI.au3 - HOWTO / DOCS / HELP #CS https://developer.github.com/v3/ https://developer.github.com/v3/guides/ https://developer.github.com/program/ https://github.com/contact?form%5Bsubject%5D=New+GitHub+Integration https://developer.github.com/ http://stackoverflow.com/questions/28796941/github-api-authentication-with-msxml2-xmlhttp #CE #EndRegion GHAPI.au3 - HOWTO / DOCS / HELP  
      REMARKS:
      This is just a modest start up and not a whole fully workable UDF, just so for a try, but maybe someone will be useful
      Regards,
      mLipok
       
      EDIT 1:
      If you need to make it workable just ask about specyfic feature.
      EDIT 2:
      Some changes in using word "GitHub" - to meet this rules: https://github.com/logos
    • LeloDragneel
      By LeloDragneel
      Hey guys,
      I'm looking to implement an accurate voice recognition method in my program. I tried to understand the Microsoft SAPI API, read their online documentation and found it very confusing and unclear. (Like seriously, it's so bad and vague, but that's just my opinion). I have also tried using UTTER UDF, but could not get a grasp either, because you know, that's an extension UDF to Microsoft SAPI.
      Let's face it, the Google Speech Recognition is much more accurate than Microsoft SAPI (by far). Right now, I am determined to just use the Google Speech API. I have dug deep in regards to implementing the Google Speech API in AutoIT and I haven't found even one post about it. I suppose it's because the Google Speech API was only recently made available to the public. In case you don't know what I'm talking about, here's the link to google api. On that page, notice that there is language support for various languages such as Java, C#, and PHP. However, there's no support for AutoIT. So my question is; how can I go about implementing the Google Speech API into my AutoIT program? Is it even possible?
      Cheers guys!
    • mLipok
      By mLipok
      This is TeamViewer.au3 UDF for TeamViewer API.
       
      ; #INDEX# ======================================================================== ; Title .........: TeamViewer.au3 ; AutoIt Version : 3.3.10.2++ ; Language ......: English ; Description ...: A collection of function for use with TeamViewer API ; Author ........: mLipok ; Modified ......: ; URL ...........: ; URL ...........: https://www.teamviewer.com/ ; URL ...........: https://www.teamviewer.com/en/integrations/ ; URL ...........: https://integrate.teamviewer.com/en/develop/api/get-started/ ; URL ...........: https://downloadeu1.teamviewer.com/integrate/TeamViewer_API_Documentation.pdf ; Remarks .......: This UDF was created based on TeamViewer_API_Documentation.pdf v 1.4.1 ; Remarks .......: This UDF is using Free Chilkat component look here https://www.autoitscript.com/forum/files/file/433-chilkat-udf/ ; Remarks .......: Documentation is "work in progress" ; Date ..........: 2017/02/08 ; Version .......: 0.1.1 BETA - Work in progress ; ================================================================================  
      I'm using TeamViewer_Example.ini to store my secret tokens/keys.
      [Settings] AccessToken= [OAuth2] ClientID= ClientSecret= authorizationCode=  
      in TeamViewer_Example.au3 you can see few examples:
      Func _Example() ; If not exist then create new INI file from template If Not FileExists('TeamViewer_Example.ini') Then FileCopy('TeamViewer_Example — Template.ini', 'TeamViewer_Example.ini') ; Read Access Token from INI Local $sTV_AccessToken = IniRead('TeamViewer_Example.ini', 'Settings', 'AccessToken', '') If $sTV_AccessToken = '' Then ; Your Access Token, can be left empty when OAuth (below) is configured. ; ClientId = <----------------- Create an app in your TeamViewer Management Console and insert the client ID to the INI ; ClientSecret = <------------- Insert your client secret to the INI ; AuthorizationCode = <-------- Visit https://webapi.teamviewer.com/api/v1/oauth2/authorize?response_type=code&client_id=YOUR$i_ClientIdHERE ; Login, grant the permissions (popup) and put the code shown in the AuthorizationCode variable to the INI Local $sTVOAuth_ClientID = IniRead('TeamViewer_Example.ini', 'OAuth2', 'ClientID', '') Local $sTVOAuth_ClientSecret = IniRead('TeamViewer_Example.ini', 'OAuth2', 'ClientSecret', '') _IECreate('https://webapi.teamviewer.com/api/v1/oauth2/authorize?response_type=code&client_id=' & $sTVOAuth_ClientID) ; Local $sTVOAuth_AuthorizationCode = IniRead('TeamViewer_Example.ini', 'OAuth2', 'authorizationCode', '') Local $sTVOAuth_AuthorizationCode = InputBox('AuthorizationCode', 'Please provide TV OAuth2 AuthorizationCode') If @error Then Return If $sTVOAuth_ClientID Then $sTV_AccessToken = _TVAPI_RequestOAuth2_AccessToken($sTVOAuth_ClientID, $sTVOAuth_ClientSecret, $sTVOAuth_AuthorizationCode) EndIf If $sTV_AccessToken Then _TVAPI_AccessToken($sTV_AccessToken) If _TVAPI_Ping() = True Then ; ping API to check connection and $sTV_AccessToken _Example_TeamViewer__1_Devices_SaveToFile() ;~ _Example_TeamViewer__2_Devices_ChangeDetails() ;~ _Example_TeamViewer__3_Devices_GetDevicesSingleID() ;~ _Example_TeamViewer__4_Reports_GetAllConnections() ;~ _Example_TeamViewer__5_Users_GetUserInfomation() ;~ _Example_TeamViewer__6_Groups_ListGroups() ;~ _Example_TeamViewer__7_Devices_AddDeleteDevice() Else MsgBox(0, '_TVAPI_Ping', "$v_Token or connection problem.") EndIf EndFunc ;==>_Example  
      SUPPORT TOPIC IS HERE:
       
      TeamViewer_Example — Template.ini
    • mLipok
      By mLipok
      This is TeamViewer.au3 UDF for TeamViewer API.
      ; #INDEX# ======================================================================== ; Title .........: TeamViewer.au3 ; AutoIt Version : 3.3.10.2++ ; Language ......: English ; Description ...: A collection of function for use with TeamViewer API ; Author ........: mLipok ; Modified ......: ; URL ...........: ; URL ...........: https://www.teamviewer.com/ ; URL ...........: https://www.teamviewer.com/en/integrations/ ; URL ...........: https://integrate.teamviewer.com/en/develop/api/get-started/ ; URL ...........: https://downloadeu1.teamviewer.com/integrate/TeamViewer_API_Documentation.pdf ; Remarks .......: This UDF was created based on TeamViewer_API_Documentation.pdf v 1.4.1 ; Remarks .......: This UDF is using Free Chilkat component look here https://www.autoitscript.com/forum/files/file/433-chilkat-udf/ ; Remarks .......: Documentation is "work in progress" ; Date ..........: 2017/02/08 ; Version .......: 0.1.1 BETA - Work in progress ; ================================================================================ in TeamViewer_Example.au3 you can see few examples:

       
      Func _Example() ; If not exist then create new INI file from template If Not FileExists('TeamViewer_Example.ini') Then FileCopy('TeamViewer_Example — Template.ini', 'TeamViewer_Example.ini') ; Read Access Token from INI Local $sTV_AccessToken = IniRead('TeamViewer_Example.ini', 'Settings', 'AccessToken', '') If $sTV_AccessToken = '' Then ; Your Access Token, can be left empty when OAuth (below) is configured. ; ClientId = <----------------- Create an app in your TeamViewer Management Console and insert the client ID to the INI ; ClientSecret = <------------- Insert your client secret to the INI ; AuthorizationCode = <-------- Visit https://webapi.teamviewer.com/api/v1/oauth2/authorize?response_type=code&client_id=YOUR$i_ClientIdHERE ; Login, grant the permissions (popup) and put the code shown in the AuthorizationCode variable to the INI Local $sTVOAuth_ClientID = IniRead('TeamViewer_Example.ini', 'OAuth2', 'ClientID', '') Local $sTVOAuth_ClientSecret = IniRead('TeamViewer_Example.ini', 'OAuth2', 'ClientSecret', '') _IECreate('https://webapi.teamviewer.com/api/v1/oauth2/authorize?response_type=code&client_id=' & $sTVOAuth_ClientID) ; Local $sTVOAuth_AuthorizationCode = IniRead('TeamViewer_Example.ini', 'OAuth2', 'authorizationCode', '') Local $sTVOAuth_AuthorizationCode = InputBox('AuthorizationCode', 'Please provide TV OAuth2 AuthorizationCode') If @error Then Return If $sTVOAuth_ClientID Then $sTV_AccessToken = _TVAPI_RequestOAuth2_AccessToken($sTVOAuth_ClientID, $sTVOAuth_ClientSecret, $sTVOAuth_AuthorizationCode) EndIf If $sTV_AccessToken Then _TVAPI_AccessToken($sTV_AccessToken) If _TVAPI_Ping() = True Then ; ping API to check connection and $sTV_AccessToken _Example_TeamViewer__1_Devices_SaveToFile() ;~ _Example_TeamViewer__2_Devices_ChangeDetails() ;~ _Example_TeamViewer__3_Devices_GetDevicesSingleID() ;~ _Example_TeamViewer__4_Reports_GetAllConnections() ;~ _Example_TeamViewer__5_Users_GetUserInfomation() ;~ _Example_TeamViewer__6_Groups_ListGroups() ;~ _Example_TeamViewer__7_Devices_AddDeleteDevice() Else MsgBox(0, '_TVAPI_Ping', "$v_Token or connection problem.") EndIf EndFunc ;==>_Example You can download it here:
      I'm using TeamViewer_Example.ini to store my secret tokens/keys.
      [Settings] AccessToken= [OAuth2] ClientID= ClientSecret= authorizationCode=