0

i want my program to look for a colour near white and click on it. I know how to identify a colour when i point my mouse to it and my goal is to do the opposite

EX. search for a colour near white then click on it

    public static void klick ( int x , int y)
  {
    robot.mouseMove(x, y);
    robot.delay(5);
    robot.mousePress(MouseEvent.BUTTON1_MASK);
    robot.mouseRelease(MouseEvent.BUTTON1_MASK);
  }
  public static void colour (int x, int y)
  {
    robot.delay(5);
    Color color = robot.getPixelColor(x,y);
    robot.delay(5);
    System.out.println("Red   = " + color.getRed());
    System.out.println("Green = " + color.getGreen());
    System.out.println("Blue  = " + color.getBlue());
    if (inColorRange(color.getRed(), color.getBlue()) && 
        inColorRange(color.getBlue(), color.getGreen())) {
      robot.mousePress(MouseEvent.BUTTON1_MASK);
      robot.mouseRelease(MouseEvent.BUTTON1_MASK);
    }

  }
  public static boolean inColorRange(int color1, int color2) {
    return Math.abs(color2-color1) <= 20;
  }

this is what i have so far it identifies a colour near white and clicks on it but i have to tell the program what coordinates.

user1965081
  • 55
  • 1
  • 2
  • 8

0 Answers0