Jump to content

Double timers


Recommended Posts

Hi

That's some marvellous work you guys are doing here. Who would've ever thought that AutoIt could contain AI?!

I just started scripting in this language, and I've tried looking through these forums and the help file, and I cannot find the answer to my question:

Is there no "GoTo myfunction" command in AutoIt?

What I want to build is:

-Initialization of various globals and locals and the script in general

--loop1

--start timer1

---do loop2 while "something"

---a timer2 function is running in here, doing some other stuff every 30 seconds

---when timer1 reaches 10 minutes, I want it to start over at loop1

---end loop2

--end loop1

-Exit

Arguments for ending the loops are in place (a simple ESC stroke will terminate the loop).

My quarrel is: What do I write to start timer1? And what do I write in loop2 to make it jump to loop1 after timer1 reaches 10 minutes?

Thanks in advance.

Link to comment
Share on other sites

For loops you want While/WEnd or perhaps Do/Until. For timers you have TimerInit()/TimerDiff(). Look them up in the help file and check out the demo scripts there.

Here's a demo that approximates what you described, at 5 and 30 seconds vice 30sec and 10min to make it less painful to test:

Global $Timer1, $Timer2 = TimerInit(), $Count

HotKeySet("{ESC}", "_Quit")

While 1
    $Count = 0
    $Timer1 = TimerInit()
    While 1
        If TimerDiff($Timer2) / 1000 >= 5 Then
            $Count += 1
            MsgBox(64, "Count", "Count = " & $Count, 2)
            $Timer2 = TimerInit()
        EndIf
        If TimerDiff($Timer1) / 1000 >= 30 Then ExitLoop
    WEnd
WEnd

Func _Quit()
    Exit
EndFunc

Welcome to AutoIt... and read the help file!

:)

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