I am trying to write what can best be surmised as a script to click a button on a browser many times without stopping. I can do key presses ad infinitum fine using the java.awt.Robot class but the problem I'm having is coding the correct activator/interruptor; I don't know how to make Java listen to keyboard commands (I want to start/stop when I press F3) without using a listener, which in turn needs to be added to a UI component, if I am not mistaken. How do I do this? Currently I have:
public static void main(String[] args) throws Exception
{
final Robot robot = new Robot();
robot.delay(10000);
while (true)
{
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.delay(1000);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
}
}
I realize it's probably very simple in Jython or Groovy, but I am curios nonetheless.