I'm now studying how to get a function outside the thread so that it works inside the thread. But the example of this link (https://hotkeyit.github.io/v2/docs/commands/ahkFunction.htm) is very confusing, could someone explain me in a simpler way by following the example below? Please!
Code: Select all
#NoEnv
#NoTrayIcon
#SingleInstance, Force
Gui, Add, Button, h50 w200 vstart gstartG, START
Gui, Show, `t
return
toggle := 0
startG:
toggle := !toggle
if (toggle) {
GuiControl,, start, STOP
startScript := CriticalObject()
script:="
("
#NoEnv
#NoTrayIcon
Loop
{
;
PaternThread := AhkExported()
function := PaternThread.AhkGetVar.function
a = 5
b = 8
c = function(a,b)
MsgBox % ""a + b: "" c
}
)"
DllThread:=AhkThread(script,&startScript)
} else {
DllThread.ahkTerminate()
GuiControl,, start, START
}
return
function(x,y){
return x + y
}
GuiClose:
ExitApp