KAX Posted August 12, 2006 Share Posted August 12, 2006 Hi AutoIt fans! I would like to use a timer service to get awaked when timer has expired. But it should work without polling. Means using sleep and waiting in loops. Has someone got a good idea ? Link to comment Share on other sites More sharing options...
Zib Posted August 12, 2006 Share Posted August 12, 2006 (edited) $Timer_Expiration_Time = 10000 ;10 seconds. $Timer = TimerInit() Do Sleep(500) Until TimerDiff($Timer) >= $Timer_Expiration_Time MsgBox(0, "Time Expired", "It has been " & $Timer_Expiration_Time / 1000 & " seconds.") Edited August 12, 2006 by Zib Link to comment Share on other sites More sharing options...
KAX Posted August 12, 2006 Author Share Posted August 12, 2006 This is not the 'optimal' solution I'm loolking for. Because it doesn't allow you easily to add more timers. My favorite structure looks like: ... $timer1 = CreateTimer() StartTimer($timer1, 1000) ;starts timer1, time in ms while $performMainLoop ; main loop $msg = GUIGetMsg(1) Select Case $msg[0] = $GUI_EVENT_CLOSE Exit Case $msg[0] = $TIMEREXPIRED ; check which timer ; perform appr. action StartTimer($timer1, 500); restart it .... EndSelect Wend Link to comment Share on other sites More sharing options...
Zib Posted August 12, 2006 Share Posted August 12, 2006 $Timer1_Expiration_Time = 10000 ;10 seconds. $Timer2_Expiration_Time = 8000 ;8 seconds. $Timer3_Expiration_Time = 30000 ;30 seconds. $Timer1 = TimerInit() $Timer2 = TimerInit() $Timer3 = TimerInit() While 1 Select Case TimerDiff($Timer1) >= $Timer1_Expiration_Time ;Do something... $Timer1_Expiration_Time = 5000 $Timer1 = TimerInit() Case TimerDiff($Timer2) >= $Timer2_Expiration_Time ;Do something else.. Case TimerDiff($Timer3) >= $Timer3_Expiration_Time ;Do something else.. EndSelect WEnd Something like this? Maybe I am not understanding correctly. Link to comment Share on other sites More sharing options...
KAX Posted August 12, 2006 Author Share Posted August 12, 2006 ...Something like this? Maybe I am not understanding correctly.Thanks Zib,this solution consumes the CPU-power inside the loop, because it polls the used timers at every loop step. I prefer a solution ala WM_TIMER. Which winds up the timers and then only waits for messages. (Hope the waiting for messages does not steal the CPU from all the concurrent running processes!) Link to comment Share on other sites More sharing options...
/dev/null Posted August 12, 2006 Share Posted August 12, 2006 This is not the 'optimal' solution I'm loolking for. Because it doesn't allow you easily to add more timers.My favorite structure looks like:This is what you want: http://www.autoitscript.com/forum/index.ph...st&p=143556CheersKurt __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * Link to comment Share on other sites More sharing options...
KAX Posted August 12, 2006 Author Share Posted August 12, 2006 This is what you want: http://www.autoitscript.com/forum/index.ph...st&p=143556CheersKurtThank you,that helped me! Link to comment Share on other sites More sharing options...
KAX Posted August 14, 2006 Author Share Posted August 14, 2006 unsolved questions to timer functions The timer function: DLLCall("user32.dll","int_ptr","SetTimer","hwnd",$gui,"int_ptr",$nID,"int",2000,"ptr",0) generate repeated timeouts. So good so far. But it seems, that the timers haven't designed to be operated in start-stop mode. (To restart a timer only when a certain event has occured). An other point is to change the timeout. Can someone help? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now