The trouble I'm having is with using...
[DllImport("user32")]
public static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
...and then...
SendMessage(???, WM_SYSCOMMAND, (IntPtr)SC_MONITORPOWER, (IntPtr)MONITOR_OFF);
SendMessage wants the Form's Handle but I'm not using Forms so cannot get the Handle.
Is there any other way I can put the monitor to sleep OR get the Handle in WPF?
To get the Handle for a WPF Window use:
new WindowInteropHelper(YourWPFWindow).Handle
MSDN reference
Write new WindowInteropHelper(someWindow).Handle
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With