Java的机器人无法控制全键盘 [英] Java robot cannot control the whole keyboard

查看:646
本文介绍了Java的机器人无法控制全键盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让一种键盘控制器类,但java的机器人似乎无法conrol全键盘。

I tried to make a sort of keyboard controller class but the java robot seems to be unable to conrol the whole keyboard.

我试过

robot.keyPress(i);
Thread.currentThread().sleep(50);
robot.keyRelease(i);

从0到255,这关键是从来没有pressed(所有AZERTY键盘上的这个键是present)。

from 0 to 255 and this key is never pressed (this key is present on all azerty keyboard).

任何想法,为什么?
谢谢你。

Any idea why? Thanks.

PS:你不需要preSS CTRL或ALT才能使用此键,产生这样的:²

Ps : you don't need to press CTRL or ALT in order to use this key, it produce this : "²"

推荐答案

您可以尝试创建一个新的窗口,并把它捕获并打印出key codeS的键pressed。然后运行它,preSS问题的关键。那么它应该打印键code 吧:

You could try creating a new window, and have it capture and print out the key codes for the keys pressed. Then run it and press the key in question. it should then print the KeyCode for it:

public static void main(String[] args) {
    JFrame frame= new JFrame();
    frame.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
            System.out.println(e.getExtendedKeyCode());
        }            
    });
    frame.setBounds(0, 0, 100, 50);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
}

这样用虚拟键盘给我的 16777394

看<一个href=\"http://docs.oracle.com/javase/7/docs/api/constant-values.html#java.awt.event.KeyEvent.CHAR_UNDEFINED\" rel=\"nofollow\">http://docs.oracle.com/javase/7/docs/api/constant-values.html#java.awt.event.KeyEvent.CHAR_UNDEFINED对于所有的重点code'的值

see http://docs.oracle.com/javase/7/docs/api/constant-values.html#java.awt.event.KeyEvent.CHAR_UNDEFINED for all the 'KeyCode' values

这篇关于Java的机器人无法控制全键盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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