labrint wrote: ↑
26 Feb 2019, 04:48
I don't think you can run two functions at once in a single script because AHK does not support multithreading.
This statement is partially true.
AHK emulates multi-threading.
Only one "thread" can be active at one time, but when you use something like SetTimer, what happens is, when the timer fires, it interrupts the current thread, runs the timer code, then relinquishes control back to the interrupted thread.
So as long as your SetTimer function ends (hits a return statement), then you have, in effect, multi-threaded.
The code the OP posted already does this, he just does not realize it.
Code: Select all
SetTimer, Internet, 500
Tooltip % "Other code running... " A_TickCount
Return DllCall("Wininet.dll\InternetGetConnectedState", "Str", flag,"Int",0)
SoundBeep, 1000, 100
SoundBeep, 500, 100