是否可以使用 WinAPI/C# 让单个显示器进入睡眠状态?

发布于 2024-10-07 07:12:34 字数 343 浏览 4 评论 0原文

通过使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

羁拥 2024-10-14 07:12:34

确切地说,我不知道您是否可以让特定的显示器进入睡眠状态。但是您可以通过将显示器数量更改为一个(假设您有 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.

一袭白衣梦中忆 2024-10-14 07:12:34

根据这个...不。

原因是 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文