我试图弄清楚为什么我会得到这个异常。
Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Invalid combination of button flags
代码很简单。我正在使用一个名为 Robot 的机器人类。我正在努力做到这一点,以便机器人每 1 秒左击一次作为测试。但是,我无法让它识别鼠标左键。
public void click() {
try {
robot = new Robot();
robot.setAutoDelay(1000);
robot.mousePress(MouseEvent.BUTTON1);
robot.mouseRelease(MouseEvent.BUTTON1);
} catch (AWTException e) {
e.printStackTrace();
}
}
我已经阅读了一些 StackOverflow 问题,他们建议使用该getButtonMask()
函数,但我的库不包含该函数。