I have a simple script written with r.keypress:
import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.KeyEvent;
public class robot {
public static void main(String[] args) throws AWTException, InterruptedException {
// TODO Auto-generated method stub
Robot r = new Robot();
r.keyPress(KeyEvent.VK_H);
r.keyPress(KeyEvent.VK_A);
r.keyPress(KeyEvent.VK_P);
r.keyPress(KeyEvent.VK_P);
r.keyPress(KeyEvent.VK_Y);
r.keyPress(KeyEvent.VK_SPACE);
r.keyPress(KeyEvent.VK_B);
r.keyPress(KeyEvent.VK_I);
r.keyPress(KeyEvent.VK_R);
r.keyPress(KeyEvent.VK_T);
r.keyPress(KeyEvent.VK_H);
r.keyPress(KeyEvent.VK_D);
r.keyPress(KeyEvent.VK_A);
r.keyPress(KeyEvent.VK_Y);
}
}
The issues are twofold. Firstly, it won't output double characters, and keyrelease just throws unhandled exceptions. I don't know why it wouldn't work, but KeyRelease works now as
r.keyRelease(KeyEvent.VK_SPACE);
Secondly, I want to use this to output a series of numbers, i.e, 1, 2, 3, etc all the way to 1000000. Is this possible with keypress, and if not, what's the alternative to still use it wherever my cursor is?