enter image description here我要单击“确定”和“取消”按钮。请提出建议。 enter image description here
Robot robot = new Robot();
robot.delay(300);
robot.keyPress(KeyEvent.VK_ENTER); //Release Enter
robot.keyRelease(KeyEvent.VK_ENTER);
答案 0 :(得分:0)
您可以尝试以下操作:-
Robot object=new Robot();
object.keyPress(KeyEvent.VK_ESCAPE);
object.keyRelease(KeyEvent.VK_ESCAPE);
在上面的代码中,“转义” 键用于关闭弹出窗口。
您也可以将其用于单击“取消”按钮:-
object.keyPress(KeyEvent.VK_TAB);
object.keyRelease(KeyEvent.VK_TAB);
object.keyPress(KeyEvent.VK_TAB);
object.keyRelease(KeyEvent.VK_TAB);
object.keyPress(KeyEvent.VK_TAB);
object.keyRelease(KeyEvent.VK_TAB);
// Press Enter
object.keyPress(KeyEvent.VK_ENTER);
// Release Enter
object.keyRelease(KeyEvent.VK_ENTER);
请尝试单击“确定”按钮:-
// Press Down
object.keyPress(KeyEvent.VK_DOWN);
// Press Down
object.keyRelease(KeyEvent.VK_DOWN);
// Press Enter
object.keyPress(KeyEvent.VK_ENTER);
// Release Enter
object.keyRelease(KeyEvent.VK_ENTER);