Page 1 of 1

How can i run two loops at the same time

Posted: 11 Mar 2017, 20:15
by A random guy
So i'm trying to run a loop while checking for a message from another script. This is not my actual code but has the same concept.

Code: Select all

Test = 1
OnMessage(0x5555, "MsgMonitor")
; this is the loop
loop
{
if Test = 1
{
msgbox, 4144, test, test
sleep, 60000
}
}

; this is what i want while that loop is happening 
loop
{
MsgMonitor(wParam)
{
Test := %wParam%
}
}

Re: How can i run two loops at the same time  Topic is solved

Posted: 11 Mar 2017, 20:19
by Exaskryz
To answer the title, you'd use SetTimer instead of Loop.

However, you don't need a loop to check for the message. OnMessage() does that for you. Once you have executed that line, the script in the background will wait for the message. When it gets it, it'll execute the label (or function) you assigned in OnMessage().

Re: How can i run two loops at the same time

Posted: 12 Mar 2017, 18:46
by A random guy
Thanks