简体   繁体   English

如何在空闲计时器关闭后使用.NET重新打开显示器?

[英]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: 我在Windows 7中有电源选项设置为:
Turn off monitor after: 1 minute 在1分钟后关闭显示器
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 这看起来很有希望: http//www.codeproject.com/KB/cs/Monitor_management_guide.aspx

It uses the"SendMessage" API call: 它使用“SendMessage”API调用:

SC_MONITORPOWER Sets the state of the display. SC_MONITORPOWER设置显示的状态。 This command supports devices that have power-saving features, such as a battery-powered personal computer. 此命令支持具有省电功能的设备,例如电池供电的个人计算机。 The lParam parameter can have the following values: lParam参数可以具有以下值:

-1 - the display is powering on -1 - 显示器正在通电

1 - the display is going to low power 1 - 显示器功耗很低

2 - the display is being shut off 2 - 显示屏正在关闭

Do you need to turn it on, or just prevent it from turning off? 你需要打开它,还是只是阻止它关闭? If the latter, you can use the WinAPI: 如果是后者,可以使用WinAPI:

SetThreadExecutionState(ES_DISPLAY_REQUIRED) SetThreadExecutionState(ES_DISPLAY_REQUIRED)

I don't think that there is a .net wrapper built in, but you should be able to pInvoke it. 我不认为内置了一个.net包装器,但你应该能够启动它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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