Manoj
Manoj

Reputation: 3997

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.

Upvotes: 3

Views: 2335

Answers (1)

Duncan Jones
Duncan Jones

Reputation: 69339

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.

Upvotes: 6

Related Questions