Listening to system mouse clicks from Java

三世轮回 提交于 2019-12-06 08:01:04

问题


My main aim is to count the number of mouse clicks on a particular application.

Imagine I have opened Microsoft Word and a web browser on my PC. My Java code should tell me how many times I clicked on Word and on the web browser. I need the application name and the number of clicks.

How can I do this? Any solution must work for MAC, Linux and Windows.


回答1:


You could try a library such as jnativehook: http://code.google.com/p/jnativehook/. Check out their examples on this page.

This library uses native functionality to provide access to mouse events that would otherwise be impossible to achieve in pure Java. It appears to support Mac, Linux and Windows.



来源:https://stackoverflow.com/questions/13291161/listening-to-system-mouse-clicks-from-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!