title: Robot class - Java
body: <pre><code>import java.awt.*;
  import java.awt.event.InputEvent;
  import java.awt.image.BufferedImage;
  
  public final class test
  {
      private static Robot robot;
      public static boolean clickStatus;
  
      public static void leftClick (int R, int G, int B)
      {
              Color myColorToMatch = new Color (R, G, B);
              BufferedImage image = robot.createScreenCapture (new Rectangle (Toolkit.getDefaultToolkit ().getScreenSize ()));
              int w = image.getWidth (null);
              int h = image.getHeight (null);
              int[] rgbs = new int[w*h];
              image.getRGB (0, 0, w, h, rgbs, 0, w);
              for (int y=0; y&lt;h; y++) {
                  for (int x=0; x&lt;w; x++) {
                        if (new Color (image.getRGB (x, y)).equals (myColorToMatch))
                                 robot.mouseMove(x, y);
                                 robot.mousePress (InputEvent.BUTTON1_MASK);
                                 robot.mouseRelease(InputEvent.BUTTON1_MASK);
                                 break;
                      }
                      break;
              }
      }        
  
      public static void main(String[] args)
      {
              try
              {
                      robot = new Robot();
              }
              catch(Exception Error)
              {
                      Error.printStackTrace();
              }             
              // dImp: 130,40,32 - 160,99,57 - 217,135,79
              // banker: 139, 130, 129                
              boolean botLoop = true;
              boolean bankStatus;
  
              while (botLoop == true)
              {
                      robot.delay (1000);
                      leftClick (96,96,98);
              }
      }
  }
  </code></pre>
  
  <p>But there's a problem and I don't know how to fix it. The bot will just Keep clicking every second where ever the mouse is and not go over to/click the desired pixel.
  Could someone please help me with this? I can't find the error</p>