I'm so lost. Isn't this possible?
What I need:
MainScript.ahk:
LastThing := ""
ThreadsArray := []
Loop %thisMany%{
threads.Push(NewThread("Second script"))
}
---Do Stuff with LastThing---
SecondScript.ahk:
---Get last thing and put it in LastThing---
What I have:
MainScript.ahk:
LastThing := ""
SecondScriptSrc := FileRead("SecondScript.ahk", "`n")
dllpath:=A_AhkDir "\AutoHotkey.dll"
DllCall("LoadLibrary","Str",dllpath)
DllCall(dllpath "\ahktextdll","Str","","Str","","PTR")
DllCall(dllpath "\ahkassign", "Str", "LastThing", "Str", LastThing, "CDecl")
DllCall(dllpath "\ahkExec","Str",SecondScriptSrc,"CDecl")
LastThing := DllCall(dllpath "\ahkgetvar","Str", "LastThing", "UInt", 1, "Cdecl Str")
SecondScript.ahk
dllpath:=A_AhkDir "\AutoHotkey.dll"
DllCall("LoadLibrary","Str",dllpath)
LastThing := DllCall(dllpath "\ahkgetvar","Str", "LastThing", "UInt", 1, "Cdecl Str")
LastThing := "thing"
DllCall(dllpath "\ahkassign", "Str", "LastThing", "Str", LastThing, "CDecl")
This is what the documentation makes it look like how I'm supposed to do it. The message box shows random numbers that look a lot like pointers. Am I stupid?
Edit: If this isn't possible then what is the point of ahkassign and ahkgetvar? To me, the documentation for ahkgetvar certainly makes it look like you can execute a thread and then retrieve a variable from that thread.
dllpath:=A_AhkDir "\AutoHotkey.dll"
DllCall("LoadLibrary","Str",dllpath) ; Load the AutoHotkey module.
DllCall(dllpath "\ahktextdll","Str","","Str","","CDecl") ; start a new thread from file.
DllCall(dllpath "\ahkassign","Str","var","Str","value","CDecl") ; assing value to var
MsgBox DllCall(dllpath "\ahkgetvar","Str","var","UInt",0,"CDecl") ; wait for the thread to exit