The following Java code when run on Windows XP will lock the desktop, however when run on Vista or Windows 7 it doesn't lock the desktop. I'd appreciate it if someone could show me how to get this to work in Vista and Windows 7 using Java only.
import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.KeyEvent;
public class Roboto {
//Lock windows desktop using "WinKey + L"
public static void main(String[] args) {
try {
Robot r = new Robot();
r.keyPress(KeyEvent.VK_WINDOWS);
r.keyPress(KeyEvent.VK_L);
r.keyRelease(KeyEvent.VK_L);
r.keyRelease(KeyEvent.VK_WINDOWS);
} catch (AWTException e) {
e.printStackTrace();
}
}
}