I'm new and I need a little help...

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
gnastie
Newbie
Posts: 5
Joined: Thu May 14, 2020 3:38 am

I'm new and I need a little help...

Post by gnastie » Thu May 14, 2020 3:45 am

How do you make it so that a portion of the script will stop repeating if an image is not found on the screen? I need the portion to be able to keep repeating as long as the image is found on the screen and stop repeating this certain part of script once the image is no longer found.

Thank you for your time,
Isaac

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

Re: I'm new and I need a little help...

Post by Dorian (MJT support) » Thu May 14, 2020 8:56 am

Hopefully this will be on the right track and give you some ideas.

If you're using the Image Recognition Wizard to generate FindImagePos IR code, you'll see something like this :

Code: Select all

FindImagePos>%BMP_DIR%\image_1.bmp,SCREEN,0.7,1,XArr,YArr,NumFound,CCOEFF
If>NumFound>0
  MouseMove>XArr_0,YArr_0
  LClick
Endif
This looks for an image, and then performs an action if it was found. e.g. if NumFound>0. If a match was found, move the mouse, and left click. The action only takes place if the image was found. If not, the code is ignored. It could simply be that your loop can go in there, but of course without knowing the rest of your script we can't say, so...

... you can make use of that variable later on in your script.

Let's change things a little first to make that variable unique, as all code generated with the Wizard will generate the same NumFound variable :

Code: Select all

//Find and Left Click Center of 
FindImagePos>%BMP_DIR%\image_1.bmp,SCREEN,0.7,1,XArr,YArr,Image1Found,CCOEFF
If>Image1Found>0
  MouseMove>XArr_0,YArr_0
  LClick
Endif
If the image was found, Image1Found will be >0. If it wasn't, it will be 0. We can now use this to control any aspect of our script.

//Do something if the image was found

Code: Select all

//Do something if the image was found 
If>Image1Found>0
  ...do something
Endif
//Do something if the image wasn't found

Code: Select all

//Do something if the image wasn't found 
If>Image1Found=0
  ...do something
Endif
//Do something if the image was found, and something else if it wasn't

Code: Select all

//Do something if the image was found, and something else if it wasn't 
If>Image1Found>0
  ...do something
  else
  ..do something else
Endif
Always remember your Endif.
Yes, we have a Custom Scripting Service. Message me or go here

gnastie
Newbie
Posts: 5
Joined: Thu May 14, 2020 3:38 am

Re: I'm new and I need a little help...

Post by gnastie » Thu May 14, 2020 8:17 pm

Works flawlessly, thanks so much!

I just wanted to say, compared to JitBit, this program and its community are so much better.

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

Re: I'm new and I need a little help...

Post by Dorian (MJT support) » Fri May 15, 2020 9:09 am

Always happy to help, and thank you for your kind comments.
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