简体   繁体   English

如何跟踪桌面上的鼠标单击

[英]How to track a click of the mouse on the desktop

How to track a click of the mouse on the desktop outside of any Java components. 如何跟踪任何Java组件外部的桌面上的鼠标单击。 Thank you in advance. 先感谢您。

With pure Java this is maybe not possible but you can use external libraries which are based on Java Native Interface ( https://en.wikipedia.org/wiki/Java_Native_Interface)for comunicating with your application. 使用纯Java,这也许是不可能的,但是您可以使用基于Java Native Interfacehttps://en.wikipedia.org/wiki/Java_Native_Interface)的外部库与应用程序通信。

You can do that using JNativeHook .About the framework Swing or JavaFX it is your choice. 您可以使用JNativeHook做到这一点。关于框架SwingJavaFX这是您的选择。

Link: 链接:

( https://github.com/kwhat/jnativehook ) https://github.com/kwhat/jnativehook


Demo: 演示:

( https://github.com/kwhat/jnativehook/blob/master/src/java/org/jnativehook/example/NativeHookDemo.java ) https://github.com/kwhat/jnativehook/blob/master/src/java/org/jnativehook/example/NativeHookDemo.java

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

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