本文介绍了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环境下进行(+补丁?)起,用模拟的关键事件。

从的老要模拟文章展示如何的使用的才能:

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:

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


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

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

09-05 12:32
查看更多