Create a real additional AutoHotkey thread in current process using AutoHotkey.dll.
OutputVar := AhkThread(ScriptOrFile, Parameters, Title, ScriptIsFile, DllToUse)Function Example: Thread := AhkThread("MsgBox 'Message from thread.'")
The name of the variable in which to store the object for newly created thread.
Using this object we can call all AutoHotkey.dll functions with simple object syntax.
The AutoHotkey script to execute. This parameter can be one of the following:
- Script passed as string or variable containing string. - Path to an ahk file. Parameter ScriptIsFile must be set to true to start a script from file. - Empty or omitted to start an empty script ("#Persistent`n#NoTrayIcon"). - 0 to prepare the thread but not start it. Use ahkdll or ahktextdll to start new thread.
Command line parameters that will be available in built-in variable A_Args object.
Title for the dll thread (by default filename) that will be shown in MsgBox, Gui... when no Title is given.
Set to true or 1 if ScriptOrFile is a path to a file on disk or network.
Path or Resource name for AutoHotkey.dll that will be used to create new thread.
ahkdll and ahktextdll will behave different when AutoHotkey.dll is compiled.
When ScriptOrFile is omitted or empty, the compiled script is executed.
To free resources for the thread we have to call ahkthread_free(obj) and also release the object (obj:="").
obj.ahkterminate() can be called optionally.
|ahkdll||Load a new thread from a file, current thread will be terminated.|
|ahktextdll||Load a new thread from a string/memory/variable, current thread will be terminated.|
|ahkReady||Returns 1 (true) if a thread is being executed currently, 0 (false) otherwise.|
|ahkReload||Reload thread using same parameters used with ahkdll or ahktextdll.|
|ahkFunction||Call a function via SendMessage method. Mainly used with AutoHotkey.dll to call a function in dll script or call a function in main script from dll.|
|ahkPostFunction||Call a function via PostMessage method (does not wait until function returns). Also used mainly with AutoHotkey.dll|
|ahkExecuteLine||Executes script from given line pointer.|
|ahkLabel||Goto (PostMessage) or Gosub (SendMessage) a Label. Also used mainly with AutoHotkey.dll|
|ahkFindFunc||Find a function and return its pointer.|
|ahkFindLabel||Find a label and return its pointer.|
|addFile||Add and optionally execute additional script/code from file. Not available for scripts compiled with AutoHotkeySC.bin.|
|addScript||Add and optionally execute additional script/code from text/memory/variable. Not available for scripts compiled with AutoHotkeySC.bin.|
|ahkExec||Execute some script/code from text/memory/variable temporarily. Not available for scripts compiled with AutoHotkeySC.bin.|
|ahkassign||Assign a value to variable or pointer of variable.|
|ahkgetvar||Retrieve a value from a variable.|
ahkdll:=AhkThread("#Persistent`nvariable:=`"Thread`"") ; Loads the AutoHotkey module and starts the script. While !ahkdll.ahkgetvar.variable Sleep 50 ; wait until variable has been set. MsgBox ahkdll.ahkgetvar.variable ; Display content of variable in thread ahkthread_free(ahkdll),ahkdll:="" ; Stop execution in thread and free resources.