SendMessage函数/ SC_MONITORPOWER无法开启监控运行Windows 8时ON [英] SendMessage/SC_MONITORPOWER won't turn monitor ON when running Windows 8
问题描述
我把我的显示器和关闭使用以下code:
I turn my monitors on and off by using the following code:
[DllImport("user32.dll")]
static extern IntPtr SendMessage(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam);
private const int WM_SYSCOMMAND = 0x0112;
private const int SC_MONITORPOWER = 0xF170;
private const int MonitorTurnOn = -1;
private const int MonitorShutoff = 2;
//Turn them off
SendMessage(f.Handle, WM_SYSCOMMAND, (IntPtr)SC_MONITORPOWER, (IntPtr)MonitorShutoff);
//Turn them on
SendMessage(f.Handle, WM_SYSCOMMAND, (IntPtr)SC_MONITORPOWER, (IntPtr)MonitorTurnOn);
此作为旨在工作,但在安装Windows 8后(我认为这是什么原因,因为我看到别人有同样的问题)上是行不通的打开屏幕。我仍然可以将其关闭,但不管多少次,我跑与MonitorTurnOn SendMessage函数(),我还是要移动鼠标或preSS一键搞定显示器回去。
This used to work as intended, but after installing Windows 8 (I assume this is the reason, since I see others have the same issue) turning the screen on won't work. I can still turn it off, but no matter how many times I run SendMessage() with MonitorTurnOn, I still have to move the mouse or press a key to get the monitors back on.
这是如何使Windows 8的这项工作有什么建议?
Any suggestions on how to make this work on Windows 8?
推荐答案
我有同样的问题,我找到了解决方法是移动鼠标:
I had the same problem, the solution I found is to move the mouse :
mouse_event(MOUSEEVENTF_MOVE, 0, 1, 0, NULL);
Sleep(40);
mouse_event(MOUSEEVENTF_MOVE, 0, -1, 0, NULL);
它会唤醒显示器。
Earlypearl
It will wake the monitor on. Earlypearl
这篇关于SendMessage函数/ SC_MONITORPOWER无法开启监控运行Windows 8时ON的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!