vlashel
vlashel

Reputation: 345

How to make Java GUI application listen to Windows lock screen and unlock screen events?

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!

Upvotes: 0

Views: 1809

Answers (1)

cello
cello

Reputation: 5486

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.

Upvotes: 2

Related Questions