将 KBDLLHOOKSTRUCT(.NET) 转换为 KeyEvent/Char(Java)、JNA
所以,基本上我正在做的是使用 JNA 设置 LowLevelKeyboardProc 键盘钩子,一切都工作得很好,我可以得到与我在 java 中想要的值完全一样的值,但我遇到的问题是当尝试转换为字符时,它处理大写锁、SHIFT 键和大量其他东西(例如键盘上除 az 0-9 之外的所有东西)变得非常烦人,我想知道是否有更简单的方法来进行转换? 这是每次按下键时我从钩子中得到的详细信息 http://msdn.microsoft。 com/en-us/library/windows/desktop/ms644967(v=VS.85).aspx ,我认为最好找到一种手动生成 KeyEvent 的方法(不是字符,因为我需要一些东西来处理 F 键、大写锁定按钮、CTRL 按钮等)。
我能得到的任何帮助都非常感谢!
So, basically what i'm doing is using JNA to set a LowLevelKeyboardProc Keyboard hook, everything works perfectly fine, i can get the values exactly like i want them in java, but the problem i get is when trying to convert to chars, it becomes extremely ennoying handling caps locks, SHIFT keys and tons of other things like everything thats not a-z 0-9 on the keyboard, i was wondering if there is a easier way to do the conversion?
heres the details of what I'm getting from the hook every time a key is pressed
http://msdn.microsoft.com/en-us/library/windows/desktop/ms644967(v=VS.85).aspx
, i Figured it might be best to find a way to manually generate a KeyEvent(Not char, since i need something to handle things like F keys, caps lock button, CTRL button etc etc).
Any help i can get is highly appriciated!.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Abbot 项目 (http://abbot.sf.net) 有一个使用预定义的键盘映射将键码映射到键字符的系统(它生成各种击键并记录结果字符输出)。然而,Java 没有提供一种方法来“预测”给定特定键代码的结果字符输出。
MS 库中可能有一些东西。
The Abbot project (http://abbot.sf.net) has a system for mapping keycodes to keychars, using predefined keyboard mappings (it generates a wide variety of keystrokes and records the resulting character output). However, Java does not provide a way for "predicting" the resulting character output given a particular key code.
There may be something within the MS libraries.