Last active
November 29, 2017 15:21
-
-
Save rubyu/9167e2b52ab8033414fd70357079070e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe DisplayStandBy.cs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Runtime.InteropServices; | |
namespace Monitor | |
{ | |
class Power | |
{ | |
const int HWND_BROADCAST = 0xffff; | |
const int WM_SYSCOMMAND = 0x0112; | |
const int SC_MONITORPOWER = 0xF170; | |
[DllImport("user32.dll")] | |
public static extern bool PostMessage(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam); | |
static void Main() | |
{ | |
System.Threading.Thread.Sleep(1000); | |
PowerOff(); | |
} | |
static void PowerOff() | |
{ | |
PostMessage((IntPtr)HWND_BROADCAST, WM_SYSCOMMAND, new IntPtr(SC_MONITORPOWER), new IntPtr(2)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment