I have a simple Java project that uses Robot to simulate a simple mouse movement as shown below.
while(true){
try {
for(int x=0; x<200; x++){
r.mouseMove(x, 300);
Thread.sleep(10);
}
Thread.sleep(3000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
The code works fine when I run it. The problem is that as soon as I click on this gaming application window, the cursor no longer moves. The whole point of this project is to automate particular mouse movements within a game, but when I click on this game window it appears the Robot class no longer does anything. As soon as I click out of the gaming window, the automated mouse movements continue as normal. Why is the Robot mouse movements not working when I click on this gaming window? Is it a problem with Java Robot? Is there an alternative I can try instead of Robot? Programming automated mouse movements should be possible when this game window is selected since a macro recorder I downloaded is able to simulate mouse movements in the game. Why would the code for this macro recorder be able to move the mouse cursor in the game while the Java code I am writing is not able to move the mouse cursor?