Sometimes I watch The Notebook before the TV, and I will only be able to touch the TV. It takes too long to automatically close the screen, I don't want to shut down the power source because I want to trigger the mouse, so I went to Google to find the related program. I wanted to use vbs, but vbs couldn't call win api, I had to switch to C #. This is my generation. on my computer, I can make sure that I can enter the power-saving mode.
class Program
{
const int MONITOR_ON = -1;
const int MONITOR_OFF = 2;
const int WM_SYSCOMMAND = 0x0112;
const int SC_MONITORPOWER = 0xF170;
[DllImport("user32.dll")]
static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll")]
static extern bool SendMessage(IntPtr hWnd, UInt32 Msg, int wParam, int lParam);
static void Main(string[] args)
{
Intptr hwnd = findwindow (null, null); // find the root window Handler
Sendmessage (hwnd, wm_syscommand, SC _monitorpower, monitor_off); // sends the closing alert message
}
}
Attaches the EXE extension, if you want to use it.
Lower limit