我们可以使用Java中的机器人类插入Unicode字符吗? [英] Can we insert Unicode Characters using Robot Class in Java?
问题描述
我正在用Java开发一个实时英语-僧伽罗语Unicode翻译器,我做了翻译部分,但是现在我想将Final输出Unicode字符添加到当前活动的窗口(如Web浏览器)中.通过Java Robot类添加字符 Robot.keyPress(//keyInput)方法.但是有什么办法可以使用java Unicode字符(例如u0200十六进制值)来完成此操作.如果无法用这种方法完成,我必须解决什么解决方案.请有人帮助我吗?
I am developing a Real time English-Sinhala Unicode translator in java.I did the translation part.But now I want to add the Final output Unicode characters to the currently active window (like a web browser).There's a way to add characters via java Robot class with Robot.keyPress(//keyInput) method.But is there any way to do this with java Unicode characters like u0200 hex value.If it can't be done with this way what solutions I have to resolve this.Please anyone help me ?
推荐答案
是的,您可以按照建议虚拟键盘.可用时,Unicode标志符号使按钮标签可用,如此处所示.
Yes, you can simulate key presses using Robot
, as suggested here. No, Robot
can't see what's printed on the user's key caps. You're probably going to have to develop a virtual keyboard. When available, Unicode glyphs make usable button labels, as shown here.
附录:请注意,
Addendum: Note that a KeyEvent
represents a keystroke, while Unicode encodes graphemes represented by glyphs. The mapping depends on the keyboard layout, e.g. Sinhala.
这篇关于我们可以使用Java中的机器人类插入Unicode字符吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!