I have noticed that when I run Windows Media Player on my laptop, that the screen saver will not start and more importantly my computer will not go into sleep or hibernate mode. However, when running iTunes or other applications, unless you move your mouse or hit a key on your keyboard your computer will eventually go into sleep or hibernate mode. I want to write a little application that will prevent my computer from going into sleep or hibernate mode. Does anyone have any ideas on how this could be done?

link|improve this question
See this question - superuser.com/questions/99391/… – BJ292 May 20 at 15:55
feedback

migrated from stackoverflow.com Dec 2 '11 at 15:02

This question came from our site for professional and enthusiast programmers.

9 Answers

For application - you may want to look at win32 function SetThreadExecutionState

Anyway, you could set different power scheme in windows control panel to let computer stay awake all the time.

link|improve this answer
feedback

You've got several events to handle to acheive this. First up, process the WM_SYSCOMMAND message, specifically the SC_SCREENSAVE and SC_MONITORPOWER options. Secondly, handle the WM_POWERBROADCAST message and return BROADCAST_QUERY_DENY.

However, MS decided to allow the BROADCAST_QUERY_DENY to be ignored by the system so it'll only work where it's allowed to work, usually a user setting. Too many applications were preventing power-down that the feature was effectively redundant.

Skizz

link|improve this answer
feedback

Hope this help you out (^^)

Go to "start menu" Click on "All Programs" Click on "Power Options" Click on "Hibernate" Change the settings to "Disable" Hibernate" Click "Apply" Click "OK"

link|improve this answer
feedback

Just go into your power management settings and disable going to sleep or going into hibernate

link|improve this answer
Why the downvote? The OP didnt specify they want to be able to do it from within an application, just that they wanted to do it – MrWiggles Feb 25 '09 at 13:44
2  
"I want to write a little application that will prevent my computer from going into sleep or hibernate mode..." – victor hugo Jun 20 '09 at 1:06
feedback

Have a look at insomnia, which if I understand correctly is exactly the application you want. Note that both binary and source code are available, so if you prefer to roll your own, you can use that as a starting point.

link|improve this answer
exactly what I wanted, thanks – Frank Schwieterman Mar 4 at 4:15
feedback

Write a small program that stores the mouose position, then moves the mouse a little and back again.

link|improve this answer
feedback

There is a small exe program called mouse wiggle you may want to check out.

link|improve this answer
Please provide a link to this application. – John Saunders Feb 3 '10 at 14:20
feedback

Go to START, then type cmd then in the command window type powercfg/hibernate on.

link|improve this answer
feedback
  1. Go to Control panel
  2. Then Power option
  3. Click on "Change When the computer sleep" then page open
  4. Click on then "never"
  5. Click on "save changes" then "ok"
link|improve this answer
feedback

Your Answer

 
or
required, but never shown