Jump to content
Sign in to follow this  

Searching Multiple Pixels

Recommended Posts


What I am trying to do is identify certain key phrases/symbols on an application. On the application I am using the font is not copyable nore is it in a text box per say. It comes across the screen on top of other pixels displayed by the application.

for example If a user types the symbol "/" The "/" will display on my application above other pixels on my screen.

I know the exact color shades and the pixels relationship to the first pixel once it is found.

on a 800X600 screen I need to search roughly a 200X200 box.

I have been able to write code that would work however my code is very slow... the "/" disappears before my code even finds it. It is on display for maybe 3 seconds at most. and my program doesnt find the pixels efficiently enough to find and recognize the "/"

All in all the "/" character is about 12-16 pixels. I do not need to actually find all of those pixels, just enough for it to be unique from other characters and symbols it may find.

I have tried to things thus far:

1. pixelsearch() entering the cordinates and the first pixel with the color it would find in the /. Then I use the getpixelcolor() to find the next pixel and check to make sure its conistent with the next pixel in the symbol "/", it then continues to check the surrounding pixels in the order left to right line by line until it has found all the pixels (or enough to clearly establish that its a /.

2. I created a seudo cursor search approach and the getpixelcolor at the first pixel of my 200X200 search box and if it was the correct color of the first pixel then find the next pixel color and confirm its correct etc If it wasnt the correct color it would then get teh pixel color of the next pixel tot he right and continue across that row searching for the right color if it doesnt find it on that row it goes down to the next.

Option 2 (amazingly enough) seemed to be quicker than option 1 but it doesnt always find the "/" before it disappears off of the screen.

Is tehre a better way to do this?

The variable I do not know are where in the 200X200 window the "/" will appear. Since there are lots of other characters and symbols being typed it can potentially have the first few pixels in common with several other characters.

Any ideas? I thought of having it take a screenshot and comparing it to an image to find the image in the screen shot but I would have to have a way to determine when to take a screenshot... I suppose i could take one periodically every few seconds or few mileseconds but I doubt that would run very efficiently.

Share this post

Link to post
Share on other sites

Just so that you know... I am at work and cannot post my code for that reason. Once I get home I will try and upload the code I just wanted to get some ideas flowing.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this