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
I'm new and I need a little help...
Moderators: JRL, Dorian (MJT support)
- Dorian (MJT support)
- Automation Wizard
- Posts: 1415
- Joined: Sun Nov 03, 2002 3:19 am
Re: I'm new and I need a little help...
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 :
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 :
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
//Do something if the image wasn't found
//Do something if the image was found, and something else if it wasn't
Always remember your Endif.
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
... 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
//Do something if the image was found
Code: Select all
//Do something if the image was found
If>Image1Found>0
...do something
Endif
Code: Select all
//Do something if the image wasn't found
If>Image1Found=0
...do something
Endif
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
Re: I'm new and I need a little help...
Works flawlessly, thanks so much!
I just wanted to say, compared to JitBit, this program and its community are so much better.
I just wanted to say, compared to JitBit, this program and its community are so much better.
- Dorian (MJT support)
- Automation Wizard
- Posts: 1415
- Joined: Sun Nov 03, 2002 3:19 am
Re: I'm new and I need a little help...
Always happy to help, and thank you for your kind comments.