ahkExec

Exported function that executes some code temporarily from string in currently executed script.


OutputVar := ahkExec(Code)
Function Example: Result := ahkExec("MsgBox `% A_Now")
                  Result := DllCall("AutoHotkey.dll\ahkExec", "Str", "MsgBox `% A_Now", "Char")
                  Result := DllCall("AutoHotkey.exe\ahkExec", "Str", "MsgBox `% A_Now", "Char")

Parameters

OutputVar

The name of the variable in which to store 1 (true) if code was created and executed successfully, 0 (false) otherwise.

NewCode

Code to execute temporarily in currently running script.

Return Value

If code was created and executed successfully 1 (true) is returned, otherwise 0 (false).

Related

ahkFindFunc, ahkFindLabel, ahkassign

Examples

dllpath:=A_AhkDir "\AutoHotkey.dll"
DllCall("LoadLibrary","Str",dllpath) ; Load the AutoHotkey module.
DllCall(dllpath "\ahktextdll","Str","","Str","","CDecl") ; start a new thread, just the function.
DllCall(dllpath "\ahkExec","Str","MsgBox Hello World!","CDecl") ; add and execute code

; Same example like above but using included AutoHotkey.dll
dll:=AhkThread()
dll.ahkExec["MsgBox Hello World!"]

; Execute code in current thread
ahkExec("MsgBox Test")