简体   繁体   中英

How to simulate SHIFT+HOME in windows using JAVA Robot

I am using JAVA Robot to simulate keyboard's SHIFT+HOME operation, code is simple:

Robot robot = new Robot();
robot.keyPress(KeyEvent.VK_SHIFT);
robot.keyPress(KeyEvent.VK_HOME);
robot.keyRelease(KeyEvent.VK_HOME);
robot.keyRelease(KeyEvent.VK_SHIFT);

After test, it can simulate shift and home, but no combined effort. How to correct it?

我很确定,没有其他方法可以做到这一点。

Thanks all above, resolved. Add "Toolkit.getDefaultToolkit().setLockingKeyState(KeyEvent.VK_NUM_LOCK, false);" before the actions

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM