Wednesday, November 11, 2009

Auto Shutdown

An Useful Software for all broadband subscriber. Just start your download, Schedule the shut down time, and go to sleep, your computer will shut down automatically at the scheduled time. I just made it few days ago, I'm posting the download link also giving the source code, I will update the software soon with more features, stay in touch..

Required : .Net Framework 2.0 (Which you all supposed to have if you are using Windows XP or later Versions)


Public Class FormMain
    Private ShutDownTime As DateTime

    Private Sub CloseToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CloseToolStripMenuItem.Click
        Me.Close()
    End Sub

    Private Sub AboutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AboutToolStripMenuItem.Click
        About_Box.ShowDialog()
    End Sub

    Private Sub Form_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.ToolStripStatusLabelTime.Text = TimeOfDay.ToLongTimeString
        Me.DateTimePicker1.Value = Now
        Me.LabelStatus.Visible = False
        Me.TimerCheckMinimize.Enabled = True
    End Sub

    Private Sub TimerLabelTime_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles TimerLabelTime.Tick
        Me.ToolStripStatusLabelTime.Text = TimeOfDay.ToLongTimeString
    End Sub

    Private Sub Button_Set_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_Set.Click
        If Me.DateTimePicker1.Value <= Now Then
            Me.ShutDownTime = Me.DateTimePicker1.Value.AddDays(1)
        Else
            Me.ShutDownTime = Me.DateTimePicker1.Value
        End If
        Me.TimerShutDown.Enabled = True
        Me.LabelStatus.Text = "The Computer will Shut Down at " & Me.DateTimePicker1.Value.ToLongTimeString
        Me.LabelStatus.ForeColor = Color.Green
        Me.LabelStatus.Visible = True
    End Sub

    Private Sub Button_Reset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_Reset.Click
        Me.LabelStatus.Text = "Select a Time and set the Timer"
        Me.LabelStatus.ForeColor = Color.Red
        Me.LabelStatus.Visible = True
        Me.TimerShutDown.Enabled = False
    End Sub

    Private Sub TimerShutDown_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles TimerShutDown.Tick
        If Now >= ShutDownTime Then
            System.Diagnostics.Process.Start("shutdown", "-s -t 00")
            Me.TimerShutDown.Enabled = False
        End If
    End Sub

    Private Sub NotifyIcon1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles NotifyIcon1.Click, NotifyIcon1.BalloonTipClicked
        If Me.WindowState = FormWindowState.Minimized Then
            Me.Show()
            Me.WindowState = FormWindowState.Normal
            Me.TimerCheckMinimize.Enabled = True
            Me.TimerLabelTime.Enabled = True
        End If
    End Sub

    Private Sub TimerCheckMinimize_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles TimerCheckMinimize.Tick
        If Me.WindowState = FormWindowState.Minimized Then
            Me.Hide()
            Me.NotifyIcon1.ShowBalloonTip(2000)
            Me.TimerCheckMinimize.Enabled = False
            Me.TimerLabelTime.Enabled = False
        End If
    End Sub
End Class


This is the main code...

No comments:

Post a Comment

Send Free SMS