Jump to content

Need help with a countdown timer.


 Share

Recommended Posts

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.

Link to comment
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
Link to comment
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
Link to comment
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
 Share

  • Recently Browsing   0 members

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