Vista and Monitor Power Saving

Blitz3D Forums/Blitz3D Programming/Vista and Monitor Power Saving

Henrik(Posted 2008) [#1]
How can i prevent vista to go in to powersave mode (turn the monitor off) when i play my blitz3d game with a joystick? There is no problem
if i play the game with the keyboard.
Henrik


Henrik(Posted 2008) [#2]
Shouldn't joystick activity prevent "power saving" or wake up the pc/monitor from sleep,like a keyhit or mouse activity/mouse button hit does?
Henrik


Warner(Posted 2008) [#3]
Maybe you could use an API call to fake a keypress every thirty seconds when the game is active ?


Henrik(Posted 2008) [#4]
Good idea, if i only knew how to do that ;)


Warner(Posted 2008) [#5]
I'm not sure if this will work under Vista.
First of all, create a file that is called "user32.decls", and place it in
c:\program files\blitz3d\userlibs
Put these lines in that file:
.lib "user32.dll" 
api_keybd_event%(bVk%, bScan%, dwFlags%, dwExtraInfo%) : "keybd_event"


After that you can use the command api_keybd_event() in your programs.
This code will press the key "A". Note that you should not only press the key, but also release it afterwards.
Repeat

api_keybd_event($41, 0, 0, 0) ;keydown
api_keybd_event($41, 0, 2, 0) ;keyup

Delay 2500

Until KeyHit(1)

End

First open notepad, then start the code, then switch to notepad.
Every 2.5 seconds, it will press the 'A' key.

For more info on keybd_event, look here:
http://msdn.microsoft.com/en-us/library/ms646304(VS.85).aspx


Warner(Posted 2008) [#6]
Wait, I found something else that might work better:
http://www.blitzbasic.com/Community/posts.php?topic=67312


Henrik(Posted 2008) [#7]
I will try that, thanks a lot for your help.
Henrik


Henrik(Posted 2008) [#8]
I use the API call to fake a keypress, and it works great!
Thanks again Warner.

Henrik