Hello i am very new to this. I am trying to make a very simple macro. It just needs to search for an image and click another image once the first image is found.
So far I can get it to find one image click the image and then move onto the next set of images. The problem is it only does this in the order i programmed it in. if i run the macro in between images it won't start until the first image is found.
How can i make it so that it will find any image no matter the order?
Help with image recognition wizard
Moderators: Dorian (MJT support), JRL
Re: Help with image recognition wizard
Here is what my test macro looks like. It finds the first image and clicks fine and then will find and click the second image. But if i start the program while the second image is up it will not click that image until the first image shows up.
//Wait for
WaitScreenImage>%BMP_DIR%\image_8.bmp,0.7,CCOEFF
//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
LClick
Endif
//Wait for
WaitScreenImage>%BMP_DIR%\image_11.bmp,0.7,CCOEFF
//Find and Left Click Center of
FindImagePos>%BMP_DIR%\image_11.bmp,SCREEN,0.7,1,XArr,YArr,NumFound,CCOEFF
If>NumFound>0
MouseMove>XArr_0,YArr_0
LClick
Endif
//Wait for
WaitScreenImage>%BMP_DIR%\image_8.bmp,0.7,CCOEFF
//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
LClick
Endif
//Wait for
WaitScreenImage>%BMP_DIR%\image_11.bmp,0.7,CCOEFF
//Find and Left Click Center of
FindImagePos>%BMP_DIR%\image_11.bmp,SCREEN,0.7,1,XArr,YArr,NumFound,CCOEFF
If>NumFound>0
MouseMove>XArr_0,YArr_0
LClick
Endif
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Re: Help with image recognition wizard
You could do it like this:
Code: Select all
Label>WaitForAnImage
Let>FoundAnImage=FALSE
FindImagePos>%BMP_DIR%\image_9.bmp,SCREEN,0.7,1,XArr,YArr,NumFound,CCOEFF
If>NumFound>0
MouseMove>XArr_0,YArr_0
LClick
Let>FoundAnImage=TRUE
Else
FindImagePos>%BMP_DIR%\image_11.bmp,SCREEN,0.7,1,XArr,YArr,NumFound,CCOEFF
If>NumFound>0
MouseMove>XArr_0,YArr_0
LClick
Let>FoundAnImage=TRUE
Endif
Endif
If>FoundAnImage=FALSE
//Neither image was found, loop back and look again
Wait>0.2
Goto>WaitForAnImage
Endif
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
-
- Newbie
- Posts: 1
- Joined: Wed Dec 09, 2015 11:59 am
Re: Help with image recognition wizard
Hello,
Its Useful For me
Its Useful For me
Re: Help with image recognition wizard
It works! Thanks for your input. My test macro currently looks like this. Only i need it to find an image and click on a different image. How would I do that?
Code: Select all
Label>WaitForAnImage
//Find and Left Click Center of
FindImagePos>%BMP_DIR%\image_4.bmp,SCREEN,0.7,1,XArr,YArr,NumFound,CCOEFF
If>NumFound>0
MouseMove>XArr_0,YArr_0
LClick
Let>FoundAnImage=TRUE
Endif
//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
LClick
Let>FoundAnImage=TRUE
Endif
If>FoundAnImage=FALSE
//Neither image was found, loop back and look again
Wait>0.2
Goto>WaitForAnImage
Endif
Label>WaitForAnImage
// do something here
Goto>WaitForAnImage
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Re: Help with image recognition wizard
Just put another FindImagePos inside the If .. Endif of your first one. So it looks for an image and IF found then looks for the second and clicks on THAT ONE ... e.g. *PSUEDO CODE*
Code: Select all
//Find FIRST image
FindImagePos>Image1,SCREEN,bla,bla
If>NumFound>0
//If FIRST image found, get position of image TWO and click on THAT
FindImagePos>Image2,SCREEN,bla,bla
If>Image2Found>0
MouseMove>Image2_X_0,Image2_Y_0
LClick
Endif
Endif
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?