# Thread: Java Robot: Getting the X, Y location of a pixel with a certain color. Impossible?

1. Member
Join Date
Dec 2011
Posts
31
Rep Power
0

## Java Robot: Getting the X, Y location of a pixel with a certain color. Impossible?

I was working on an artistic demonstrative program that makes used of Java's Robot Class, Robot (Java 2 Platform SE v1.4.2) .

Basically, I ran into a couple of speed bumps where I wanted to have the program draw a specific pattern going from different colors.
I already know how to find those pixels on the screen, get their pixel colors (Red, Green Blue), and store them in an array if I wanted, but I haven't ever learned about a method to have the robot point the mouse (mouseMove(x,y)) at the location of that pixel where it found that specific color.

For Example:
If my program scans the screen and finds a pixel with a color value of [Red = 122, Blue = 89, Green = 34], how can I get the X,Y location of where that specific pixel was found at?

I've tried many methods and techniques of trying to accomplish this, but nothing has worked so far.

In essence, I need the x,y location of a pixel that has a certain color. Impossible?

If anyone here has specific knowledge in this field of java , help me out

2. Moderator
Join Date
Feb 2009
Location
New Zealand
Posts
4,712
Rep Power
15

## Re: Java Robot: Getting the X, Y location of a pixel with a certain color. Impossible

If my program scans the screen and finds a pixel with a color value of [Red = 122, Blue = 89, Green = 34], how can I get the X,Y location of where that specific pixel was found at?
I'm missing something here... You say you find a pixel, but then say you don't have X/Y coordinates. Isn't that what "finding" is? Perhaps you could post the code that finds the pixel.

3. Member
Join Date
Dec 2011
Posts
31
Rep Power
0

## Re: Java Robot: Getting the X, Y location of a pixel with a certain color. Impossible

Originally Posted by pbrockway2
I'm missing something here... You say you find a pixel, but then say you don't have X/Y coordinates. Isn't that what "finding" is? Perhaps you could post the code that finds the pixel.
Sorry for the confusing explanation.
I meant that I scan the screen and get the color values of every pixel on it.
I want my robot to do a mouse move to the location where it found the specific colored pixel I was looking for. (mouse move to Red 34, Green 52, Blue 10)

However the mouseMove(int x, int y) method of the robot class does not take color values - only X and Y coordinates.

There is only one concept I can think of in the area Artificial Intelligence that might be able accomplish something like this - a neural network that is able to distinguish between the "bad pixels" and the ones I want the robot to mouseMove to.
Last edited by JeffThomas; 12-03-2011 at 08:25 AM.

4. ## Re: Java Robot: Getting the X, Y location of a pixel with a certain color. Impossible

location where it found the specific colored pixel
Does that location have x,y values that you can use with mouseMove()?

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•