Exported function that allows calling a function in script
currently executed by AutoHotkey module without waiting for
the function to return.
Paramenters can be strings only.
OutputVar := ahkPostFunction("FuncName" , Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9, Arg10)Command Example: DllCall "AutoHotkey.dll\ahkPostFunction", "Str", "FuncName" [, "Str", "Arg1", ..., "Str", "Arg10"], "CDecl Str" DllCall "AutoHotkey.exe\ahkPostFunction", "Str", "FuncName" [, "Str", "Arg1", ..., "Str", "Arg10"], "CDecl Str" Function Example: OutputVar := DllCall("AutoHotkey.dll\ahkPostFunction", "Str", "FuncName"[, "Str", Arg1 , ..., "Str",Arg10], "Str") OutputVar := DllCall("AutoHotkey.exe\ahkPostFunction", "Str", "FuncName"[, "Str", Arg1 , ..., "Str",Arg10], "Str")
The name of the variable to store 0 if function was found or -1 if functon was not found.
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)
If a function was found and called it returns 1 (true), otherwise 0 (false).
Note that Function will not run if #MaxThreads limit is reached.
ahkFunction, ahkFindFunc, NewThread
dllpath:=A_AhkDir "\AutoHotkey.dll" DllCall("LoadLibrary","Str",dllpath) ; Load the AutoHotkey module. ThreadID:=DllCall(dllpath "\NewThread","Str","Persistent`nMyFunc(param){`nSleep 1000`nMsgBox `% param`n}","Str","","Str","","CDecl") ; start a new thread, just the function. DllCall(dllpath "\ahkPostFunction","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") ; call the function. Sleep 2000 ; wait 2 seconds and exit ; Same example like above using NewThread function. dll:=NewThread("Persistent`nMyFunc(param){`nSleep 1000`nMsgBox `% param`n}",,,,dllpath) dll.ahkPostFunction("MyFunc","Hello World!") Sleep 2000