How do I wake up my Windows monitors once turned off by power settings?

社会主义新天地 提交于 2019-11-29 08:16:55

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.

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
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!