I'm trying to simulate a left click in a different program using awt.robot, with the following code:
int mask = InputEvent.BUTTON1_DOWN_MASK;
bot.mouseMove(x, y);
bot.mousePress(mask);
bot.mouseRelease(mask);
While this is moving the mouse to the correct part of the screen, the other program doesn't seem to be receiving the click. What am I doing wrong?
In certain other programs, this same method produces the click, but in one program, it has no effect.
I have tried Thread.sleep() to wait 30-300 milliseconds between mouseMove and mousePress, but it had no effect.
Do I need to use JNI and native windows API to achieve this? I'm on Windows 8.
解决方案
You are using the wrong mask: InputEvent.BUTTON1_MASK