title: Get coordinates of an image
body: <p>I have tested my code before and it seems that it was working perfectly but now my function doesn't find an image coordinates on my Windows screen (return -1,-1).</p>
  
  <p>Does the JDK version make a difference? Or is there a bug in the code below? </p>
  
  <pre><code>public int[] foundImageCoord(String imageName) {
      try {
          // current screen capture
          BufferedImage current = createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));
  
          // image to search
          BufferedImage icon = ImageIO.read(new File(imageName));
  
          // container
          for (int x = 0; x &lt; current.getWidth() - icon.getWidth(); x++) {
              for (int y = 0; y &lt; current.getHeight() - icon.getHeight(); y++) {
  
                  // image moving in the container
                  boolean matches = true;
                  overloop:
                  for (int x2 = 0; x2 &lt; icon.getWidth() ; x2++) {
                      for (int y2 = 0; y2 &lt; icon.getHeight() ; y2++) {
                          if (icon.getRGB(x2, y2) != current.getRGB(x + x2, y + y2)) {
                              matches = false;
                              break overloop;
                          }
  
                      }
  
                  }
                  if (matches) { // image found
                      return new int[] { x, y };
                  }
              }
          }
      } catch (IOException e) {
              e.printStackTrace();
      }
  
      return new int[] { -1, -1 };
  }
  </code></pre>
  
  <p>In my function main : </p>
  
  <pre><code>    WindowsBot bot;
  
      try {
  
          bot = new WindowsBot();
  
      while(true){
  
              int[] iconLocation = bot.foundImageCoord("skype/writeMessage.png");
              System.out.println("x : " + iconLocation[0] + " y : " + iconLocation[1]);
  
              //bot.click(iconLocation);
      }
      } catch (AWTException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
  </code></pre>
  
  <p>Here is the console log :</p>
  
  <pre><code>x : -1 y : -1
  x : -1 y : -1
  x : -1 y : -1
  x : -1 y : -1
  x : -1 y : -1
  </code></pre>