by L. Spiro » Wed Sep 19, 2007 10:43 pm
There is no timer function but you can use CreateThread() and inside the function you call you can call Sleep() to wait for whatever period.
But you need to set up a system that allows you to kill the second thread; while it is active the script can not be recompiled.
The system is very easy; set a global variable and a hotkey that toggles it TRUE and FALSE.
The second thread checks this every 10 milliseconds (use Sleep( 10 )) and when it is FALSE it exits. Otherwise it continues in this loop until the timeout period as you stated.
You would need a while loop, but it is important to use Sleep() somewhere in the loop to conserve resources. Sleep() (as you might know) prevents the thread from hogging resources. Alternatively you can use SetThreadPriority( GetCurrentThread(), THREAD_PRIORITY_LOWEST );.
L. Spiro