title: How to simulate a real mouse click using java?
body: <p>I'm attempting to perform a mouse click in Java, to click something in an external program. To do this, I'm using <code>java.awt.robot</code>, and the following code:</p>
  
  <pre><code>Robot bot = new Robot();
  int mask = InputEvent.MOUSE_BUTTON1_DOWN;
  bot.mouseMove(x, y);           
  bot.mousePress(mask);     
  bot.mouseRelease(mask);
  </code></pre>
  
  <p>Here's the problem. The external program is able to detect that this click is computer-generated and not human-generated, and hence, its rejecting this click.</p>
  
  <p>I have already tried moving the mouse there naturally and that didn't have any effect. So my guess is, that it must be listening to the keyboard state or such, and telling from that, that the click is computer generated.</p>
  
  <p>What do I have to do to set all keyboard / mouse states to act in the same way as a normal mouse click would?</p>