Jump to content

Timed Loop?


Recommended Posts

$start = TimerInit()
Do
    MouseClick("left", 500, 500)
    Sleep(5)

    If TimerDiff($start) >10000 Then $start = TimerInit()

Until TimerDiff($start) > 30000

After 10 seconds you'll get a new timestamp ($start = TimerInit()) and so it will take again 30 seconds until

TimerDiff($start) > 30000
, but as after 10 seconds, you will have a new timestamp again and again you will never reach TimerDiff($start) > 30000

Of course that's senseless that way, but if you enter a senseful statement for If TimerDiff($start) >10000... it will be useful for your problem.

"It's easier to disintegrate an atom than a prejudice." (A.Einstein)---------------------------------------------------------------------------My C++ - tools:Tidy tool-->indents your c++ sourceCleanscript --> cleans autoit-code before compiling (co-author: peethebee)My tools:GUIBuilder-->build your window and get the source; german versionMy Games:OnlineGameCenter-->Online Chess and Connect4 with a rtf-chatSnake-->including a level editor to build your own levelsTetris-->the well known game, big funOther things:Tower of Hanoi-->perfect riddler with graphic output

Link to comment
Share on other sites

HotKeySet('!c', 'toggle')  ;ALT + c to toggle
HotKeySet('{ESCAPE}', 'quit')  ;ESC to exit

Global $stopped = True  ;the script doesn't start immediately

While 1
    $start = TimerInit()  
    While Not $stopped
        ToolTip(StringFormat('%.2f', TimerDiff($start) / 1000))  ;YOUR
        Sleep(50)                                                ;STUFF
        If TimerDiff($start) > 30000 Then $start = TimerInit()   ;HERE
    WEnd
    Sleep(100)
    ToolTip('Script Paused')
WEnd

Func toggle()
    $stopped = Not $stopped
EndFunc

Func quit()
    ToolTip('Exiting!')
    Sleep(2000)
    Exit
EndFunc

edit - lining up the word "stuff" ;)

Edited by xcal
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...