Swisss

How Would I Loop Two Seperate Do Functions?

10 posts in this topic

HotKeySet("{F9}","myExit")
Local $i = 0
Local $u = 0

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


Do

WinActivate("WINDOW 1")

   sleep(2000)
    MouseClick("left", 912, 374)
    sleep(32500)

   MouseClick("left", 1026, 48)
   MouseClick("left", 81, 83)
   sleep(5000)

    MouseClick("left", 801, 854)


$i = $i + 1

Until $i = 30
Do

   sleep(5000)
   WinActivate("WINDOW 2")
   MouseClick("left", 372, 241)
   MouseClick("left", 388, 240)
   Send("{ENTER}")
   sleep(9000)
   WinActivate("WINDOW 1")
   MouseClick("left", 737, 61)
   $u = $u + 1

Until $u = 1

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

Basically I want it to do the action untill it reaches 30, then do the second action once, then loop this process infinitely. Thanks in advance.

Share this post


Link to post
Share on other sites



Then you should put your two "Do ... Until" in a While loop, like this :

HotKeySet("{F9}","myExit")
Local $i = 0
Local $u = 0

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

While 1 ; repeat it forever

  Do

  WinActivate("WINDOW 1")

     sleep(2000)
      MouseClick("left", 912, 374)
      sleep(32500)

     MouseClick("left", 1026, 48)
     MouseClick("left", 81, 83)
     sleep(5000)

      MouseClick("left", 801, 854)


  $i = $i + 1

  Until $i = 30
  Do

     sleep(5000)
     WinActivate("WINDOW 2")
     MouseClick("left", 372, 241)
     MouseClick("left", 388, 240)
     Send("{ENTER}")
     sleep(9000)
     WinActivate("WINDOW 1")
     MouseClick("left", 737, 61)
     $u = $u + 1

  Until $u = 1
  
WEnd ; End of the infinite While loop

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

I did not test it, but it should do what you want.

1 person likes this

Share this post


Link to post
Share on other sites

You don't need the second Do Until loop, as its only once the while 1 loop will do it once then start the process again from the first Do Until loop.

1 person likes this

Share this post


Link to post
Share on other sites

@_joboy2k

Then how will it perfom the "2nd action". I think the way you suggested won't work.

Forgive me if am wrong.

 

1 person likes this

Share this post


Link to post
Share on other sites
HotKeySet("{F9}","myExit")
Local $i = 0
Local $u = 0

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

While 1 ; repeat it forever

  Do

     WinActivate("WINDOW 1")

     sleep(2000)
     MouseClick("left", 912, 374)
     sleep(32500)

     MouseClick("left", 1026, 48)
     MouseClick("left", 81, 83)
     sleep(5000)

     MouseClick("left", 801, 854)


  $i += 1

  Until $i = 30

  sleep(5000)
  WinActivate("WINDOW 2")
  MouseClick("left", 372, 241)
  MouseClick("left", 388, 240
  Send("{ENTER}")
  sleep(9000)
  WinActivate("WINDOW 1")
  MouseClick("left", 737, 61)

  
WEnd ; End of the infinite While loop

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

 

1 person likes this

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

My mistake, I should have noticed that the second While was not necessary (because it's repeated only once ...).
 You did well by correcting me.

Edited by Jules
1 person likes this

Share this post


Link to post
Share on other sites

The script from joboy2k is also wrong, it works only in first loop correct. Assigning $i=0 after the While will correct this.

1 person likes this

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

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

While 1 ; repeat it forever
    $i = 0
  Do
    
     WinActivate("WINDOW 1")

     sleep(2000)
     MouseClick("left", 912, 374)
     sleep(32500)

     MouseClick("left", 1026, 48)
     MouseClick("left", 81, 83)
     sleep(5000)

     MouseClick("left", 801, 854)


  $i += 1

  Until $i = 30

  sleep(5000)
  WinActivate("WINDOW 2")
  MouseClick("left", 372, 241)
  MouseClick("left", 388, 240)
  Send("{ENTER}")
  sleep(9000)
  WinActivate("WINDOW 1")
  MouseClick("left", 737, 61)

  
WEnd ; End of the infinite While loop

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

yeah sorry, i copy and pasted straight back into forum and didn't test. thanks. i have made the changes to correct the mistake.

Edited by joboy2k
1 person likes this

Share this post


Link to post
Share on other sites
5 hours ago, joboy2k said:
HotKeySet("{F9}","myExit")
HotKeySet("{ENTER}","SendEnter")

While 1 ; repeat it forever
    $i = 0
  Do
    
     WinActivate("WINDOW 1")

     sleep(2000)
     MouseClick("left", 912, 374)
     sleep(32500)

     MouseClick("left", 1026, 48)
     MouseClick("left", 81, 83)
     sleep(5000)

     MouseClick("left", 801, 854)


  $i += 1

  Until $i = 30

  sleep(5000)
  WinActivate("WINDOW 2")
  MouseClick("left", 372, 241)
  MouseClick("left", 388, 240
  Send("{ENTER}")
  sleep(9000)
  WinActivate("WINDOW 1")
  MouseClick("left", 737, 61)

  
WEnd ; End of the infinite While loop

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

yeah sorry, i copy and pasted straight back into forum and didn't test. thanks. i have made the changes to correct the mistake.

 

4

This does not work either it gives a parsing error at line 19.

Share this post


Link to post
Share on other sites
16 minutes ago, Swisss said:

This does not work either it gives a parsing error at line 19.

sorry once again :) I'm having a bad day, thought i would try and help but i keep getting it wrong :), i have taken the time and put it in to scite and this fully works for me

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

While 1 ; repeat it forever
    $i = 0
  Do
     WinActivate("WINDOW 1")
     sleep(2000)
     MouseClick("left", 912, 374)
     sleep(32500)
     MouseClick("left", 1026, 48)
     MouseClick("left", 81, 83)
     sleep(5000)
     MouseClick("left", 801, 854)
     $i += 1
  Until $i = 30

  sleep(5000)
  WinActivate("WINDOW 2")
  MouseClick("left", 372, 241)
  MouseClick("left", 388, 240)
  Send("{ENTER}")
  sleep(9000)
  WinActivate("WINDOW 1")
  MouseClick("left", 737, 61)
  
WEnd ; End of the infinite While loop

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

Func SendEnter()
    Msgbox(0,"test","test")
EndFunc

 

1 person likes this

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