How to disable screensaver on Windows 7?

I use SDL 1.2.14 on windows 7,
I try add SDL_VIDEO_DISABLE_SCREENSAVER* but it didn’t work.*
Screensaver still started.
Does anyone have idea about this?

WS Liu

The source code comments in SDL_dibevents.c say:
/* Note that this doesn’t stop anything on Vista if the screensaver
has a password. */
so maybe that is your problem. Also, the WM_SYSCOMMAND method does not
seem to applicable for screensavers that use DirectX or OpenGL.

You could implement custom code based on this example:
and it looks like Windows7 handles it just fine as per spec:
but note that SPI_GETSCREENSAVEACTIVE is broken and needs extra code:

Another solution would be to use SPI_SETBLOCKSENDINPUTRESETS to enable a
programatic reset of the screensaver by sending dummy mouse events via
SendInput() repeatedly in your game-loop.

Hope that helps,
–AndreasOn 10/29/10 12:14 AM, psboy wrote:

I use SDL 1.2.14 on windows 7,
I try add /SDL_VIDEO_DISABLE_SCREENSAVER//but it didn’t work./
/Screensaver still started./
/Does anyone have idea about this?/


WS Liu

SDL mailing list
SDL at