Issue:
I have a WPF fullscreen application, which acts as a dashboard. The computer is in domain and domain policies enforce the computer to be locked in 10 minutes after the last user activity. I want to prevent the workstation (or desktop) from locking automatically.
An example of such behavior: Windows Media Player, which prevents this while a movie is running.
Known solutions (kinda workarounds):
- It is possible to send a Win32 Mouse Move event every fixed interval of time (for example, every minute)
- It is possible to send a key to the program (for example "Left Shift" key up) every fixed interval of time (for example, every minute)
QUESTION:
How can I prevent windows workstation from locking without using these workarounds?
Disclaimer:
I was pretty sure, there should be a similar question answered somewhere on StackOverflow, but i didn't find any. I would appreciate, if you could point me into the right direction.
Best Answer
The solution has been pointed out through the comments, but I'm providing a simple starter solution for anyone else arriving via a web search:
An alternative place to put the logic would be within an event handler for
StateChanged
on your main application window: