电源设置关闭后,如何唤醒Windows显示器? [英] How do I wake up my Windows monitors once turned off by power settings?

查看:382
本文介绍了电源设置关闭后,如何唤醒Windows显示器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我的Vista机器设置为在10分钟后关闭其显示器. (注意:机器未挂起或处于休眠状态)

So my Vista machine is set to turn off it's monitors after 10 minutes. (Note : machine is not suspended, or hibernated)

我正在运行一个.Net应用程序,需要在指定时间唤醒"系统.作为人类,您只需移动鼠标或按任意键.如何以编程方式执行此操作?

I have a .Net application running, that needs to "wake" the system at a specified time. As a human, you just move the mouse or press a key. How do I do this programatically?

我尝试过:以编程方式设置光标;使用"SendKeys";甚至将CreateWaitableTimer设置为取消暂停(即使它没有被暂停),希望这会触发某些事情.

I've tried : programatically setting the cursor; using "SendKeys"; and even pinvoking CreateWaitableTimer to unsuspend (even though it's not suspended) in the hope that that would trigger something.

理想的c#代码会很棒,但是正确的Win API就足够了.

Ideally code in c# would be great, but the correct Win API would suffice.

非常感谢.

推荐答案

您应该能够通过发送系统命令消息来控制监视器电源,如下所示.请注意,这已经在XP上进行了测试,Vista可能会有所改变,因此您需要对其进行测试并告知我们.

You should be able to control monitor power by sending system command messages as follows. Note that this is tested on XP, Vista may have changed things somewhat so you'll need to test it and let us know.

此代码在VB中,但是您可以看到它使用的Win32 API调用.您需要将窗口句柄传递给该函数,以便您的代码将需要创建一个窗口来处理消息(只需将其传递给默认的窗口处理函数即可).

This code is in VB but you can see the Win32 API call that it uses. You need to pass a window handle to the function so your code will need a window created to process the message (just pass it through to the default window processing function).

Const SC_MONITORPOWER As Integer = &HF170
Const WM_SYSCOMMAND As Short = &H112S
Private Function SendMessage(
    ByVal Handle As Int32,
    ByVal wMsg As Int32,
    ByVal wParam As Int32,
    ByVal lParam As Int32) As Int32
End Function
Sub MonStandBy(hWnd as Int32)
    SendMessage(hWnd, WM_SYSCOMMAND, SC_MONITORPOWER, 1)
End Sub
Sub MonOff(hWnd as Int32)
    SendMessage(hWnd, WM_SYSCOMMAND, SC_MONITORPOWER, 2)
End Sub
Sub MonOn(hWnd as Int32)
    SendMessage(hWnd, WM_SYSCOMMAND, SC_MONITORPOWER, -1)
End Sub

这篇关于电源设置关闭后,如何唤醒Windows显示器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆