bladem2003 Posted February 9, 2019 Posted February 9, 2019 Hello, i need help to translate the c code to autoit . I don't understand the callback function. expandcollapse popup#include <windows.h> #include <stdio.h> // native IR Data by PAnsiChar typedef void CALLBACK CallBackPAnsiChar(char*, char*, char*, char*); typedef int (__stdcall *impInitPAnsiChar)(CallBackPAnsiChar); CALLBACK MyCallBackPAnsiChar(char* Protocol, char* Address, char* Command, char* Flags) { printf("\nIR Data received: Protocol: %s, Address: 0x%s, Command: 0x%s, Flags: 0x%s", Protocol, Address, Command, Flags); fflush(stdout); } int main(int argc, char **argv) { impInitPAnsiChar InitPAnsiChar = NULL; // Load DLL file HINSTANCE hinstLib = LoadLibrary(TEXT("USB_IR_Remote_Receiver.dll")); if (hinstLib == NULL) { printf("\nERROR: unable to load DLL\n"); return 1; } // Get function pointer InitPAnsiChar InitPAnsiChar = (impInitPAnsiChar)GetProcAddress(hinstLib, "InitPAnsiChar"); if (InitPAnsiChar == NULL) { printf("\nERROR: unable to find DLL function\n"); FreeLibrary(hinstLib); return 1; } if (InitPAnsiChar(*MyCallBackPAnsiChar)) { printf("\nInit DLL with InitPAnsiChar successfull"); } else { // Unload DLL file FreeLibrary(hinstLib); return 0; } while(1) { } //return 0; }
Danyfirex Posted February 9, 2019 Posted February 9, 2019 (edited) Hello. I think it should look like: HotKeySet("{ESC}", "_Terminate") Local $IsRunning=True Local $hDll=DllOpen("USB_IR_Remote_Receiver.dll") ; Create callback function. Local $hCallback = DllCallbackRegister("_MyCallBackPAnsiChar", "none", "str;str;str;str") ; Call InitPAnsiChar DllCall($hDll, "int", "InitPAnsiChar", "ptr", DllCallbackGetPtr($hCallback)) While $IsRunning Sleep(30) WEnd ; Delete callback function. DllCallbackFree($hCallback) ;close dll DllClose($hDll) Exit ; Callback Procedure Func _MyCallBackPAnsiChar($sProtocol,$sAddress,$sCommand,$sFlags) ConsoleWrite(StringFormat("IR Data received: Protocol: %s, Address: 0x%s, Command: 0x%s, Flags: 0x%s", $sProtocol, $sAddress, $sCommand, $sFlags) & @CRLF) EndFunc ;==>_EnumWindowsProc Func _Terminate() $IsRunning=False EndFunc Saludos Edited February 9, 2019 by Danyfirex 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
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