Jump to content

Recommended Posts

Posted

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 ?

Posted

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
Posted

$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.

Posted

...

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!)

Posted

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=143556

Cheers

Kurt

__________________________________________________________(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 *

Posted

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?

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...