PatTech
PatTech

Reputation: 397

How to use .NET to Turn the Monitor back on after the Idle Timer has Turned it Off?

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.

Upvotes: 3

Views: 2504

Answers (2)

JMarsch
JMarsch

Reputation: 21771

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.

Upvotes: 0

David
David

Reputation: 34573

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

Upvotes: 1

Related Questions