简体   繁体   English

在任何工具上捕获键盘和鼠标事件

[英]Capture Keyboard and mouse event thorugh java library on any tools

I want to capture the keyboard and mouse click event on my window everywhere suppose I have opened browser or opened notepad or some other tools, it should not be effected. 我想在我的窗口上捕捉键盘和鼠标点击事件,假设我已经打开浏览器或打开记事本或其他工具,它不应该受影响。 I know to do one way this with the batch file but I am trying to do this thruogh java libraries. 我知道用批处理文件做一个这样的方法,但我试图做这个thruogh java库。 I tried with AWT and swing but they can only capture within their frame. 我试过AWT和挥杆,但他们只能在他们的框架内捕捉。

Please suggest me approach for captuering keyboard and mouse event through java. 请建议我通过java捕获键盘和鼠标事件的方法。 Any help will be appriciated. 任何帮助都会得到满足。

This is problematic the moment you want to run it on different platforms. 当您想要在不同平台上运行它时,这是有问题的。 For Windows, you would need to use Java Native Interface directly to access dll's, or use ready libraries such as this . 对于Windows,你需要直接使用Java本地接口访问的DLL,或者使用现成的库如这个

These listeners in general are not trivial to implement, but there are some good examples in test sections of linked gitpage. 一般来说,这些监听器实现起来并不容易,但是在链接gitpage的测试部分中有一些很好的例子。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM