Programming guides for beginner...
Any comments are welcomed....
I hope it helps!!! Thanks for drop by...
Powered By Blogger

Tuesday, September 7, 2010

Window shot-cut keys using visual basic 2008

This is coding for window shot-cut keys application. This application include shot-cut to calculator, notepad, command prompt, task manager, shutdown, restart, and log off.
the coding are provided following.
"
Public Class Form1
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
If CheckBox1.Checked = True Then
Me.TopMost = True
Else
Me.TopMost = False
End If
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Shell("Calc")
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Shell("Notepad")
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
SendKeys.Send("^+{esc}")
End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Shell("cmd")
End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
MsgBox("Loging off computer in " & TextBox1.Text & " seconds.", MsgBoxStyle.Information)
TextBox1.ReadOnly = True
Timer1.Start()
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
MsgBox("Restarting computer in " & TextBox1.Text & " seconds.", MsgBoxStyle.Information)
TextBox1.ReadOnly = True
Timer2.Start()
End Sub

Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
MsgBox("Shuting down computer in " & TextBox1.Text & " seconds.", MsgBoxStyle.Information)
TextBox1.ReadOnly = True
Timer3.Start()
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Button5.Enabled = False
Button6.Enabled = False
Button7.Enabled = False
Button8.Enabled = True
Try
If TextBox1.Text = "0" Then
Button9.Enabled = True
If CheckBox2.Checked = True Then
Timer1.Stop()
Shell("Shutdown -l -f -t 00")
Else
Timer1.Stop()
Shell("Shutdown -l -t 00")
End If
ElseIf TextBox1.Text = Nothing Then
Button9.Enabled = True
If CheckBox2.Checked = True Then
Timer1.Stop()
Shell("Shutdown -l -f -t 00")
Else
Timer1.Stop()
Shell("Shutdown -l -t 00")
End If
Else
TextBox1.Text = TextBox1.Text - 1
End If
Catch ex As Exception
Button5.Enabled = True
Button6.Enabled = True
Button7.Enabled = True
Button8.Enabled = False
TextBox1.ReadOnly = False
Timer1.Stop()
MsgBox("Error, please insert only integer", MsgBoxStyle.Critical)
End Try
End Sub

Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
Button5.Enabled = False
Button6.Enabled = False
Button7.Enabled = False
Button8.Enabled = True
Try
If TextBox1.Text = "0" Then
Button9.Enabled = True
If CheckBox2.Checked = True Then
Timer2.Stop()
Shell("Shutdown -r -f -t 00")
Else
Timer2.Stop()
Shell("Shutdown -r -t 00")
End If
ElseIf TextBox1.Text = Nothing Then
Button9.Enabled = True
If CheckBox2.Checked = True Then
Timer2.Stop()
Shell("Shutdown -r -f")
Else
Timer2.Stop()
Shell("Shutdown -r")
End If
Else
TextBox1.Text = TextBox1.Text - 1
End If
Catch ex As Exception
Button5.Enabled = True
Button6.Enabled = True
Button7.Enabled = True
Button8.Enabled = False
TextBox1.ReadOnly = False
Timer2.Stop()
MsgBox("Error, please insert only integer", MsgBoxStyle.Critical)
End Try
End Sub

Private Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick
Button5.Enabled = False
Button6.Enabled = False
Button7.Enabled = False
Button8.Enabled = True
Try
If TextBox1.Text = "0" Then
Button9.Enabled = True
If CheckBox2.Checked = True Then
Timer3.Stop()
Shell("Shutdown -s -f -t 00")
Else
Timer3.Stop()
Shell("Shutdown -s -t 00")
End If
ElseIf TextBox1.Text = Nothing Then
Button9.Enabled = True
If CheckBox2.Checked = True Then
Timer3.Stop()
Shell("Shutdown -s -f")
Else
Timer3.Stop()
Shell("Shutdown -s")
End If
Else
TextBox1.Text = TextBox1.Text - 1
End If
Catch ex As Exception
Button5.Enabled = True
Button6.Enabled = True
Button7.Enabled = True
Button8.Enabled = False
TextBox1.ReadOnly = False
Timer3.Stop()
MsgBox("Error, please insert only integer", MsgBoxStyle.Critical)
End Try
End Sub

Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
Timer1.Stop()
Timer2.Stop()
Timer3.Stop()
Button8.Enabled = False
Button5.Enabled = True
Button6.Enabled = True
Button7.Enabled = True
Button9.Enabled = False
TextBox1.ReadOnly = False
MsgBox("Process cancel")
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Button8.Enabled = False
Button9.Enabled = False
End Sub

Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
Shell("shutdown -a")
Button5.Enabled = True
Button6.Enabled = True
Button7.Enabled = True
Button8.Enabled = False
Button9.Enabled = False
TextBox1.ReadOnly = False
End Sub
End Class

"
Video will be uploaded soon in youtube.
please refer to this link: http://www.youtube.com/user/tohcw90


To download the file go to following link.
please inform me if the link had expired.

Password: tutorialoflife

For more details, please leave comments.

No comments:

Post a Comment