Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to determine that a screensaver is running?

One solution that one could suggest is to periodically look for a special 'Screen-saver' desktop, and if it's present then count it as a running screensaver.

But apparently this is not the case for all screensavers as with some the mentioned desktop is always present.

Are there more reliable solutions for this?

like image 745
mblsha Avatar asked Dec 30 '22 05:12

mblsha


2 Answers

See the WINAPI function SystemParametersInfo() with the SPI_GETSCREENSAVERRUNNING parameter. It's the only documented way to detect whether the screen saver is currently running. (You can also find out if a screen saver is even enabled, get and set the timeout value, and start the screen saver using this function.)

like image 82
Ken White Avatar answered Jan 13 '23 14:01

Ken White


I think the key is to identify the screensaver by its window class ("WindowsScreenSaverClass"). I found this page How do I start, detect and stop screen savers? that has some code examples and explanations.

like image 22
f3lix Avatar answered Jan 13 '23 13:01

f3lix