1

in java, is there any way i can find the location of a color on the screen? so if i know what the color is i get get the current location of it?

i can use the robot class to get a specific color but i need to be able to locate the color on the screen where ever it is.

if this cannot be done with robot or anouther class, i would appresiate it if someone could point me in the right direction by telling me what i need to do. thanks

if so could anyone please help me with what api to use or how to do it?

JAVA
  • 29
  • 5
  • So, you can grab a screen shot using Robot, you can find the color in the screen shot, but you can't translate the pixel x/y back to the screen?? – MadProgrammer Jul 31 '12 at 05:30
  • well im trying to find if i can locate the color while its moving so ican click it? – JAVA Jul 31 '12 at 05:33
  • Ahhh, okay. I don't think Java has anything that's fast enough to capture the entire screen (a smaller region might be doable) - just to clarify, is this within you program (ie within the applications window) or externally (ie something OS is producing or another application)? – MadProgrammer Jul 31 '12 at 05:38
  • preferably for games and things. not for personal use, just to learn better java. so any possible way you can think of would be useable by me – JAVA Jul 31 '12 at 05:39
  • Well, I just did a quick Google and found http://code.google.com/p/java-screen-recorder/ - don't know if it would fast enough, but might worth a look – MadProgrammer Jul 31 '12 at 05:42
  • ahh, i think i said wrong or you misunderstood, im thinking to make something to do what i mentioned. i have already made a mouse recorder :) – JAVA Jul 31 '12 at 05:45

1 Answers1

1

The real question is, why am I Goggling this for you :P

Community
  • 1
  • 1
MadProgrammer
  • 343,457
  • 22
  • 230
  • 366
  • i was really asking if there is a way i can make this happen in my code – JAVA Jul 31 '12 at 05:56
  • but i do appresiate that you bothered to google anything for someone – JAVA Jul 31 '12 at 05:56
  • I would have though the second link would have directed you in the right direction. Basically, as I understand it, you need to get a screen shot (fast) - Robot, but quicker. From what I've read, these seem to be able to do that :P – MadProgrammer Jul 31 '12 at 06:05
  • i have never used screen shots just Robots getPixelColor(x, y). could i get every color of every pixel on the screen using this and check if the color is the same as the color i want to click on the screen? – JAVA Jul 31 '12 at 07:36
  • Sure, I don't know he fast it will be though – MadProgrammer Jul 31 '12 at 10:01