Need help with repeat

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
Jimmie
Newbie
Posts: 10
Joined: Tue Jan 09, 2018 3:18 pm

Need help with repeat

Post by Jimmie » Sun Mar 11, 2018 10:12 pm

Pretty much I want to repeat a label>Start 10 times then move on to the next action but my repeat just keeps repeating itself.

Label>Start
Repeat>10
//Find and Left Click Center of
FindImagePos>%BMP_DIR%\image_9.bmp,SCREEN,0.7,1,XArr,YArr,NumFound,CCOEFF
If>NumFound>0
MouseMove>XArr_0,YArr_0
Wait>0.10
LClick
Endif
Unti>10
(Next action it gets stuck after until>10 and repeats instead of moving on)
//find and Left Click Center of
FindImagePos>%BMP_DIR%\image_5.bmp,SCREEN,0.7,1,XArr,YArr,NumFound,CCOEFF
If>NumFound>0
MouseMove>XArr_0,YArr_0
Wait>0.10
LClick
Endif

Here is a better explanation of what I'm trying to do ignore my pro paint skills :p

Image

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: Need help with repeat

Post by Marcus Tettmar » Sun Mar 11, 2018 10:50 pm

Should be like this:

Repeat needs a loop counter. The loop counter needs to be incremented. Until line is "Until>" not "Unti". Until needs to take a condition.

See:
https://help.mjtnet.com/article/144-how ... p-the-loop

So, your code should be something like this:

Code: Select all

Let>kounter=0
Repeat>kounter
   //Find and Left Click Center of 
   FindImagePos>%BMP_DIR%\image_9.bmp,SCREEN,0.7,1,XArr,YArr,NumFound,CCOEFF
   If>NumFound>0
      MouseMove>XArr_0,YArr_0
      Wait>0.10
      LClick
   Endif
   Let>kounter=kounter+1
Until>kounter=10

//find and Left Click Center of 
FindImagePos>%BMP_DIR%\image_5.bmp,SCREEN,0.7,1,XArr,YArr,NumFound,CCOEFF
If>NumFound>0
   MouseMove>XArr_0,YArr_0
   Wait>0.10
   LClick
Endif
Let's look at that first loop in real english. We say set "kounter" to zero. Then Repeat ... Until our kounter equals 10. Inside the loop we add 1 to kounter (kounter becomes kounter + 1). So kounter increments by 1 for each iteration. So when it becomes 10 the Until condition (kounter=10) becomes TRUE so the loop ends.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Jimmie
Newbie
Posts: 10
Joined: Tue Jan 09, 2018 3:18 pm

Re: Need help with repeat

Post by Jimmie » Sun Mar 11, 2018 11:43 pm

I figured it out this works pretty good if anyone else has issues.


Let>k=0
Label>Start
Let>k=k+1
Actions you want to repeat
If>k<21 (change 21 to the number you want to repeat)
Wait>0.10
Goto>Start

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: Need help with repeat

Post by Marcus Tettmar » Sun Mar 11, 2018 11:53 pm

Jimmie wrote:I figured it out this works pretty good if anyone else has issues.


Let>k=0
Label>Start
Let>k=k+1
Actions you want to repeat
If>k<21 (change 21 to the number you want to repeat)
Wait>0.10
Goto>Start
See my reply above with a repeat/until version and link to an article on the three main ways to loop.

Sent from my Pixel 2 using Tapatalk
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts