我想要关闭显示器,并在一段时间后将其打开。但是显示器不想打开。我怎么了?
HWND hwnd_monitor = FindWindow(0, 0);
SendMessage(hwnd_monitor, WM_SYSCOMMAND, SC_MONITORPOWER, 2);
Sleep(1000);
SendMessage(hwnd_monitor, WM_SYSCOMMAND, SC_MONITORPOWER, -1);
答案 0 :(得分:-4)
您可以尝试移动鼠标,这将唤醒显示器。 以下是链接中提供的解决方案:http://stackoverflow.com/questions/12572441/sendmessage-sc-monitorpower-wont-turn-monitor-on-when-running-windows-8
[DllImport("user32.dll")]
static extern void mouse_event(Int32 dwFlags, Int32 dx, Int32 dy, Int32 dwData, UIntPtr dwExtraInfo);
private const int MOUSEEVENTF_MOVE = 0x0001;
private void Wake(){
mouse_event(MOUSEEVENTF_MOVE, 0, 1, 0, UIntPtr.Zero);
Sleep(40);
mouse_event(MOUSEEVENTF_MOVE, 0, -1, 0, UIntPtr.Zero);
}