How to Loop Until an Image Found?

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
LeoparD
Newbie
Posts: 2
Joined: Mon May 21, 2018 9:41 pm

How to Loop Until an Image Found?

Post by LeoparD » Mon May 21, 2018 9:51 pm

Hello there, I checked youtube videos, manuals and other topics but can't figure out how to loop my mouse click until an image is found. I know this one is basic but I need your help.

To be exact:

Code: Select all

MouseMove>839,732
LClick
I want the click every 200 ms until image capture gets this:

Code: Select all

ScreenCapture>559,355,633,425,%TEMP_DIR%\screenrect.bmp
//Find and Left Click To the Right of the 
FindImagePos>%BMP_DIR%\image_3.bmp,%TEMP_DIR%\screenrect.bmp,0.7,8,XArr,YArr,NumFound,CCOEFF
If>NumFound>0
  MouseMove>{%XArr_0%+559+600},{%YArr_0%+355}
  LClick
Endif
I'm really thankful for your time and effort.

redcloud
Newbie
Posts: 3
Joined: Sat May 19, 2018 8:38 pm

Re: How to Loop Until an Image Found?

Post by redcloud » Mon May 21, 2018 10:15 pm

I think this is what your asking.

Code: Select all

label>startclick

ScreenCapture>559,355,633,425,%TEMP_DIR%\screenrect.bmp
//Find and Left Click To the Right of the 
FindImagePos>%BMP_DIR%\image_3.bmp,%TEMP_DIR%\screenrect.bmp,0.7,8,XArr,YArr,NumFound,CCOEFF
If>NumFound>0
  MouseMove>{%XArr_0%+559+600},{%YArr_0%+355}
  LClick
goto>afterimange
Endif

MouseMove>839,732
LClick
wait>0.2
goto>startclick

label>afterimange
other code here
-------------this will effectively check for the image, if its found will jump to the next part of your script, if its not found then it will click like you wanted, then wait for 200ms and go back to check for the image again until the image is found.

LeoparD
Newbie
Posts: 2
Joined: Mon May 21, 2018 9:41 pm

Re: How to Loop Until an Image Found?

Post by LeoparD » Mon May 21, 2018 10:30 pm

Thanks a lot! It actually is better for me that it checks for the image every time before clicking. Thank you.

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