听Java中的系统鼠标点击 [英] Listening to system mouse clicks from Java

查看:113
本文介绍了听Java中的系统鼠标点击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的主要目标是计算特定应用程序的鼠标点击次数。

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

想象一下,我已在PC上打开了Microsoft Word和Web浏览器。我的Java代码应该告诉我多少次点击Word和Web浏览器。我需要应用程序名称和点击次数。

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.

我该怎么做?任何解决方案都必须适用于MAC,Linux和Windows。

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

推荐答案

您可以尝试使用jnativehook等库: http://code.google.com/p/jnativehook/ 。查看他们的示例在此页面上

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

此库使用本机功能来提供对纯Java无法实现的鼠标事件的访问。它似乎支持Mac,Linux和Windows。

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.

这篇关于听Java中的系统鼠标点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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