timer object?

Ask for Help on Using the Language With Memory Hacking Software

Moderators: g3nuin3, SpeedWing, WhiteHat, mezzo

timer object?

Postby robrave » Wed Sep 19, 2007 11:59 am

how can I check for a extern variable value periodically? I want to create a dialog which displays the value of a declared extern variable.. how can i use timer in script? or do i have to use while loop which loops endlessly?

thanks!
User avatar
robrave
Hacker Smacker
 
Posts: 41
Joined: Sat Sep 15, 2007 3:27 pm
Location: Philippines

Postby 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
User avatar
L. Spiro
L. Spiro
 
Posts: 3129
Joined: Mon Jul 17, 2006 10:14 pm
Location: Tokyo, Japan


Return to Help

Who is online

Users browsing this forum: No registered users and 0 guests

cron