Swisss

Setting a While Loop to Loop x Number of Times?

3 posts in this topic

I have the script.

HotKeySet("{F9}","myExit")

HotKeySet("{ENTER}","SendEnter")

While 1
   $i = 0
Do

WinActivate("Window1")

   sleep(2000)
    MouseClick("left", 889, 364)
    sleep(33000)
   MouseClick("left", 1581, 762)
   sleep(5500)
    MouseClick("left", 1581, 762)


$i += 1

Until $i = 29

   sleep(5500)
   MouseClick("left", 1581, 762)
   sleep(4000)
   MouseClick("left", 1581, 762)
  sleep(5000)
  MouseClick("left", 883, 515)
   sleep(3000)
   MouseClick("left", 780, 142)
   sleep(6000)
   MouseClick("left", 265, 222)
   sleep(4000)
   MouseClick("left", 1004, 586)
   sleep(2000)
   MouseClick("left", 1583, 842)
   sleep(2000)
   MouseClick("left", 1059, 468)
   sleep(45000)
   MouseClick("left", 722, 64)


WEnd

Func myExit()
   msgbox(0,"Exiting program","Good Bye!")
   Exit
EndFunc

Basically, I want the While loop to loop 3 times. Then have another do loop, loop once. So it would start and loop until i=29, then do the next loop once and do this three times. Then it would have another do loop, loop once and then restart at i=0. Thank you very much for your help.

Share this post


Link to post
Share on other sites



I would suggest using a for loop instead.  

for $a=0 to 2 
        ; do stuff
next

If you really want to use a while loop you can add a counter inside it with a condition (If $counter=2 then ExitLoop EndIf).  

In your example you probably wanted nested loops.  You can use an outer for loop that runs three time and an inner for loop that runs 29 times or whatever you want it to be.

for $a=0 to 2 
    for $b=0 to 29
        ; do stuff
    next 
next

 

1 person likes this

Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Share this post


Link to post
Share on other sites

Mousclick is one of the worst and unsafest way to automate a application. So pease post name that better help is possible.

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