My Java app needs to open an On-Screen-Keyboard app [ osk.exe ], then use Java Robot to move the mouse to the close button position and press the mouse to close the app, but it won't close, yet when I clicked on my mouse, it does close the app, why ? How to use Java Robot to close it ?
Here is my sample code :
try
{
Runtime.getRuntime().exec("cmd.exe /c osk.exe");
Robot robot=new Robot();
robot.delay(100); // Delay to let the application load
robot.mouseMove(1750,880); // Move to On_Screen Keyboard's [ osk.exe ] upper right corner where the close button [ X ] is.
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
}
catch (Exception e) { e.printStackTrace(); }