Search code examples
c#screensaver

Detect inactivity and cancel screensaver


I am making a WPF C# program. For the next stage I want to create a message that appears on the screen after half an hour of inactivity. I define inactivity as no mouse movements and no keys pressed. I have two questions for this

1) How would I trigger the message to show after half an hour of inactivity?

2) How would I cancel the windows screensaver if it is running?

So far I have looked at:

You will see that frustrating most results point to creating a windows/linux screensaver rather than helping with my goal which is creating code that triggers from inactivity like the windows screensaver does.


Solution

  • Try looking at this article on code project.

    The trick was to search for "System Idle" instead of "Screen Saver Effect".

    (Credit to Darin Dimitrov's answer)