Monitor Utility: Power Saver

An application to turn of your monitor dynamically. You can Turn Off your monitor instantly or by setting the timer manually.

 

For Developers:
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 Monitor_Utility
{
    public partial class frmMain : Form
    {
        int off_time = 1;
        int ticks;

        public frmMain()
        {
            InitializeComponent();
        }

        [DllImport("user32.dll")]
        private static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam);

        private void turnoff()
        {
            int WM_SYSCOMMAND = 0x0112;
            int SC_MONITORPOWER = 0xF170;
            SendMessage(this.Handle.ToInt32(), WM_SYSCOMMAND, SC_MONITORPOWER, 2);
        }

        private void btnTurnOff_Click(object sender, EventArgs e)
        {
            timer1.Stop();
            ticks = 0;
            btnSetTimer.Enabled = true;
            lblTimerStat.Text = "Monitor Turned Off Manually";
            turnoff();
        }

        private void tbTimer_Scroll(object sender, EventArgs e)
        {
            off_time = tbTimer.Value;
            ticks = 0;
            lblStat.Text = off_time + " Minute";
        }

        private void btnSetTimer_Click(object sender, EventArgs e)
        {
            ticks = 0;
            timer1.Start();
            btnSetTimer.Enabled = false;
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            ticks++;
            if (ticks == off_time * 60)
            {
                turnoff();
                timer1.Stop();
                ticks = 0;
                btnSetTimer.Enabled = true;
                lblTimerStat.Text = "Turned Off";
            }
            else
            {
                lblTimerStat.Text = "Monitor will turn off in " + ((off_time * 60) - ticks) + " seconds";
            }
        }

        private void linkWeb_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            System.Diagnostics.Process.Start("http://www.techole.com/");
        }

        private void linkOrkut_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            System.Diagnostics.Process.Start("http://www.orkut.co.in/Main#Community?cmm=99843449");
        }

        private void notifyIcon1_DoubleClick(object sender, EventArgs e)
        {
            if (this.Visible == true)
            {
                this.Visible = false;
            }
            else if (this.Visible == false)
            {
                this.Visible = true;
            }
        }
    }
}

Share this Post:
Digg Google Bookmarks reddit Mixx StumbleUpon Technorati Yahoo! Buzz DesignFloat Delicious BlinkList Furl

No Responses to “Monitor Utility: Power Saver”

Leave a Reply: