How to repeat this code until there is no more same image

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
ishaanmusic
Newbie
Posts: 2
Joined: Sun Jun 14, 2020 4:06 pm

How to repeat this code until there is no more same image

Post by ishaanmusic » Sun Jun 14, 2020 4:09 pm

//Wait for
WaitScreenImage>%BMP_DIR%\image_2.bmp,0.6,CCOEFF

//Find and Left Click Center of
FindImagePos>%BMP_DIR%\image_2.bmp,SCREEN,0.7,1,XArr,YArr,NumFound,CCOEFF
If>NumFound>0
MouseMove>XArr_0,YArr_0
LClick
Endif


i want to repeat till there is no more same FIndimage POs

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 679
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: How to repeat this code until there is no more same image

Post by Dorian (MJT support) » Mon Jun 15, 2020 9:40 am

You can do that with While/EndWhile, so the code will keep looping until a certain condition is met. If the image is visible and found by FindImagePos, NumFound will be 1. So we can keep looping until it is no longer 1. Note that we set NumFound to 1 before the While/Endwhile loop to ensure the condition is met for the first cycle.

Code: Select all

//Wait for
WaitScreenImage>%BMP_DIR%\image_2.bmp,0.6,CCOEFF

Let>NumFound=1
While>NumFound>0
  //Find and Left Click Center of
  FindImagePos>%BMP_DIR%\image_2.bmp,SCREEN,0.7,1,XArr,YArr,NumFound,CCOEFF
  If>NumFound>0
    MouseMove>XArr_0,YArr_0
    LClick
  Endif
Endwhile

//You can delete this
mdl>It's not there now
Yes, we have a Custom Scripting Service. Message me or go here

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