java系统级的键盘和鼠标状态 [英] java system-wide keyboard and mouse state

查看:210
本文介绍了java系统级的键盘和鼠标状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在系统范围内收听鼠标和键盘事件,而不将其从系统队列中取出?

Is there a way to listen to the mouse and keyboard events system-wide without taking these out of system queue?

例如。有没有办法设置一个恶魔,让我们说,哪个会听和报告每个键盘和鼠标事件?

E.g. is there a way to set a demon, let's say, which would listen and report each and every keyboard and mouse event?

推荐答案

不可能使用纯Java。但是您可以使用JNI(Java Native Interface),它正在使用C ++编写的代码和本机编译。所以,这样你可以用C ++编写全局KeyListener,并让Java使用它。

It's not possible using pure Java. But you can use JNI (Java Native Interface), which is working on code written in C++ and natively compiled. So, this way you can write the Global KeyListener in C++ and let make Java use of it.

有一个为Linux,OS X和Windows实现的活动项目: http://code.google.com/p/jnativehook/

There is an active project implementing this for Linux, OS X and Windows: http://code.google.com/p/jnativehook/

这篇关于java系统级的键盘和鼠标状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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