Java的awt.Robot:CTRL + ALT + DEL并不带来了所需的屏幕 [英] Java awt.Robot: CTRL+ALT+DEL does not bring up desired screen

查看:462
本文介绍了Java的awt.Robot:CTRL + ALT + DEL并不带来了所需的屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚发现了关于awt.Robot图书馆,我很高兴能来使用它。我想我会玩我的朋友有点恶作剧,并有机器人preSS控制,ALT,删除preSS锁定计算机按钮,但我不能让程序弹出控制ALT删除画面

下面是我的code:

 进口java.awt中的*。
进口java.awt.event.KeyEvent中;
公共类博特{
公共静态无效的主要(字串[] args)
{
    尝试{
        机器人机器人=新的机器人();
        bot.delay(4000);
        bot.key preSS(KeyEvent.VK_CONTROL);
        bot.delay(100);
        bot.key preSS(KeyEvent.VK_ALT);
        bot.delay(100);
        bot.key preSS(KeyEvent.VK_DELETE);
        bot.delay(500);
        bot.keyRelease(KeyEvent.VK_CONTROL);
        bot.keyRelease(KeyEvent.VK_ALT);
        bot.keyRelease(KeyEvent.VK_DELETE);
    }赶上(的AWTException E){
        // TODO自动生成catch块
        e.printStackTrace();
    }}公共静态无效pressEnter(机器人机器人)
{
    bot.key preSS(KeyEvent.VK_ENTER);
    bot.delay(40);
    bot.keyRelease(KeyEvent.VK_ENTER);
}
}


解决方案

这不能在Windows XP环境下进行 1 (+补丁?)起,用模拟的关键事件。

评论这里的老要模拟文章展示如何的使用的才能:


  

有关Vista的安全原因,我们不能播放热键消息,以模拟CTRL + ALT + DEL。
  要做到这一点对VISTA你需要使用一个特殊的图书馆SASLIB默认情况下不...

提供

无论如何,如果你使用Win32(或其他OS)API直接,你可能有机会获得相应的API来执行任务。例如,请参见 LockWorkStation


  

该函数具有相同的结果作为pressing按Ctrl + Alt + Del键,然后单击锁定工作站。


请参阅Is有一个Java库来访问本地Windows API?了解导线上的本机(Windows)中的API是如何被访问。


1 从我假设目标操作的描述为Windows。

I just recently found out about the awt.Robot Library and I'm quite excited to get to use it. I thought I'd play a little prank on my friend and have the robot press control,alt,delete press the lock the computer button but I can't get the program to bring up the control alt delete screen.

Here's 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);
}
}

解决方案

This cannot be done in Windows XP1 (+ patches?) onward with simulated key events.

From a comment here on an old article showing how this used to be able to be simulated:

For secure reasons on Vista we can not broadcast hotkey message to simulate CTRL ALT DEL. To do this on VISTA you need to use a special library "SASLIB" not provided by default...

Anyway, if you use the Win32 (or whatever OS) API directly, you probably have access to the appropriate API to perform a task. For instance, see LockWorkStation:

This function has the same result as pressing Ctrl+Alt+Del and clicking Lock Workstation.

See Is there a Java library to access the native Windows API? for leads on how the native (Windows) API can be accessed.


1 From the description of the operation I'm assuming the target is Windows.

这篇关于Java的awt.Robot:CTRL + ALT + DEL并不带来了所需的屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆