Fast Image Recognition and Screen Limit

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
ggripp
Newbie
Posts: 4
Joined: Tue Dec 22, 2015 9:42 am

Fast Image Recognition and Screen Limit

Post by ggripp » Wed Jan 06, 2016 5:40 pm

Hi guys, i'm trying to create a macro to use in a game...

I'm having 2 problems...
1st> Is there any way to limit the area where the script will try to find the image? I want it to look for the image only in a specific 200x200 area on the center of my screen...

2nd> The image that i'm trying to find is a pretty fast animation... sometimes the animation runs 20 times before the macro successfully recognize the image and run the rest of the script... any way to make it better?

Code: Select all

Label>1
FindImagePos>C:\macro\fish.bmp,SCREEN,40,1,XArr,YArr,fish
If>fish>0
Press LCTRL
Send>z
Wait>1
Press LCTRL
Send>z
Release LCTRL
MouseMove>555,320
LClick
Wait>2
Endif
Goto>1


This is the image i'm using as parameter
Image

and this is the animation.
Image

Thanks in advance.
Srry about my terrible english. :roll: :oops:

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

Re: Fast Image Recognition and Screen Limit

Post by Marcus Tettmar » Thu Jan 07, 2016 1:17 pm

Hi,

1) You can specify a window instead of SCREEN, or if you want a portion of the screen first use ScreenCapture to capture that portion to a BMP and then specify that BMP in FindImagePos.

2) No, not really.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

User avatar
PepsiHog
Automation Wizard
Posts: 517
Joined: Wed Apr 08, 2009 4:19 pm
Location: Florida

Re: Fast Image Recognition and Screen Limit

Post by PepsiHog » Mon Feb 01, 2016 12:27 am

Hi ggripp,

A possible solution is to think about what is not there when the animation is. Invert what you are trying to do. Is there something else that only is true when the animation is there?

-or-

Use getpixelcolor. The little image in the center moves up and down slightly, but I bet there is at least one of those red pixels that stays red, no matter if the fish is up or down. In other words, the screen x,y is always red. You can also check for other pixels and their color.

Better yet, maybe look at a pixel that alternates between red and another color (like white at the bottom of the fish) This doesn't likely happen on any other image, in the exact same spot.

Good Luck, Hope I helped,
PepsiHog

[edit] - I pointed with my mouse at the white on the fish (white could be yellow) but the point my mouse pointed at was white when the animation was up, and red when the animation was down.

I will write an example script, but I can't do it right now.
Windows 7

PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2024) AND enjoy programming. (That's my little piece of heaven!)

The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!

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