Results 1 to 4 of 4
  1. #1
    doejohn is offline Member
    Join Date
    Jun 2010
    Posts
    4
    Rep Power
    0

    Default Detecting color change and clicking a button. awt.robot not fast enough?

    Hey, I've made a Java program that plays an Adobe Shockwave "game" for me. A part of it involves clicking a button in the game when a certain object passes by a specific point. The object is small, white and always passes by the same area, so to make it respond as fast as possible, I only check for 1 pixel to turn white, then click the button. It's pretty accurate, but about 10% of its attempts are slightly too slow. Is there any way to do this faster? Would a C#/C++ program be able to do this even faster?

    Java Code:
    import java.awt.*;
    public class myFastBot{
    	public static void main(String[] args) throws AWTException{
    		Robot robot = new Robot();
    		while (robot.getPixelColor(900, 400).getRed() < 255) {
    			// Waiting for pixel to turn white
    		}
    		// Pixel turned white. Now press the button - FAST!!
    		robot.mouseMove(950,500);
    		robot.mousePress(InputEvent.BUTTON1_MASK);
    		robot.mouseRelease(InputEvent.BUTTON1_MASK);
    		// Not always fast enough :(
    	}
    }

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,873
    Rep Power
    25

    Default

    To interact in realtime, you probably need to go native.

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

  4. #4
    doejohn is offline Member
    Join Date
    Jun 2010
    Posts
    4
    Rep Power
    0

    Default

    Ok thanks a lot. I'm trying to get this part done using native (C) methods now.

Similar Threads

  1. Get source web page after clicking next Button
    By noob in forum New To Java
    Replies: 1
    Last Post: 03-05-2010, 10:01 PM
  2. Change color of a region
    By sky in forum AWT / Swing
    Replies: 5
    Last Post: 11-24-2009, 04:47 PM
  3. Change the color in my program
    By carl in forum New To Java
    Replies: 5
    Last Post: 04-03-2009, 01:20 PM
  4. Color Change of data
    By Java.child in forum AWT / Swing
    Replies: 20
    Last Post: 02-12-2009, 07:51 AM
  5. How to change TXT color Onclick
    By dave700800 in forum New To Java
    Replies: 1
    Last Post: 12-08-2007, 02:39 AM

Posting Permissions

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