Sign in to follow this  
Followers 0
Andrew Chen

Timed Loop?

5 posts in this topic

Hello, I was just wondering how I would spam this one command in a loop for 30 seconds. So far I have this:

while 1

MouseClick("left", 500, 500)

Sleep(5)

Wend

What would I have to change to make it repeat itself like so, but only for 30 seconds?

Share this post


Link to post
Share on other sites



$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

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

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

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