Skip to content

Instantly share code, notes, and snippets.

@rubyu rubyu/Compile.bat
Last active Nov 29, 2017

Embed
What would you like to do?
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe DisplayStandBy.cs
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
You can’t perform that action at this time.