Java awt.Robot: CTRL + ALT + DEL does not display the desired screen

I recently learned about the awt.Robot library, and I am very happy to use it. I thought I would play a little joke with my friend and I will have control over the robot, and then press the lock button on the computer, but I can not get the program to open the alt delete control screen.

Here is my code:

import java.awt.*;
import java.awt.event.KeyEvent;
public class Bot {
public static void main(String[] args)
{
    try {
        Robot bot = new Robot();
        bot.delay(4000);
        bot.keyPress(KeyEvent.VK_CONTROL);
        bot.delay(100);
        bot.keyPress(KeyEvent.VK_ALT);
        bot.delay(100);
        bot.keyPress(KeyEvent.VK_DELETE);
        bot.delay(500);
        bot.keyRelease(KeyEvent.VK_CONTROL);
        bot.keyRelease(KeyEvent.VK_ALT);
        bot.keyRelease(KeyEvent.VK_DELETE);
    } catch (AWTException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}

public static void pressEnter(Robot bot)
{
    bot.keyPress(KeyEvent.VK_ENTER);
    bot.delay(40);
    bot.keyRelease(KeyEvent.VK_ENTER);
}
}
+4
source share
2 answers

This cannot be done in Windows XP 1 (+ patches?) In advance with simulated key events.

From a comment here in an old article that shows how this could be modeled:

Vista CTRL ALT DEL. VISTA "SASLIB", ...

, API Win32 ( ) , , , API . , . LockWorkStation:

, Ctrl + Alt + Del " ".

. Java API Windows? , (Windows) API.


1 , Windows.

+5

, Ctrl + Alt + Del , , .

, :

try {

    Runtime.getRuntime().exec("rundll32 user32.dll,LockWorkStation");

} catch (IOException ex) {
    Logger.getLogger(TimeFrame.class.getName()).log(Level.SEVERE, null, ex);
}
0

All Articles