Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Listening to system mouse clicks from Java

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.

like image 264
Manoj Avatar asked Jun 26 '26 08:06

Manoj


1 Answers

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.

like image 101
Duncan Jones Avatar answered Jun 28 '26 20:06

Duncan Jones



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!