Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect that a PC has been idle for 30 seconds using Java?

Tags:

java

How to detect that a PC has been idle for 30 seconds using Java?

EDITED

With idle I mean that there are no user activity. The user does nothing in 30 seconds. I wold like to do an apllication like Windows, that detects that the user does nothing and enter in stad-by.

like image 738
rpf Avatar asked Mar 05 '09 10:03

rpf


2 Answers

I've come across this excellent example of detecting system wide idle time using JNA. Java Native Access (JNA) is a library that provides access to Java Native Interface (JNI) without the need for you to actually write native code.

Here's the example that is very close to what you're asking for.

like image 188
sudorandom Avatar answered Nov 16 '22 02:11

sudorandom


Not possible as requested, but you can create workarounds using the java.lang.management API. A JNI implementation can also be found on javaworld.

like image 35
soulmerge Avatar answered Nov 16 '22 03:11

soulmerge