help with Find Image

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
ihat
Newbie
Posts: 3
Joined: Mon Feb 12, 2018 5:58 pm

help with Find Image

Post by ihat » Mon Feb 12, 2018 6:07 pm

Hello,

glad to be here and appreciate any help provided from the masters in this forum

i need a macro to detect 4 images and combine 2 images when found and order a mouse click.

managed to work it but when i click run nothing happens, but no error message or error box displayed.

can't figure out what's wrong ScreenCapture>991,552,1080,587,%TEMP_DIR%\screenrect.bmp
//Find
FindImagePos>%BMP_DIR%\image_1.bmp,%TEMP_DIR%\screenrect.bmp,0.7,1,XArr,YArr,NumFound1,CCOEFF
ScreenCapture>131,556,238,586,%TEMP_DIR%\screenrect.bmp
//Find
FindImagePos>%BMP_DIR%\image_1.bmp,%TEMP_DIR%\screenrect.bmp,0.7,1,XArr,YArr,NumFound2,CCOEFF
ScreenCapture>997,557,1087,586,%TEMP_DIR%\screenrect.bmp
//Find
FindImagePos>%BMP_DIR%\image_2.bmp,%TEMP_DIR%\screenrect.bmp,0.7,1,XArr,YArr,NumFound3,CCOEFF
ScreenCapture>131,557,222,585,%TEMP_DIR%\screenrect.bmp
//Find
FindImagePos>%BMP_DIR%\image_2.bmp,%TEMP_DIR%\screenrect.bmp,0.7,1,XArr,YArr,NumFound4,CCOEFF
If>(NumFound1 && NumFound2)>0
MouseMoveRel>56,248
LClick
MouseMoveRel>51,224
LClick
Until><>
Goto>Image_search
Else
If>(NumFound1 && NumFound4)>0
MouseMoveRel>55,249
LClick
Until><>
Goto>Image_search
Else
If>(NumFound3 && NumFound4)>0
MouseMoveRel>55,249
LClick
MouseMoveRel>107,222
LClick
Until><>
Goto>Image_search
Else
If>(NumFound3 && NumFound2)>0
MouseMoveRel>55,249
LClick
Until><>
Goto>Image_search
Else
//Loop back and try again
Endif
Endif
Endif
Endif

User avatar
Marcus Tettmar
Site Admin
Posts: 7378
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: help with Find Image

Post by Marcus Tettmar » Tue Feb 13, 2018 6:24 pm

Your IFs are failing because you're using syntax not recognised by MacroScript. I don't know what && means - presume that's an AND? If so should be:

Code: Select all

If>{(%NumFound1% >0) AND (%NumFound2%>0)}
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

ihat
Newbie
Posts: 3
Joined: Mon Feb 12, 2018 5:58 pm

Re: help with Find Image

Post by ihat » Wed Feb 14, 2018 12:46 pm

Thanks Marcus, i did the change as advised but the macro isn't running, I'm not familiar with the macro scheduler yet, when i click run the red X stop appear for milliseconds and the run box is activated again.
but on top middle of the screen i see the message that the macro is running but nothing happens is it that the images are not detected or something else.

thanks

ihat
Newbie
Posts: 3
Joined: Mon Feb 12, 2018 5:58 pm

Re: help with Find Image

Post by ihat » Thu Feb 15, 2018 7:24 pm

Hello,

Managed to run the Macro successfully :D
I have 4 images
the conditions
if 1&2 found 2 mouse clicks
if 1 & 4 found 1 mouse click
the problem I want the macro to wait for the 1&4 to appear then the mouse click
the same applies for 3&4 wait and if 3&2 appear then mouse click

I added Else in between but doesn't seem to work

appreciate if someone can help on how to do that...

Label>Image_search
ScreenCapture>979,356,1310,539,%TEMP_DIR%\screenrect.bmp
//Find
FindImagePos>%BMP_DIR%\image_1.bmp,%TEMP_DIR%\screenrect.bmp,0.7,1,XArr,YArr,NumFound1,CCOEFF
ScreenCapture>306,358,638,546,%TEMP_DIR%\screenrect.bmp
//Find
FindImagePos>%BMP_DIR%\image_2.bmp,%TEMP_DIR%\screenrect.bmp,0.7,1,XArr,YArr,NumFound4,CCOEFF
ScreenCapture>306,360,647,549,%TEMP_DIR%\screenrect.bmp
//Find
FindImagePos>%BMP_DIR%\image_3.bmp,%TEMP_DIR%\screenrect.bmp,0.7,1,XArr,YArr,NumFound2,CCOEFF
ScreenCapture>973,351,1322,552,%TEMP_DIR%\screenrect.bmp
//Find
FindImagePos>%BMP_DIR%\image_5.bmp,%TEMP_DIR%\screenrect.bmp,0.7,1,XArr,YArr,NumFound3,CCOEFF
If>{(%NumFound1%>0) AND (%NumFound2%>0)}
MouseMove>45,244
LClick
MouseMove>45,217
LClick
Else
If>{(%NumFound1%>0) AND (%NumFound4%>0)}
MouseMove>101,218
LClick
Else
Goto>Image_search
Endif
Endif
If>{(%NumFound3%>0) AND (%NumFound4%>0)}
MouseMove>42,243
LClick
MouseMove>101,218
LClick
Else
If>{(%NumFound3%>0) AND (%NumFound2%>0)}
MouseMove>101,218
LClick
Else
Goto>Image_search
Endif
Endif

User avatar
Marcus Tettmar
Site Admin
Posts: 7378
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: help with Find Image

Post by Marcus Tettmar » Mon Feb 19, 2018 8:05 pm

If you want to wait then you need to loop. So if nothing found loop back and try again. See:
https://help.mjtnet.com/article/144-how ... p-the-loop
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

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