0

我想在我的 java 应用程序运行时锁定我的电脑,所以我使用 Robot 类来实现两个键的组合:windows logo key + L。但它没有用!这是我的代码:

Robot a=new Robot();  
a.keyPress(KeyEvent.VK_WINDOWS);  
a.keyPress(KeyEvent.VK_L);

任何人都可以帮助我吗?

4

1 回答 1

0

You can use this code snippet in your listener class to lock screen in windows machines.

Runtime.getRuntime().exec("rundll32.exe user32.dll, LockWorkStation");
于 2013-03-19T01:01:38.217 回答