I am writing a desktop application in which I want to perform an operation if user doesn't use the computer for X number of minutes. Just like auto idle in MSN messager or skype. Any hints?
Asked
Active
Viewed 6,079 times
4
-
*"if user doesn't use the computer for X number of minutes."* The computer or the application? The latter is what MSN & Skype do, and it is much easier than monitoring the entire computer, beside being more the apps. business (to know). – Andrew Thompson Jan 18 '12 at 13:12
-
2I am talking about the computer input and I think MSN and skype detects computer input rather than application input. – qasimzee Jan 18 '12 at 13:18
3 Answers
4
I found https://code.google.com/p/fiat-lux/source/browse/Fiat+Lux/src/fiatlux/os/time/ that served my purpose.
Thanks

Răzvan Flavius Panda
- 21,730
- 17
- 111
- 169

qasimzee
- 640
- 1
- 12
- 30
-
This time code looks like it's actually from the jppf project originally. The gradle artifact that contains this code is at 'org.jppf:jppf-node:5.1.1' and you can find the source from the same http://grepcode.com/file/repo1.maven.org/maven2/org.jppf/jppf-node/5.0/org/jppf/node/idle/IdleTimeDetectorFactoryImpl.java?av=f It's worth noting that the JPPF code is under Apache 2.0 and the Fiat-Lux code linked above is under GPL, although possibly incorrectly so. – juckele Dec 15 '15 at 18:17
3
you need to:
- listen for events at the application level
- track the time interval between these events
read here this article. you have the code under InactivityListener.java
And there is even a similar thread: How to detect inactivity/idle time since last keypressed on j2me

Community
- 1
- 1

CloudyMarble
- 36,908
- 70
- 97
- 130
-
Consider changing "track the time interval" (sounds like a report), to "have a thread that periodically wakes up and checks for absence of events" – Bohemian Jan 20 '12 at 07:42
2
You can use a background thread that basically only sleeps idle or a quartz task if you are not already using any timer/job scheduler library.

Fernando Miguélez
- 11,196
- 6
- 36
- 54
-
Isn't this restricted to your application, in contrast to foreign applications, running on the machine? – user unknown Jan 18 '12 at 16:08