Jump to content

Setting a While Loop to Loop x Number of Times?


Recommended Posts

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.

Link to comment
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

 

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

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