Exported function that allows calling a function in script
currently executed by AutoHotkey module.
Paramenters can be strings only as well as return value.
OutputVar := ahkFunction("FuncName" , Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9, Arg10)Command Example: DllCall "AutoHotkey.dll\ahkFunction", "Str", "FuncName" [, "Str", "Arg1", ..., "Str", "Arg10"], "CDecl Str" DllCall "AutoHotkey.exe\ahkFunction", "Str", "FuncName" [, "Str", "Arg1", ..., "Str", "Arg10"], "CDecl Str" Function Example: OutputVar := DllCall("AutoHotkey.dll\ahkFunction", "Str", "FuncName"[, "Str", Arg1 , ..., "Str",Arg10], "Str") OutputVar := DllCall("AutoHotkey.exe\ahkFunction", "Str", "FuncName"[, "Str", Arg1 , ..., "Str",Arg10], "Str")
The name of the variable to store the functions returned value as string, on failure empty string is stored.
The name of the function to call.
You can pass up to 10 parameters to the function. Note all parameters need to be Strings or NULL / 0 if you want to omit parameter (use function default parameters)
Note that Function will not run if #MaxThreads limit is reached.
ahkPostFunction, ahkFindFunc, NewThread
dllpath:=A_AhkDir "\AutoHotkey.dll" DllCall("LoadLibrary","Str",dllpath) ; Load the AutoHotkey module. ThreadID:=DllCall(dllpath "\NewThread","Str","Persistent`nMyFunc(param){`nSleep 10000`nMsgBox param`n}","Str","","Str","","CDecl") ; start a new thread, just the function. Msgbox DllCall(dllpath "\ahkFunction","Str","MyFunc","Str","Hello World!","Ptr",0,"Ptr",0,"Ptr",0,"Ptr",0,"Ptr",0,"Ptr",0,"Ptr",0,"Ptr",0,"Ptr",0,"Uint",ThreadID,"CDecl Str") ; call the function. ; Same example like above using NewThread function. dll:=NewThread("Persistent`nMyFunc(param){`nMsgBox param`n}",,,,dllpath) MsgBox dll.ahkFunction("MyFunc","test")