addScript
Exported function that adds new code from string to currently executed script.
OutputVar := addScript(NewCode , WaitExecute)Command Example: addScript "MsgBox A_Now", 1 DllCall "AutoHotkey.dll\addScript", "Str", "MsgBox A_Now", "Int", 1, "UPTR" DllCall "AutoHotkey.exe\addScript", "Str", "MsgBox A_Now", "Int", 1, "UPTR" Function Example: LinePtr := addScript("MsgBox `% A_Now", 1) LinePtr := DllCall("AutoHotkey.dll\addScript", "Str", "MsgBox A_Now", "Int", 1, "UPTR") LinePtr := DllCall("AutoHotkey.exe\addScript", "Str", "MsgBox A_Now", "Int", 1, "UPTR")
Parameters
- OutputVar
The name of the variable in which to store the line pointer to new code, if code could not be added 0 will be stored.
- NewCode
-
New Code to add to currently running script.
- WaitExecute (optional)
-
0 = add code but do not execute.
1 = add code, execute and wait for return.
2 = add code, execute and return immediately (don't wait for code to end execution).
Related
ahkFindFunc, ahkFindLabel, ahkassign, NewThread
Examples
dllpath:=A_AhkDir "\AutoHotkey.dll" DllCall("LoadLibrary","Str",dllpath) ; Load the AutoHotkey module. ThreadID:=DllCall(dllpath "\NewThread","Str","","Str","","Str","","Cdecl") ; start new, empty thread. DllCall(dllpath "\addScript","Str","MsgBox 'Hello World!'","Int",1,"UInt",ThreadID,"CDecl") ; add and execute code ; Same example like above using NewThread function. dll:=NewThread(,,,,dllpath) dll.addScript("MsgBox 'Hello World!'",1) ; Add and execute script in current thread addScript("MsgBox 'Test'",1)