tags:

views:

342

answers:

3

I'm writing an application which monitors the person’s mouse and keyboard. If they have not used the keyboard or mouse for 1 minute, it should pops up a message which says “You have not used the mouse or keyboard for 1 minute” and an OK button.

How do I do this in Java?

+2  A: 

If you want to do this for only your application, then its very simple. You can simply add listerns i.e Toolkit.getDefaultToolkit.addAwtEventListener(..).

But for the system as a whole, I am afraid, it cannot be done in java, you may use JNI though.

Suraj Chandran
A: 

if you only want to monitor activity in the the java application windows, its trivial all you have to do is register to the appropriate event. but to monitor all mouse and keyboard activity in the OS you will have to hook to the API which is platform dependent and will require using the GNI

Alon
+2  A: 

You need a bit of C++ code (see this thread) to register a global keylogger with Java. If you can't compile C++ JNI code, then you'll need a third party library like J/Invoke.

Aaron Digulla