title: Java - Getting a key press to register with another window open
body: <p>I recently created an autoclicker, however it had a very large downside. Once activated, there was no way to make it not click certain things, or stop it without literally hitting the stop button on eclipse.
  <br>
  I was trying to figure out a way to:</p>
  
  <ul>
  <li>Press a key or click a mouse to stop the program(while on another
  window)</li>
  <li>Only click when a certain application has the focus of the screen
  Are any of these possible? </li>
  </ul>