title: Java Robot class won't interact with an application?
body: <p>I've been reading up on this and haven't found an answer that has made sense to me.</p>
  
  <p>I'm trying to write a program in Java to interact with an application to see if I can write a program to play a video game for me. The game is on my computer.</p>
  
  <p>Here is an excerpt of code:</p>
  
  <pre><code>public static void main(String[] args) throws java.io.IOException {
  
      Runtime run = Runtime.getRuntime();
  
      run.exec("open /Applications/OpenEmu.app");
  
      try {
  
          Robot robot = new Robot();
  
  
          System.out.println("Waiting 5 Seconds");
          //robot.delay(5000);
  
          System.out.println("Pressed X");
          robot.keyPress(KeyEvent.VK_X);
          robot.keyPress(KeyEvent.VK_X);
          robot.keyPress(KeyEvent.VK_X);
          robot.keyPress(KeyEvent.VK_X);
          //Starts an easy mode game
  </code></pre>
  
  <p>It opens the application fine, and in something like notepad, it will type XXXX, but it won't do so for the game?</p>
  
  <p>I've assigned the 'x' key on my keyboard as a command button for the game. My guess is that the 'x' press is internal. All help is appreciated!</p>