ahkLabel

Exported function that allows calling a Label in script currently executed by AutoHotkey module.
Paramenters can be strings only as well as return value.


OutputVar := DllCall("Module\ahkLabel", "Str", "LabelName", "UInt", DoNotWait, "CDecl Int")
Command  Example: DllCall "AutoHotkey.dll\ahkLabel", "Str", "MyLabel", "UInt", 0, "CDecl Int"
                  DllCall "AutoHotkey.exe\ahkLabel", "Str", "MyLabel", "Uint", 0, "CDecl Int")

Function Example: OutputVar := DllCall("AutoHotkey.dll\ahkLabel", "Str", "MyLabel", "UInt", 0, "CDecl Int")
                  OutputVar := DllCall("AutoHotkey.exe\ahkLabel", "Str", "MyLabel", "UInt", 0, "CDecl Int")

Parameters

OutputVar

The name of the variable to store 1 / true if label was found or 0 / false otherwise.

LabelName

The name of the label to jump to.

DoNotWait

1 (true) will not wait for the code to finish / return, FALSE / NULL / 0 will wait for execution to finish like GoSub does.

Related

ahkPostFunction, ahkFindFunc, DllCall, NewThread

Examples

dllpath:=A_AhkDir "\AutoHotkey.dll"
DllCall("LoadLibrary","Str",dllpath) ; Load the AutoHotkey module.
ThreadID:=DllCall(dllpath "\NewThread","Str","
(
Persistent
MyLabel:
MsgBox A_ThisLabel
Return
)","Str","","Str","","CDecl") ; start a new thread, just the function.
DllCall(dllpath "\ahkLabel","Str","MyLabel","UInt",0,"Uint",ThreadID,"CDecl") ; jump to label and wait for it to finish / return.

; Same example like above using NewThread function.
dll:=NewThread("
(
Persistent
MyLabel:
MsgBox A_ThisLabel
Return
)")
dll.ahkLabel("MyLabel")