How to use robot.mousePress(int) and robot.mouseRelease(int)?

I use Robot for grinding in enchanting in Skyrim so in my case you can’t press escape to exit so I use another way to force quit the program:

I put a file on a stick and copy the path into this code:

String emergencyExit="Some path to a file on a stick";
public boolean checkEmergencyExit() {
  try {
    return new File(emergencyExit).exists();
  }
  catch(Exception e) {
    e.printStackTrace();
    return false;
  }
}
void checkExit() {
  if (checkEmergencyExit()) exit();
}

Next I have my sketch use checkExit after every Robot. Should the script do something it isn’t supposed to I insert the stick stopping the program.

This is also useful if the Robot e.g. accidentally minimizes the window or clicks on another window.

3 Likes