Calling a Class is the fastest way but Label should be fast enough too.
A_AhkLabel:=DllCall("GetProcAddress","PTR",DllCall("GetModuleHandle","PTR"),"AStr","ahkLabel","PTR") DllCall(A_AhkLabel,"Str","Label","UInt",0) return
In AutoHotkey_H dll you can use WinAPI functions directly.
Also consider using DynaCall.
dll:=AhkThread(" ( A_AhkLabel:=GetProcAddress(GetModuleHandle(),""ahkLabel"") DllCall(A_AhkLabel,""Str"",""Label"",""UInt"",0) AhkLabel:=DynaCall(A_AhkPath ""\ahkLabel"",""i==st"") AhkLabel[""Label""] return )") While dll.ahkReady() sleep 100 ExitApp Label: MsgBox % A_ThisLabel Return
Small example with calling class and label from AutoHotkey_H:
SetBatchLines,-1 CriticalFun:=CriticalObject(fun) dll:=AhkThread(" ( exe:=AhkExported() fun:=CriticalObject(" (&CriticalFun) ") Loop 100{ QueryPerformanceCounter(getvar(v1:=0)) exe.ahkLabel(""Label"") QueryPerformanceCounter(getvar(v2:=0)) fun.Call() QueryPerformanceCounter(getvar(v3:=0)) ToolTip `% ""Label`t`t"" v2-v1 ""``nClass`t`t"" v3-v2 Sleep 200 } )") While dll.ahkReady() Sleep 100 ExitApp Esc::ExitApp Label: Return Class Fun { Call(){ } }
CriticalObject is only required if you call the function from multiple threads, otherwise you can also use (&fun) instead (&CriticalFun)!