用robot类模拟鼠标点击

try {
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    Robot robot = new Robot();
    robot.mouseMove(screenSize.width - 10, 10);
    robot.delay(2000);
    robot.mousePress(InputEvent.BUTTON1_MASK);
    robot.delay(2000);
    robot.mouseRelease(InputEvent.BUTTON1_MASK);

} catch (AWTException e) {
    e.printStackTrace();
}

比较有意思的一段代码。

yava /
in categories tagged with