views:

556

answers:

2

How do I turn the monitor back on after the idle timer has turned it off? I have power options in windows 7 set to:
Turn off monitor after: 1 minute
Go to sleep: Never

But I don't know how to turn it back on through code.

A: 

This looks promising: http://www.codeproject.com/KB/cs/Monitor_management_guide.aspx

It uses the"SendMessage" API call:

SC_MONITORPOWER Sets the state of the display. This command supports devices that have power-saving features, such as a battery-powered personal computer. The lParam parameter can have the following values:

-1 - the display is powering on

1 - the display is going to low power

2 - the display is being shut off

David
A: 

Do you need to turn it on, or just prevent it from turning off? If the latter, you can use the WinAPI:

SetThreadExecutionState(ES_DISPLAY_REQUIRED)

I don't think that there is a .net wrapper built in, but you should be able to pInvoke it.

JMarsch