SendMessage/SC_MONITORPOWER won't turn monitor ON when running Windows 8

前端 未结 4 1124
死守一世寂寞
死守一世寂寞 2020-12-03 14:22

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,          


        
4条回答
  •  暖寄归人
    2020-12-03 14:54

    I have found out this trick to work on windows 8.1

    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)1);
    

    According to MSN, "1" is to switch monitor to "Low Power" but it does the trick. The screen will not turn off anymore.

提交回复
热议问题