0

So, basically I've made a stopwatch GUI application which I want to use for tracking time I spend in front of my PC. I want my stopwatch to stop counting when I lock my PC and resume counting when I unlock my PC. How can this be achieved with Java?

Thanks!

vlashel
  • 345
  • 2
  • 15
  • possible duplicate of [Implementing Workstation lock listener using Java](http://stackoverflow.com/questions/25727879/implementing-workstation-lock-listener-using-java) – alex2410 Nov 17 '14 at 08:36

1 Answers1

1

Hava a look at JNA. They provide an example code to listen to Windows events: https://github.com/twall/jna/blob/master/contrib/native_window_msg/src/com/sun/jna/platform/win32/Win32WindowDemo.java

The example code also includes methods like onMachineLocked, onMachineUnlocked which might help you.

cello
  • 5,356
  • 3
  • 23
  • 28