Results 1 to 7 of 7
Thread: Robot class
- 07-11-2010, 03:04 PM #1
Senior Member
- Join Date
- Dec 2009
- Posts
- 104
- Rep Power
- 0
Robot class
Hello people,
I have made the following code.
Now what i want to do is: search the screen for the color we have found earlier. I haven't found any method doing this. Does it exist?Java Code:/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package javaapplication2; import java.awt.AWTException; import java.awt.Color; import java.awt.MouseInfo; import java.awt.Point; import java.awt.Robot; public class Main { /** * @param args the command line arguments */ public static void main(String[] args) { try { Robot bot = new Robot(); System.out.println("Please move your mouse to the monster to attack /n" + "and keep it on it for 5 seconds."); // just some message Point location = MouseInfo.getPointerInfo().getLocation(); //mouse position int mouseX = (int)location.getX(); int mouseY = (int)location.getY(); Color pixelcolor; //declaring the variable where the color of the pixel will be stored in bot.delay(5000); // 5 seconds sleep pixelcolor = bot.getPixelColor(mouseX, mouseY); //get the color of mouse position System.out.println(pixelcolor); // print it System.out.println("Bot will now start searching for monsters and attack."); } catch (AWTException AWT) { System.out.println("AWTException occured"); } } }
If not, i thought of the following. Move the mouse over the entire screen and check pixelcolor everytime, i know how to make this method i think. But would it be effective?Beginner in Java Programming, Please don't trust my anwsers blind please :D
- 07-11-2010, 03:22 PM #2
Yes there are ways to do this. Look at the PixelGrabber class. There probably is sample code here if you Search for that class name.search the screen for the color we have found earlier
It would allow you to look at all the pixels for an image.
- 07-11-2010, 03:41 PM #3
Senior Member
- Join Date
- Jul 2009
- Posts
- 1,143
- Rep Power
- 5
Use the Robot class to create a BufferedImage of the screen. Then you can search the BufferedImage one pixel at a time to find the matching pixels.
- 07-12-2010, 08:36 AM #4
Senior Member
- Join Date
- Dec 2009
- Posts
- 104
- Rep Power
- 0
Pixelgrabber can only search pixels in a image, what i want to do is search pixels in a computer game.
As for the bufferedImage how could i accomplish this?:confused:Beginner in Java Programming, Please don't trust my anwsers blind please :D
- 07-12-2010, 01:56 PM #5
Where are these pixels?search pixels in a computer game
What does being in a game mean?
- 07-12-2010, 05:52 PM #6
Senior Member
- Join Date
- Dec 2009
- Posts
- 104
- Rep Power
- 0
The pixels are on my screen, yet still i need to search a specifix color pixel on my screen.
Beginner in Java Programming, Please don't trust my anwsers blind please :D
- 07-12-2010, 05:54 PM #7
Similar Threads
-
Help with Robot Class
By protocos in forum EclipseReplies: 11Last Post: 10-05-2009, 08:15 PM -
Help with Java Robot and Runtime Class
By Rmond1254 in forum New To JavaReplies: 1Last Post: 02-18-2009, 06:33 AM -
Newbie - Robot Class
By drasgear in forum New To JavaReplies: 2Last Post: 11-14-2008, 04:46 PM -
Robot Class
By Jessie Madman in forum New To JavaReplies: 3Last Post: 05-15-2008, 04:13 AM -
Robot Class
By jfredrickson in forum New To JavaReplies: 2Last Post: 07-11-2007, 09:00 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks