jugador Posted September 23, 2023 Share Posted September 23, 2023 (edited) https://www.oreilly.com/library/view/vbscript-in-a/0596004885/re109.html https://www.autohotkey.com/docs/v1/lib/Func.htm ; #FUNCTION# ============================================================================= ; Name ..........: __GetRef ; Syntax ........: __GetRef($o_FunName = '', Const $p1 = Default, Const $p2 = Default, Const $p3 = Default, Const $p4 = Default, _ ; Const $p5 = Default, Const $p6 = Default) ; Parameters ....: $o_FunName - Callbacks Function Name ; $p1 - [optional] ; $p2 - [optional] ; $p3 - [optional] ; $p4 - [optional] ; $p5 - [optional] ; $p6 - [optional] ; Return values .: Object ; Author ........: jugador ; ======================================================================================== Example 1 Spoiler expandcollapse popup#include "GetRef UDF2.au3" Global $o_WHttpObj = Null Global $o_ExitFlag = False __ExampleA() Func __ExampleA() Local $oComErr = Null $oComErr = ObjEvent("AutoIt.Error", com_error_handler) #forceref $oComErr Local $o_BUrl = "https://www.autoitscript.com/forum/" $o_WHttpObj = ObjCreate("MSXML2.ServerXMLHTTP.6.0") $o_WHttpObj.Open("GET", $o_BUrl, True) $o_WHttpObj.onreadystatechange = __GetRef('__Onreadystatechange') $o_WHttpObj.Send() While $o_ExitFlag <> True ToolTip("__GetRef (Example)") Sleep(100) WEnd $o_WHttpObj = 0 EndFunc Func __Onreadystatechange() If $o_WHttpObj.ReadyState = 4 Then If $o_WHttpObj.Status = 200 Then _ ConsoleWrite("- Response: " & " (status [StatusText]): " & $o_WHttpObj.status & " [ " & $o_WHttpObj.StatusText & " ]" & @CRLF) $o_ExitFlag = True EndIf Return 0 EndFunc ; #FUNCTION# ============================================================================= ; Name...........: com_error_handler ; ======================================================================================== Func com_error_handler($oError) With $oError ConsoleWrite(" Error ScriptLine....... " & .scriptline & @CRLF) ConsoleWrite(" Error Number........... " & "0x" & Hex(.number) & " (" & .number & ")" & @CRLF) ConsoleWrite(" Error WinDescription... " & StringStripWS(.windescription, 2) & @CRLF) EndWith EndFunc Example 2 Spoiler expandcollapse popup#include "GetRef UDF2.au3" Global $o_ExitFlag = False __ExampleA() Func __ExampleA() Local $oComErr = Null $oComErr = ObjEvent("AutoIt.Error", com_error_handler) #forceref $oComErr Local $o_BUrl = "https://www.autoitscript.com/forum/" Local $o_WHttpObj = Null $o_WHttpObj = ObjCreate("MSXML2.ServerXMLHTTP.6.0") $o_WHttpObj.Open("GET", $o_BUrl, True) $o_WHttpObj.onreadystatechange = __GetRef('__Onreadystatechange', $o_WHttpObj) $o_WHttpObj.Send() While $o_ExitFlag <> True ToolTip("__GetRef (Example)") Sleep(100) WEnd $o_WHttpObj = 0 EndFunc Func __Onreadystatechange($o_WHttpObj) If $o_WHttpObj.ReadyState = 4 Then If $o_WHttpObj.Status = 200 Then _ ConsoleWrite("- Response: " & " (status [StatusText]): " & $o_WHttpObj.status & " [ " & $o_WHttpObj.StatusText & " ]" & @CRLF) $o_ExitFlag = True EndIf Return 0 EndFunc ; #FUNCTION# ============================================================================= ; Name...........: com_error_handler ; ======================================================================================== Func com_error_handler($oError) With $oError ConsoleWrite(" Error ScriptLine....... " & .scriptline & @CRLF) ConsoleWrite(" Error Number........... " & "0x" & Hex(.number) & " (" & .number & ")" & @CRLF) ConsoleWrite(" Error WinDescription... " & StringStripWS(.windescription, 2) & @CRLF) EndWith EndFunc Example 3 Spoiler expandcollapse popup#include "GetRef UDF2.au3" Global $o_ExitFlag = 0 __Example1() Func __Example1() Local $o_HttpArray[4][2] $o_HttpArray[0][1] = "https://www.autoitscript.com/forum/" $o_HttpArray[1][1] = "https://www.google.com/" $o_HttpArray[2][1] = "https://www.bing.com/" $o_HttpArray[3][1] = "https://github.com/" __WinhttpGet($o_HttpArray) EndFunc Func __WinhttpGet(ByRef $o_WHttpOb) Local $oComErr = Null $oComErr = ObjEvent("AutoIt.Error", com_error_handler) #forceref $oComErr Local $o_LoopCnt = UBound($o_WHttpOb) For $i = 0 To $o_LoopCnt - 1 $o_WHttpOb[$i][0] = ObjCreate("Msxml2.XMLHTTP.6.0") If IsObj($o_WHttpOb[$i][0]) Then With $o_WHttpOb[$i][0] .Open("GET", $o_WHttpOb[$i][1], True) .onreadystatechange = __GetRef('__Onreadystatechange', $o_WHttpOb[$i][0], $o_WHttpOb[$i][1]) .Send() EndWith Endif Next While $o_LoopCnt <> $o_ExitFlag ToolTip("__GetRef (Example)") Sleep(100) WEnd For $i = 0 To $o_LoopCnt - 1 $o_WHttpOb[$i][0] = 0 Next EndFunc ; #FUNCTION# ============================================================================= ; Name...........: __Onreadystatechange() ; ======================================================================================== Func __Onreadystatechange($o_HttpObj, $o_UrlName) If $o_HttpObj.ReadyState = 4 Then If $o_HttpObj.Status = 200 Then _ ConsoleWrite("- " & $o_UrlName & " (status[StatusText]): " & $o_HttpObj.status & " [ " & $o_HttpObj.StatusText & " ]" & @CRLF) $o_ExitFlag += 1 EndIf Return 0 EndFunc ; #FUNCTION# ============================================================================= ; Name...........: com_error_handler() ; ======================================================================================== Func com_error_handler($oError) With $oError ConsoleWrite(" Error ScriptLine....... " & .scriptline & @CRLF) ConsoleWrite(" Error Number........... " & "0x" & Hex(.number) & " (" & .number & ")" & @CRLF) ConsoleWrite(" Error WinDescription... " & StringStripWS(.windescription, 2) & @CRLF) EndWith EndFunc Example 4 Spoiler expandcollapse popup#include "GetRef UDF2.au3" Global $o_ExitFlag = 0 __Example1() Func __Example1() Local $o_HttpArray[4][3] $o_HttpArray[0][1] = "https://www.autoitscript.com/forum/" $o_HttpArray[1][1] = "https://www.google.com/" $o_HttpArray[2][1] = "https://www.bing.com/" $o_HttpArray[3][1] = "https://github.com/" $o_HttpArray[0][2] = '__Autoitscript_Onreadystatechange' $o_HttpArray[1][2] = '__Google_Onreadystatechange' $o_HttpArray[2][2] = '__Bing_Onreadystatechange' $o_HttpArray[3][2] = '__Github_Onreadystatechange' __WinhttpGet($o_HttpArray) EndFunc Func __WinhttpGet(ByRef $o_WHttpOb) Local $oComErr = Null $oComErr = ObjEvent("AutoIt.Error", com_error_handler) #forceref $oComErr Local $o_LoopCnt = UBound($o_WHttpOb) For $i = 0 To $o_LoopCnt - 1 $o_WHttpOb[$i][0] = ObjCreate("Msxml2.XMLHTTP.6.0") If IsObj($o_WHttpOb[$i][0]) Then With $o_WHttpOb[$i][0] .Open("GET", $o_WHttpOb[$i][1], True) .onreadystatechange = __GetRef($o_WHttpOb[$i][2], $o_WHttpOb[$i][0]) .Send() EndWith Endif Next While $o_LoopCnt <> $o_ExitFlag ToolTip("__GetRef (Example)") Sleep(100) WEnd For $i = 0 To $o_LoopCnt - 1 $o_WHttpOb[$i][0] = 0 Next EndFunc ; #FUNCTION# ============================================================================= ; Name...........: __Autoitscript_Onreadystatechange() ; ======================================================================================== Func __Autoitscript_Onreadystatechange($o_HttpObj) If $o_HttpObj.ReadyState = 4 Then If $o_HttpObj.Status = 200 Then _ ConsoleWrite("- From Autoitscript: " & " (status[StatusText]): " & $o_HttpObj.status & " [ " & $o_HttpObj.StatusText & " ]" & @CRLF) $o_ExitFlag += 1 EndIf Return 0 EndFunc ; #FUNCTION# ============================================================================= ; Name...........: __Google_Onreadystatechange() ; ======================================================================================== Func __Google_Onreadystatechange($o_HttpObj) If $o_HttpObj.ReadyState = 4 Then If $o_HttpObj.Status = 200 Then _ ConsoleWrite("- From Google: " & " (status[StatusText]): " & $o_HttpObj.status & " [ " & $o_HttpObj.StatusText & " ]" & @CRLF) $o_ExitFlag += 1 EndIf Return 0 EndFunc ; #FUNCTION# ============================================================================= ; Name...........: __Bing_Onreadystatechange() ; ======================================================================================== Func __Bing_Onreadystatechange($o_HttpObj) If $o_HttpObj.ReadyState = 4 Then If $o_HttpObj.Status = 200 Then _ ConsoleWrite("- From Bing: " & " (status[StatusText]): " & $o_HttpObj.status & " [ " & $o_HttpObj.StatusText & " ]" & @CRLF) $o_ExitFlag += 1 EndIf Return 0 EndFunc ; #FUNCTION# ============================================================================= ; Name...........: __Github_Onreadystatechange() ; ======================================================================================== Func __Github_Onreadystatechange($o_HttpObj) If $o_HttpObj.ReadyState = 4 Then If $o_HttpObj.Status = 200 Then _ ConsoleWrite("- From Github: " & " (status[StatusText]): " & $o_HttpObj.status & " [ " & $o_HttpObj.StatusText & " ]" & @CRLF) $o_ExitFlag += 1 EndIf Return 0 EndFunc ; #FUNCTION# ============================================================================= ; Name...........: com_error_handler() ; ======================================================================================== Func com_error_handler($oError) With $oError ConsoleWrite(" Error ScriptLine....... " & .scriptline & @CRLF) ConsoleWrite(" Error Number........... " & "0x" & Hex(.number) & " (" & .number & ")" & @CRLF) ConsoleWrite(" Error WinDescription... " & StringStripWS(.windescription, 2) & @CRLF) EndWith EndFunc Example 5 #include "GetRef UDF2.au3" __ExampleA() Func __ExampleA() Local $TestB = __GetRef('MsgFunction', 'PrintMsg') $TestB() EndFunc Func PrintMsg($friend) ConsoleWrite(2 & @crlf) ConsoleWrite("How " & $friend & @crlf) ConsoleWrite(3 & @crlf) EndFunc Func MsgFunction($myFunc) ConsoleWrite(1 & @crlf) Call($myFunc, "are You?") ConsoleWrite(4 & @crlf) EndFunc Example 5 output: 1 2 How are You? 3 4 GetRef UDF: GetRef UDF2.au3 GetRef UDF3.au3 Edited October 2, 2023 by jugador argumentum, Andreik and Danyfirex 3 Link to comment Share on other sites More sharing options...
jugador Posted September 26, 2023 Author Share Posted September 26, 2023 (edited) GetRef UDF3 #include "GetRef UDF3.au3" __ExampleA() Func __ExampleA() Local $TestA = __GetRef('__Multiply', 0, 0) ;~ initialize no of param & there default value $TestA(5, 7) $TestA(8, 11) $TestA(65) $TestA() EndFunc Func __Multiply($a, $b) If Not IsNumber($a) Then Return SetError(1) ;~ do manual check if is correct value If Not IsNumber($b) Then Return SetError(1) ;~ do manual check if is correct value ConsoleWrite('! __Ready( ' & $a & ' * ' & $b & ' = ' & $a * $b &' )' & @CRLF) EndFunc output: ! __Ready( 5 * 7 = 35 ) ! __Ready( 8 * 11 = 88 ) ! __Ready( 65 * 0 = 0 ) ! __Ready( 0 * 0 = 0 ) haven't figured out how to send Binary data(vt: 8209) & Array(vt: 8204) once done will update the UDF. note 1: if use Global then delete the object before exit else it will give @error:: ended.rc:-1073741819 Global $TestB = __GetRef('TestFunction') ;~ code $TestB = 0 ;~ delete the object note 2: don't use blocking function like (_ArrayDisplay / Msgbox) in Callbacks Function Edited September 30, 2023 by jugador Link to comment Share on other sites More sharing options...
Nine Posted September 26, 2023 Share Posted September 26, 2023 (edited) Not exactly sure what is the usage of your UDF as AutoIt has already considered functions as first class objects. Like : Example() Func Example() Local $TestB = MsgFunction $TestB(PrintMsg) EndFunc Func PrintMsg($friend) ConsoleWrite(2 & @crlf) ConsoleWrite("How " & $friend & @crlf) ConsoleWrite(3 & @crlf) EndFunc Func MsgFunction($myFunc) ConsoleWrite(1 & @crlf) $myFunc("are You?") ConsoleWrite(4 & @crlf) EndFunc Edited September 26, 2023 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Andreik Posted September 26, 2023 Share Posted September 26, 2023 @Nine That's not enough because of the way this callback function was designed. You can read some documentation here. Link to comment Share on other sites More sharing options...
Nine Posted September 26, 2023 Share Posted September 26, 2023 Ok, but I still do not understand the advantage of using it. I would like to see a real example (or explanation) that shows the benefit of the UDF in the real life. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Andreik Posted September 27, 2023 Share Posted September 27, 2023 I don't think it comes with an advantage, it's more like a wrapper for some funny Microsoft callbacks. In most cases we can simply enjoy the cool feature of AutoIt functions being first class objects. Link to comment Share on other sites More sharing options...
jugador Posted September 28, 2023 Author Share Posted September 28, 2023 (edited) https://stackoverflow.com/a/39752739 Vbscript: sHtml = "<a href=""http://www.dairyqueen.com/us-en/Promotions-US/?localechange=1&test=1"">" Set refRepl = GetRef("fnRepl") With CreateObject("VBScript.RegExp") .Global = True .MultiLine = True .IgnoreCase = True .Pattern = "<a([\s\S]*?)href=""([\s\S]*?)""([\s\S]*?)>" sResult = .Replace(sHtml, refRepl) End With Function fnRepl(sMatch, sSubMatch1, sSubMatch2, sSubMatch3, lPos, sSource) MsgBox TypeName(sMatch) & " | " & sMatch MsgBox TypeName(sSubMatch1) & " | " & sSubMatch1 MsgBox TypeName(sSubMatch2) & " | " & sSubMatch2 MsgBox TypeName(sSubMatch3) & " | " & sSubMatch3 MsgBox TypeName(lPos) & " | " & lPos MsgBox TypeName(sSource) & " | " & sSource End Function Autoit: #include "GetRef UDF3.au3" __ExampleA() Func __ExampleA() ; https://stackoverflow.com/a/39752739 Local $o_sResult Local $o_objsHtml = '<a href="http://www.dairyqueen.com/us-en/Promotions-US/?localechange=1&test=1">' Local $o_obj = ObjCreate( "VBScript.RegExp" ) If IsObj($o_obj) Then With $o_obj .Global = True .MultiLine = True .IgnoreCase = True .Pattern = "<a([\s\S]*?)href=""([\s\S]*?)""([\s\S]*?)>" $o_sResult = .Replace($o_objsHtml, __GetRef('__fnRepl', '', '', '', '', '', '')) EndWith $o_obj = 0 Exit Endif ConsoleWrite("ObjCreate failed.... Error code: " & @CRLF) EndFunc Func __fnRepl($a, $b, $c, $d, $e, $f) ConsoleWrite('! __fnRepl( )' & @CRLF) ConsoleWrite('$a: ' & VarGetType($a) & @TAB & $a & @CRLF) ConsoleWrite('$b: ' & VarGetType($b) & @TAB & $b & @CRLF) ConsoleWrite('$c: ' & VarGetType($c) & @TAB & $c & @CRLF) ConsoleWrite('$d: ' & VarGetType($d) & @TAB & $d & @CRLF) ConsoleWrite('$e: ' & VarGetType($e) & @TAB & $e & @CRLF) ConsoleWrite('$f: ' & VarGetType($f) & @TAB & $f & @CRLF) EndFunc Edited October 3, 2023 by jugador Link to comment Share on other sites More sharing options...
jugador Posted October 1, 2023 Author Share Posted October 1, 2023 (edited) obsolete example but still .... expandcollapse popup#include <IE.au3> #include "GetRef UDF3.au3" HotKeySet("{ESC}", "__Exit") __Example_A() ;__Example_B() ;__Example_C() ;__Example_D() Func __Example_A() ;~ alert when someone clicks on submitExample button Local $oIE = _IE_Example("form") sleep(1000) Local $buttons = $oIE.document.getelementsbyname("submitExample") $buttons(0).onclick = __GetRef('__OnClickSub') While 1 Sleep(100) WEnd EndFunc Func __Example_B() ;~ alert when someone clicks on the document Local $oIE = _IE_Example("basic") sleep(1000) Local $document = $oIE.document $document.onclick = __GetRef('__OnClickSub') While 1 Sleep(100) WEnd EndFunc Func __Example_C() ;~ alert when someone tries to right-click on the document Local $oIE = _IE_Example("basic") sleep(1000) Local $document = $oIE.document $document.oncontextmenu = __GetRef('__OnClickSub') While 1 Sleep(100) WEnd EndFunc Func __Example_D() ;~ prevents selection of text in the document Local $oIE = _IE_Example("basic") sleep(1000) Local $document = $oIE.document $document.onselectstart = __GetRef('__OnClickSub') While 1 Sleep(100) WEnd EndFunc Func __OnClickSub() ConsoleWrite('! __OnClickSub( button clicked!!! )' & @CRLF) __Exit() EndFunc Func __Exit() Exit EndFunc Edited October 1, 2023 by jugador Link to comment Share on other sites More sharing options...
jugador Posted October 2, 2023 Author Share Posted October 2, 2023 v3 uploaded | op post updated. Link to comment Share on other sites More sharing options...
jugador Posted October 3, 2023 Author Share Posted October 3, 2023 (edited) trying to replicate @Danyfirex code on Microsoft.Update.Session expandcollapse popup#include "GetRef UDF3.au3" __ExampleA() Func __ExampleA() ; https://gist.github.com/nicholasdille/71c23b3772bd4e871225 Local $oCom_Err = Null $oCom_Err = ObjEvent("AutoIt.Error", __ComError_handler) #forceref $oCom_Err Local $updateSession = ObjCreate( "Microsoft.Update.Session" ) If Not IsObj($updateSession) Then Return ConsoleWrite("ObjCreate failed.... Error code: " & Hex(@error, 8) & @CRLF) ConsoleWrite("Microsoft.Update.Session object created....." & @CRLF) Local $searchResult = __Search($updateSession) If @error Then ConsoleWrite("> __Search() failed" & @CRLF) Exit EndIf ConsoleWrite("SearchResultCode:: " & $searchResult.ResultCode & @CRLF) ConsoleWrite("UpdatesFound:: " & $searchResult.Updates.Count & @CRLF) If ($searchResult.ResultCode = 2) And ($searchResult.Updates.Count > 0) Then Local $DownloadResult = __Download($updateSession, $searchResult.Updates) If @error Then ConsoleWrite("> __Download() failed" & @CRLF) Exit EndIf ConsoleWrite("DownloadResultCode:: " & $DownloadResult.ResultCode & @CRLF) EndIf $updateSession = 0 Exit EndFunc Func __Search(ByRef $updateSession) Local $updateSearcher = $updateSession.CreateupdateSearcher() Local $search = $updateSearcher.Search("IsInstalled=0 and Type='Software'") ;~ Error: 0x80072EFE If @error Then Return SetError(1) Return $search EndFunc Func __Download(ByRef $updateSession, $hCollection) Local $Downloader = $updateSession.CreateUpdateDownloader() $Downloader.Updates = $hCollection Local $DownloadJob = $Downloader.BeginDownload(__GetRef('Download_OnProgressChanged', '', '') , __GetRef('Download_OnCompleted', '', '') , '') If @error Then Return SetError(1) Do Sleep(1000) Until $DownloadJob.IsCompleted Return $Downloader.EndDownload($DownloadJob) EndFunc Volatile Func Download_OnProgressChanged($hDownloadJob, $hArguments) ConsoleWrite("- Download_OnProgressChanged( Percentage ):: " & $hArguments.Progress.PercentComplete & @CRLF) EndFunc Volatile Func Download_OnCompleted($hInstallJob, $hArguments) ConsoleWrite("- Download_OnCompleted( Percentage ):: " & '100' & @CRLF) EndFunc Func __ComError_handler($oError) With $oError ConsoleWrite(@CRLF & "COM ERROR DETECTED!" & @CRLF) ConsoleWrite(" Error ScriptLine....... " & .scriptline & @CRLF) ConsoleWrite(" Error Number........... " & "0x" & Hex(.number) & " (" & .number & ")" & @CRLF) ConsoleWrite(" Error WinDescription... " & StringStripWS(.windescription, 2) & @CRLF) ConsoleWrite(" Error RetCode.......... " & "0x" & Hex(Number(.retcode)) & " (" & Number(.retcode) & ")" & @CRLF) ConsoleWrite(" Error Description...... " & StringStripWS(.description, 2) & @CRLF) EndWith EndFunc not tested as getting same error: 0x80072EFE (win 7) on both the code. @Danyfirex it would be great if you could check the above code. note: replace __COMVariantToValue with below code to support VT_DISPATCH and add __ConvertPtrToIDispatch function. Spoiler expandcollapse popup; #FUNCTION# ============================================================================= ; Name...........: __COMVariantToValue ; ======================================================================================== Func __COMVariantToValue($pVariant) Local Const $VT_I4 = 3 Local Const $VT_R8 = 5 Local Const $VT_BSTR = 8 Local Const $VT_DISPATCH = 9 Local Const $VT_UI4 = 19 Local Const $VT_I8 = 20 Local Const $tVARIANT = "word vt;word r1;word r2;word r3;ptr data; ptr" Local $t_rgvarg = DllStructCreate($tVARIANT, $pVariant) Local $iVariantType = DllStructGetData($t_rgvarg, "vt") Local $pData = $pVariant + 8 Local $i_Data = Null Switch $iVariantType Case $VT_I4 Local $t_Data = DllStructCreate( "int", $pData ) $i_Data = DllStructGetData( $t_Data, 1 ) Case $VT_R8 Local $t_Data = DllStructCreate( "double", $pData ) $i_Data = DllStructGetData( $t_Data, 1 ) Case $VT_BSTR Local $t_Ptr = DllStructCreate( "ptr", $pData ) Local $p_Ptr = DllStructGetData( $t_Ptr, 1 ) If $p_Ptr = 0x00000000 Then Return '' $i_Data = SysReadString( $p_Ptr ) Case $VT_DISPATCH Local $t_Data = DllStructCreate( "ptr", $pData ) $i_Data = DllStructGetData( $t_Data, 1 ) $i_Data = __ConvertPtrToIDispatch($i_Data) If Not IsObj($i_Data) Then Return SetError(1) Case $VT_UI4 Local $t_Data = DllStructCreate( "ptr", $pData ) $i_Data = DllStructGetData( $t_Data, 1 ) Case $VT_I8 Local $t_Data = DllStructCreate( "INT64", $pData ) $i_Data = DllStructGetData( $t_Data, 1 ) Case Else Return SetError(1) EndSwitch Return $i_Data EndFunc ; #FUNCTION# ============================================================================= ; Name...........: __ConvertPtrToIDispatch ; @monoceres ; ======================================================================================== Func __ConvertPtrToIDispatch($pIDispatch) Local $aCall = DllCall("kernel32.dll", "none", "RtlMoveMemory", _ "idispatch*", 0, _ "ptr*", $pIDispatch, _ "dword", 4) If @error Then Return SetError(1, 0, 0) Return $aCall[1] EndFunc Edited October 5, 2023 by jugador Link to comment Share on other sites More sharing options...
Danyfirex Posted October 5, 2023 Share Posted October 5, 2023 Hello, I don't have to much time to check deeply but I think your __GetRef is returning IDispatch callback but IDownload callback are IUnknown. Saludos jugador 1 Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now