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

后端 未结 4 1981
小蘑菇
小蘑菇 2020-12-31 16:34

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

4条回答
  •  隐瞒了意图╮
    2020-12-31 17:00

    Not easy to do have a look at OperatingSystemMXBean method getSystemLoadAverage() only available since java 6 you could keep a track of it and if it is the same for a while determine the pc is idle.

    This assumes idle in terms of idle CPU

    OperatingSystemMXBean operatingSystemMxBean = ManagementFactory.getOperatingSystemMXBean();

提交回复
热议问题