简体   繁体   中英

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.

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM