Image Recognition: Multiple images Question

General Macro Scheduler discussion

Moderators: JRL, Dorian (MJT support)

Post Reply
Bobhamlton5150
Newbie
Posts: 4
Joined: Tue Dec 11, 2007 4:57 am

Image Recognition: Multiple images Question

Post by Bobhamlton5150 » Tue Dec 11, 2007 5:05 am

I am using the Image recognition for a game. I have watched the Video where it was used for Outlook and read a lot on the forum, but i am still stumped.

I would like my macro to wait for several random images, possibly ten different ones to be exact and then once one of the images pops up to run a set of commands that I have written. Then repeat the procces till i tell it to stop.

The majority of the images will be of coordinates on a map, i.e. 62,54

I have tried the screencapture and findimage but if i barely touch the mouse it seems the captured screen changes too much and it stops.

Any suggestions or direction in which i can find the answer would be greatly appreciated.

Thanks

User avatar
pgriffin
Automation Wizard
Posts: 460
Joined: Wed Apr 06, 2005 5:56 pm
Location: US and Europe

Post by pgriffin » Tue Dec 11, 2007 5:16 am

To search for multiple files, you will need to capture examples of each one, and choose what the search sequence should be so that your code starts looking for image1 and goes to imageN acting on whichever image is found. This will certainly take a few seconds to step through, which may allow the screen in a game enough time to change anyway...back to square one...

Bobhamlton5150
Newbie
Posts: 4
Joined: Tue Dec 11, 2007 4:57 am

Post by Bobhamlton5150 » Tue Dec 11, 2007 5:30 am

I have the images captured. I apologize, I should be clearer in what problem I am having.

Here is a sample of what I mean

WaitScreenImage>C:\Documents and Settings\Computer\My Documents\My Pictures\outside.bmp
WaitScreenImage>C:\Documents and Settings\Computer\My Documents\My Pictures\menu.bmp
WaitScreenImage>C:\Documents and Settings\Computer\My Documents\My Pictures\enter.bmp

If>outside>0
MouseMove>150,350
RClick
Endif

If>menu>0
MouseMove>230,560
LClick
Endif

If>enter>0
MouseMove>299,100
LClick
Endif

I can get it to work if I remove the second two wait commands, but thats only half of what i want it to do. I would like it to find 1-10 of the images i have then if it finds one execute a mouse movement which i have listed.

I hope this is a little more specific

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

Post by Marcus Tettmar » Tue Dec 11, 2007 10:50 am

Sounds like you need to be using FindImagePos which returns the number of matches found. For brevity my example just deals with three possible images:

Code: Select all

Label>image_search

FindImagePos>image1.bmp,SCREEN,0,1,X1,Y1,NumFound1
FindImagePos>image2.bmp,SCREEN,0,1,X2,Y2,NumFound2
FindImagePos>image3.bmp,SCREEN,0,1,X2,Y2,NumFound3
etc

If>NumFound1>0
  MouseMove>150,350
  RClick
Else
  If>NumFound2>0
    MouseMove>230,560
    RClick
  Else
    If>NumFound3>0
      MouseMove>299,100
      LClck
    Else
      //nothing was found, loop back and try again
     Wait>0.2
     Goto>image_search
    Endif
  Endif
Endif
If I have understood your requirements then that is what you want.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

Bobhamlton5150
Newbie
Posts: 4
Joined: Tue Dec 11, 2007 4:57 am

Post by Bobhamlton5150 » Wed Dec 12, 2007 8:51 am

The macro worked beautifully. I really appreciate the imput and support.

There is one more thing that I am curious about.

Would it be possible, while the above macro is running to have the macro also hit the tab button repeatedly, non stop maybe in 5 sec intervals?

Thanks very much. All you forum helpers are computer geniuses to my roommate and I. Again I really appreciate the help.

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

Post by Marcus Tettmar » Wed Dec 12, 2007 9:43 am

Yes, within the loop add:

Press Tab

It will then hit Tab repeatedly while it is looping.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

Bobhamlton5150
Newbie
Posts: 4
Joined: Tue Dec 11, 2007 4:57 am

Post by Bobhamlton5150 » Fri Dec 14, 2007 7:54 am

I am having trouble now getting the tab loop to repeat enough times. Ideally I would like it to repeat every 3 secs continuously, while the macro is searching for the images.

Also I believe the image recognition is having trouble distinguishing the images I have. They are of coordinates, which are yellow numbers that look much like this 63,45; 64,72; etc. The image is as small as i can make it without cutting off the numbers themselves. Any suggestions?

Code: Select all

SetFocus>Game
Label>image_search
 Press Tab
 Wait>0.2
 MClick
 Wait>0.2
 Send Character/Text>0
 Wait>0.2
FindImagePos>C:\Documents and Settings\Computer\My Documents\My Pictures\outside.bmp,SCREEN,10,1,X2,Y2,NumFound1
FindImagePos>C:\Documents and Settings\Computer\My Documents\My Pictures\start.bmp,SCREEN,10,1,X2,Y2,NumFound2
FindImagePos>C:\Documents and Settings\Computer\My Documents\My Pictures\wolf.bmp,SCREEN,10,1,X2,Y2,NumFound3
FindImagePos>C:\Documents and Settings\Computer\My Documents\My Pictures\Stone.bmp,SCREEN,10,1,X2,Y2,NumFound4
FindImagePos>C:\Documents and Settings\Computer\My Documents\My Pictures\blood.bmp,SCREEN,10,1,X2,Y2,NumFound5
FindImagePos>C:\Documents and Settings\Computer\My Documents\My Pictures\pike.bmp,SCREEN,10,1,X2,Y2,NumFound6

If>NumFound1>0
 MouseMove>150,350
 RClick
 Wait>0.2
 Goto>image_search
Else
 If>NumFound2>0
  Wait>15
  Press F6
  Wait>0.2
  Goto>image_search
 Else
  If>NumFound3>0
   Wait>15
   Press F8
   Wait>0.2
   Goto>image_search
  Else
   IF>NumFound4>0
	Wait>15
	Press F9
	Wait>0.2
	Goto>image_search
   Else
	IF>NumFound5>0
	 Wait>15
	 Press F7
	 Wait>0.2
	 Goto>image_search
    Else
	 IF>NumFound6>0
	  Wait>15
	  Press F10
	  Wait>0.2
	  Goto>image_search
	 Else
      //nothing was found, loop back and try again
      Wait>0.2
      Goto>image_search
	 Endif
    Endif
   Endif
  Endif
 Endif
Endif
Again thanks for all the wonderful help. My roommate is starting to take notice and wanting me to show him what I know.

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

Post by Marcus Tettmar » Fri Dec 14, 2007 8:54 am

Your script presses tab, then the middle mouse button then sends zero and THEN searches for each image in turn. It is sequential. If you want to send the tab etc WHILE the images are being searched you're gonna have to use two scripts running at the same time.

Can you clarify what you mean by "I believe the image recognition is having trouble distinguishing the images"? Have you used the debugger, or some diagnostic messagemodals, to see what the FindImagePos functions are returning - are they finding no images, or more than one? Have you tried changing the color tolerance figure to zero to make it look for an exact match? Don't forget that these image searches take place in a loop - at certain times there may be no match for any of them.

Version 10, which is in beta, lets you increase the number of scan pixels to increase the accuracy for situations where the image may not differ sufficiently from others (lots of background for example). Version 10's FindImagePos command is also super fast compared to v9 and would therefore be better suited for gaming.
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