Screen on/off is a application Build in C#. Using this one application you can turn off your screen by moving mouse your screen will be on again.
NOTE: Using Laptop you may notice that it’s a bit difficult to turn off monitor only some time you may run out of battery in laptops and still need to complete your download. you can build your own application in c# to just turn off laptop monitor.
Source Code :
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Runtime.InteropServices; namespace Screen_Off { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private const int WmSyscommand = 0x0112; private const int ScMonitorpower = 0xF170; private const int HwndBroadcast = 0xFFFF; private const int ShutOffDisplay = 2; [DllImport("user32.dll")] private static extern void LockWorkStation(); [DllImport("user32.dll", SetLastError = true)] private static extern bool PostMessage(IntPtr hWnd, uintmsg, IntPtr wParam, IntPtr lParam); private static void ScreenOff() { PostMessage((IntPtr)HwndBroadcast, (uint)WmSyscommand, (IntPtr)ScMonitorpower, (IntPtr)ShutOffDisplay); } private void button1_Click(object sender, EventArgs e) { ScreenOff(); } } }
No comments:
Post a Comment