是否可以使用 WinAPI/C# 让单个显示器进入睡眠状态?
通过使用 Windows API,可以将显示器置于睡眠模式:
[DllImport("user32.dll")]
static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
然后
SendMessage(this.Handle, WM_SYSCOMMAND, (IntPtr)SC_MONITORPOWER, (IntPtr)2);
当运行上述命令时,两个显示器都会进入睡眠状态。是否有可能使其仅影响多个连接的显示器之一?
By using the Windows API it is possible to put the monitors into sleep mode:
[DllImport("user32.dll")]
static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
and then
SendMessage(this.Handle, WM_SYSCOMMAND, (IntPtr)SC_MONITORPOWER, (IntPtr)2);
When running the command above, both monitors go to sleep. Is it possible to make this affect only one of multiple connected monitors?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
确切地说,我不知道您是否可以让特定的显示器进入睡眠状态。但是您可以通过将显示器数量更改为一个(假设您有 2 个)来实现此目的,而您希望将其唤醒。另一个显示器将在大约一分钟后自动进入睡眠状态(大多数显示器在断开连接后大约一分钟后进入省电模式)。您实质上是以编程方式断开显示器的连接。您可以在需要时激活它。
然而,这种方法还会有其他影响,一旦你开始使用它,你就会知道。
Exactly I don't know if you can put into sleep a specific monitor.. but you can achieve this by changing number of displays to One (assuming you have 2), which you want to be awake. The other one will automatically goes to sleep after about a minute (most monitors enter power save mode after about a minute after disconnect). You are essentially disconnecting the monitor, programatically. You can activate it when you need it.
However this method will have other implications, which you will know once you start playing with it.
根据这个...不。
原因是 API 正在关闭定义为两个监视器的显示。关闭特定监视器将是硬件绑定。
According to this...no.
The reason being is that the API is turning off the display which is defined as both monitors. Turning off a specific monitor would be a hardware tie in.