Any way to stop screensaver

BlitzMax Forums/BlitzMax Programming/Any way to stop screensaver

TartanTangerine (was Indiepath)(Posted 2005) [#1]
When running in Window mode and using a Gamepad the computer does not see any activity and keeps on putting the screen saver on throughout the game.

Is there a way to make windows think that there is activty when using a gamepad/joystick and thus preventing the saver working.


netmaestro(Posted 2005) [#2]
Hi, Tim, pleased to meet you. Have a look at a piece of Delphi code I use for the purpose. It is a call to the win32 api, which you can do from Blitzmax also. It's OK if you aren't a Delphi programmer, the api call is the main thing:

function ToggleSaverActive(z:double):double; cdecl;
begin
if z=1 then
SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, 1, nil, SPIF_SENDWININICHANGE)
else
SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, 0, nil, SPIF_SENDWININICHANGE);
Result := 0;
end;

This would be the right way to do it. Tricking Windows by simulating activity would be the long way around.


TartanTangerine (was Indiepath)(Posted 2005) [#3]
How do I call the win32 api in bMax?


netmaestro(Posted 2005) [#4]
I can't help you much there as I'm new to Bmax programming myself, but check the topic on this page entitled "Screensaver Preview Framework" posted by Eikon, he does it a few times in that code example. Good luck!


TartanTangerine (was Indiepath)(Posted 2005) [#5]
ah ha fantastic.


TartanTangerine (was Indiepath)(Posted 2005) [#6]
Okay Got it. This will turn it off.

Import "-luser32"

Extern "win32"
	Function SystemParametersInfoW(stuff1:Int,Stuff2:Int,Stuff3:Int,Stuff4:Int) = "SystemParametersInfoW@16"
EndExtern
Const SPI_SETSCREENSAVEACTIVE	:Int = 17
Const SPIF_SENDWININICHANGE	:Int = 2
SystemParametersInfoW(SPI_SETSCREENSAVEACTIVE, 0, Null, SPIF_SENDWININICHANGE)



netmaestro(Posted 2005) [#7]
Good job, Tim! A tiny shove in the right direction and you're off and running.