Sign in to follow this  
Followers 0
Fickle

Loop, sleep, then loop again, Possible?

3 posts in this topic

I just started testing this (autoit) out today, but I want to make a script that will run a loop 20 times, sleep for about 20 seconds, then run the loop again. I have no experience in scripting, coding, or anything of the sort and so I am rather lost. So far, what i have is this:

$i = 0

While $i < 21

Send ("{Enter}")

Sleep (600)

Send ("{Enter}")

Sleep (1000)

Send ("{Enter}")

Sleep (600)

Send ("{Enter}")

Sleep (600)

Send ("{Enter}")

Sleep (1000)

Send ("2000000")

$i = $i + 1

WEnd

Sleep (20000)

$i = 0

While $i < 21

Send ("{Enter}")

Sleep (600)

Send ("{Enter}")

Sleep (1000)

Send ("{Enter}")

Sleep (600)

Send ("{Enter}")

Sleep (600)

Send ("{Enter}")

Sleep (1000)

Send ("2000000")

$i = $i + 1

WEnd

I am currently trying to make this an infinite loop, however I am clueless as to what I should do from here. Any help would be much appreciated. Furthermore, if there is a more efficient method than this, please let me know.

Share this post


Link to post
Share on other sites



What do you need this script for?

Share this post


Link to post
Share on other sites

This should do what you want

While 1 ;infinite loop
    For $i = 0 To 19 ;this is another type of loop. It will be repeated 20 times, then continue at line 15
        Send ("{Enter}")
        Sleep (600)
        Send ("{Enter}")
        Sleep (1000)
        Send ("{Enter}")
        Sleep (600)
        Send ("{Enter}")
        Sleep (600)
        Send ("{Enter}")
        Sleep (1000)
        Send ("2000000")
    Next
    Sleep (20000)
WEnd

If there is a more efficient method than this, please let me know.

To improve this script we'd have to know more about what you are trying to automate, but in general this type of script can be made more reliable by the use of controlsend, and faster by replacing sleep with a way to check if the next control/ window is ready for input yet.

p.s. if you put your script in [autoit], or

tags it will be easier on the eye.

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