无法在Java中使用机器人按Window + L. [英] Cannot press Window+L using robot in Java
本文介绍了无法在Java中使用机器人按Window + L.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Robot类来模拟Java中的按键。但我无法按Window键+ L虽然我能够单独按下它们。这是我的代码:
I am using the Robot class to simulate key press in Java. But i am unable to press Window key+L although i am able to press them individually. Here is my code:
private void pressKey()
{
Robot r=new Robot();
robot.keyPress(KeyEvent.VK_WINDOWS);
robot.keyPress(KeyEvent.VK_L);
robot.keyRelease(KeyEvent.VK_WINDOWS);
robot.keyRelease(KeyEvent.VK_L);
}
推荐答案
试试这个:
Runtime.getRuntime().exec("rundll32 user32.dll,LockWorkStation");
这篇关于无法在Java中使用机器人按Window + L.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文