title: Java bot for an online game
body: <p>I am creating a bot in java using the <code>java.awt.Robot</code>. The bot works fine on a browser (I have also tested it using Microsoft Word!) but when I run it in the game, the only function that works is the <code>mouseMove</code>. I want to build a bot that simply presses keyboard buttons for me.</p>
  
  <p>I instantiate the robot class</p>
  
  <pre><code>Robot r = new Robot();
  </code></pre>
  
  <p>Then I do some simple stuff: 
  press z,press 1, move the mouse and right click.</p>
  
  <pre><code>r.keyPress(KeyEvent.VK_Z);
  r.keyRelease(KeyEvent.VK_Z);
  
  r.keyPress(KeyEvent.VK_1);
  System.out.println("Press 1 button");
  r.keyRelease(KeyEvent.VK_1);
  System.out.println("Release 1 button");
  r.delay(1000);
  
  System.out.println("Move mouse");
  r.mouseMove(110, 690);
  
  System.out.println("Press");
  r.mousePress(InputEvent.BUTTON3_MASK);
  System.out.println("Release");
  r.mouseRelease(InputEvent.BUTTON3_MASK);
  </code></pre>
  
  <p>Why is this happening? Can this Robot class perform these kind of actions within a game if it runs in the background?</p>
  
  <p>Thank you</p>
  
  <p><strong>Update</strong>: If I run my bot on PES 2012 for example, it works fine but if I run it on an online game like Cabal, it does not work? the protection system of the game does not detect anything so that is not the case.</p>