Sign in to follow this  
Followers 0
IgorChete

Need help with a countdown timer.

4 posts in this topic

Basically, i want to test if a certain command in my script has completed in certain amount of time.

Something like this:

Timer starts

Some commands

if the timer hasn't reached 30 seconds, reset timer.

I've read the Help file about _Timer_SetTimer, but i don't really understand how it works.

Share this post


Link to post
Share on other sites



Keep it simple. Stick with TimerInit() and TimerDiff():

Global $iTimer

While 1
    $iTimer = TimerInit()

    ; Do stuff

    If TimerDiff($iTimer) > 10000 Then
        MsgBox(16, "Timeout", "That took longer than 10 seconds.")
        ExitLoop
    EndIf
WEnd

:x


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

$iTimer = TimerInit() resets the timer to 0, right?

I've integrated your code into my script and now i wait for the IE to freeze at some point to see if it works properly.

Share this post


Link to post
Share on other sites

$iTimer = TimerInit() resets the timer to 0, right?

No, it get the current value of an RT Clock. Then TimerDiff() will get you the difference between that saved value and the new current value of the RTC, which is approx the number of milliseconds elapsed. You can test that by displaying the value.

:x


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0