Saturday, September 21, 2013

Michael C's Custom J.A.R.V.I.S.


Michael C's Custom J.A.R.V.I.S.

               Hello, my name is Michael, as you've already seen from the title. Some time in March 2013 I was trying to find a J.A.R.V.I.S. - like application to go along with my Iron Man themed Rain meter skin. I soon realized there weren't many options out there aside from using Windows Speech Macros so I started to play around with the Windows Speech SDK and over time it turned into this J.A.R.V.I.S. project. I gave a demonstration video on YouTube just to show my creation but then I was getting a ton of requests for tutorials so I put up a few. As time went on I started to learn more and build upon the program. As of today my current tutorials contain some outdated (and let's just admit it, amateur methods). Down below is a provided list of requirements for the program to be able to run, updates/changes, and default commands you need to be aware of.

You can download the program here: http://www.mediafire.com/download/txkiq9aqo39ugo9/JARVIS.rar
You can download the project folder here: http://www.mediafire.com/download/8z6lkkrsb229xk6/CustomizableJarvis.rar (*Note: The project may not have all of the up to date features as the installer)


Requirements:

  • Windows Vista, Windows 7, Windows 8
  • Microphone (Built-in Mics usually don't work well)
  • .NET 4 Framework
  • Windows Speech Recognition set to ENGLISH: Go to Control Panel, Speech Recognition, Advanced Speech Options, and change Language to ENGLISH.


Updates:
  • 9/17/2013
  • You can now check your Gmail account for new emails. The new commands for this feature are: (Check for new emails, Read the email, Open the email, Next email, Previous email, and Clear email list). Jarvis can only read the Sender, Subject, and Summary information. To read the entire email you must say, "Open the email". Each of these new commands can interrupt Jarvis from speaking. Ex: If he is reading a long email you can say, "Next email" and he will immediately move on. This interruption feature will be implemented to all commands soon.
  • 9/14/2013
  • You can change your Music and Video directories by saying "Change Music Directory" or "Change Video Directory", choosing a new directory and it will automatically update your libraries.
  • Saying "Refresh libraries" will reload all files within your music and video directories.
  • You can say "Stop listening" to keep Jarvis from listening and say "Jarvis Come Back Online" to get him to start listening. Or you can Click on the background image to make him start listening.
  • 9/10/2013
  • You can now choose between Celsius and Fahrenheit Temperatures.
  • 9/8/2013
  • You can now refer to songs by their Title and Band Name. Ex: "Play music", (Which song), "I Miss You by Blink-182". Note: If the song has a bad ID3 Tag (most likely pirated music) the program will refer to it by its file name instead.
  • 8/16/2013
  • The play music command supports .mp3, .m4a, and .wav file formats.
  • The play video command supports .mp4, .avi, and .mkv file formats.

  • 8/13/2013
  • Alarm Clock feature - Say "set the alarm", he will ask what time, then say the time. This feature is saved in the settings.
  • 8/11/2013
  • JARVIS loads all mp3/m4a file names in your My Music folder as well as all files in your My Videos folder into his Grammar. This allows you to say, "Play music", he will ask which song, you then say the file name and he will open it. Same goes for videos except you say "Play Video"
  • You no longer have to restart JARVIS to update commands. Just click Add and say Update Commands.
  • JARVIS should check if the grammar's were loaded properly and let you know if there is a missing element in your commands.
  • If JARVIS can't  connect to the Yahoo! Weather API, he will inform you.
--Fixed--
  • 9/14/2013
  • Quicker start up time
  • Jarvis will no longer assume English is the default language so loading problems should be fixed. Although the default commands might not work as well in other languages. (Update coming)
  • Loading media directories and creating non existent text documents
  • 9/10/2013
  • Problems with saving User Info
  • 9/8/2013
  • Alarm clock - minValue cannot be greater than maxValue error
  • 8/16/2013
  • File check validation now implemented to prevent exceptions being thrown such as: ( 'one-of" must contain at least one ' item' element ) Hopefully this fixes the JIT runtime error.
  • 8/11/2013
  • Creating the JARVIS Custom Commands folder and txt files upon start up.

                                                                    Default Commands:

                                                                    • Hello
                                                                    • Hello Jarvis
                                                                    • Goodbye
                                                                    • Goodbye Jarvis
                                                                    • Close Jarvis
                                                                    • Jarvis
                                                                    • Stop talking
                                                                    • What's my name?
                                                                    • What time is it
                                                                    • What day is it
                                                                    • Whats todays date
                                                                    • Whats the date
                                                                    • Hows the weather
                                                                    • Whats the weather like
                                                                    • Whats it like outside
                                                                    • What will tomorrow be like
                                                                    • Whats tomorrows forecast
                                                                    • Whats tomorrow like
                                                                    • Whats the temperature
                                                                    • Whats the temperature outside
                                                                    • Play music
                                                                    • Play video
                                                                    • Switch Window
                                                                    • Close window
                                                                    • Out of the way
                                                                    • Come back
                                                                    • Show default commands
                                                                    • Show shell commands
                                                                    • Show web commands
                                                                    • Show social commands
                                                                    • Show Music Library
                                                                    • Show Video Library
                                                                    • Show Email List
                                                                    • Show listbox
                                                                    • Hide listbox
                                                                    • Shutdown
                                                                    • Log off
                                                                    • Restart
                                                                    • Abort
                                                                    • I want to add custom commands
                                                                    • I want to add a custom command
                                                                    • I want to add a command
                                                                    • Update commands
                                                                    • Set the alarm
                                                                    • What time is the alarm
                                                                    • Clear the alarm
                                                                    • Stop listening
                                                                    • JARVIS Come Back Online
                                                                    • Refresh libraries
                                                                    • Change video directory
                                                                    • Change music directory
                                                                    • Check for new emails
                                                                    • Read the email
                                                                    • Open the email
                                                                    • Next email
                                                                    • Previous email
                                                                    • Clear email list

                                                                    Monday, July 1, 2013

                                                                    JARVIS in C#

                                                                            SpeechRecognitionEngine _recognizer = new SpeechRecognitionEngine();
                                                                            SpeechSynthesizer JARVIS = new SpeechSynthesizer();
                                                                            string QEvent;
                                                                            string ProcWindow;
                                                                            double timer = 10;
                                                                            int count = 1;
                                                                            Random rnd = new Random();
                                                                            public Form1()
                                                                            {
                                                                                InitializeComponent();
                                                                            }

                                                                            private void Form1_Load(object sender, EventArgs e)
                                                                            {
                                                                                _recognizer.SetInputToDefaultAudioDevice();
                                                                                _recognizer.LoadGrammar(new Grammar(new GrammarBuilder(new Choices(File.ReadAllLines(@"txt file location")))));
                                                                                _recognizer.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(_recognizer_SpeechRecognized);
                                                                                _recognizer.RecognizeAsync(RecognizeMode.Multiple);
                                                                            }
                                                                            void _recognizer_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
                                                                            {
                                                                                int ranNum = rnd.Next(1, 10);
                                                                                string speech = e.Result.Text;
                                                                                switch (speech)
                                                                                {
                                                                                    //GREETINGS
                                                                                    case "hello":
                                                                                    case "hello jarvis":
                                                                                        if (ranNum < 6) { JARVIS.Speak("Hello sir"); }
                                                                                        else if (ranNum > 5) { JARVIS.Speak("Hi"); }
                                                                                        break;
                                                                                    case "goodbye":
                                                                                    case "goodbye jarvis":
                                                                                    case "close":
                                                                                    case "close jarvis":
                                                                                        JARVIS.Speak("Until next time");
                                                                                        Close();
                                                                                        break;
                                                                                    case "jarvis":
                                                                                        if (ranNum < 5) { QEvent = ""; JARVIS.Speak("Yes sir"); }
                                                                                        else if (ranNum > 4) { QEvent = ""; JARVIS.Speak("Yes?"); }
                                                                                        break;

                                                                                    //WEBSITES
                                                                                    case "open website":
                                                                                        System.Diagnostics.Process.Start("url");
                                                                                        break;

                                                                                    //SHELL COMMANDS
                                                                                    case "open program":
                                                                                        System.Diagnostics.Process.Start("file location");
                                                                                        JARVIS.Speak("Loading");
                                                                                        break;

                                                                                    //CLOSE PROGRAMS
                                                                                    case "close program":
                                                                                        ProcWindow = "process name";
                                                                                        StopWindow();
                                                                                        break;

                                                                                    //CONDITION OF DAY
                                                                                    case "what time is it":
                                                                                        DateTime now = DateTime.Now;
                                                                                        string time = now.GetDateTimeFormats('t')[0];
                                                                                        JARVIS.Speak(time);
                                                                                        break;
                                                                                    case "what day is it":
                                                                                        JARVIS.Speak(DateTime.Today.ToString("dddd"));
                                                                                        break;
                                                                                    case "whats the date":
                                                                                    case "whats todays date":
                                                                                        JARVIS.Speak(DateTime.Today.ToString("dd-MM-yyyy"));
                                                                                        break;

                                                                                    //OTHER COMMANDS
                                                                                    case "go fullscreen":
                                                                                        FormBorderStyle = FormBorderStyle.None;
                                                                                        WindowState = FormWindowState.Maximized;
                                                                                        TopMost = true;
                                                                                        JARVIS.Speak("expanding");
                                                                                        break;
                                                                                    case "exit fullscreen":
                                                                                        FormBorderStyle = FormBorderStyle.Sizable;
                                                                                        WindowState = FormWindowState.Normal;
                                                                                        TopMost = false;
                                                                                        break;
                                                                                    case "switch window":
                                                                                        SendKeys.Send("%{TAB " + count + "}");
                                                                                        count += 1;
                                                                                        break;
                                                                                    case "reset":
                                                                                        count = 1;
                                                                                        timer = 11;
                                                                                        lblTimer.Visible = false;
                                                                                        ShutdownTimer.Enabled = false;
                                                                                        lstCommands.Visible = false;
                                                                                        break;
                                                                                    case "out of the way":
                                                                                        if (WindowState == FormWindowState.Normal || WindowState == FormWindowState.Maximized)
                                                                                        {
                                                                                            WindowState = FormWindowState.Minimized;
                                                                                            JARVIS.Speak("My apologies");
                                                                                        }
                                                                                        break;
                                                                                    case "come back":
                                                                                        if (WindowState == FormWindowState.Minimized)
                                                                                        {
                                                                                            JARVIS.Speak("Alright?");
                                                                                            WindowState = FormWindowState.Normal;
                                                                                        }
                                                                                        break;
                                                                                    case "show commands":
                                                                                        string[] commands = (File.ReadAllLines(@"txt file location"));
                                                                                        JARVIS.Speak("Very well");
                                                                                        lstCommands.Items.Clear();
                                                                                        lstCommands.SelectionMode = SelectionMode.None;
                                                                                        lstCommands.Visible = true;
                                                                                        foreach (string command in commands)
                                                                                        {
                                                                                            lstCommands.Items.Add(command);
                                                                                        }
                                                                                        break;
                                                                                    case "hide listbox":
                                                                                        lstCommands.Visible = false;
                                                                                        break;

                                                                                    //SHUTDOWN RESTART LOG OFF
                                                                                    case "shutdown":
                                                                                        if (ShutdownTimer.Enabled == false)
                                                                                        {
                                                                                            QEvent = "shutdown";
                                                                                            JARVIS.Speak("I will shutdown shortly");
                                                                                            lblTimer.Visible = true;
                                                                                            ShutdownTimer.Enabled = true;
                                                                                        }
                                                                                        break;
                                                                                    case "log off":
                                                                                        if (ShutdownTimer.Enabled == false)
                                                                                        {
                                                                                            QEvent = "logoff";
                                                                                            JARVIS.Speak("Logging off");
                                                                                            lblTimer.Visible = true;
                                                                                            ShutdownTimer.Enabled = true;
                                                                                        }
                                                                                        break;
                                                                                    case "restart":
                                                                                        if (ShutdownTimer.Enabled == false)
                                                                                        {
                                                                                            QEvent = "restart";
                                                                                            JARVIS.Speak("I'll be back shortly");
                                                                                            lblTimer.Visible = true;
                                                                                            ShutdownTimer.Enabled = true;
                                                                                        }
                                                                                        break;
                                                                                    case "abort":
                                                                                        if (ShutdownTimer.Enabled == true)
                                                                                        {
                                                                                            QEvent = "abort";
                                                                                        }
                                                                                        break;
                                                                                    case "speed up":
                                                                                        if (ShutdownTimer.Enabled == true)
                                                                                        {
                                                                                            ShutdownTimer.Interval = ShutdownTimer.Interval / 10;
                                                                                        }
                                                                                        break;
                                                                                    case "slow down":
                                                                                        if (ShutdownTimer.Enabled == true)
                                                                                        {
                                                                                            ShutdownTimer.Interval = ShutdownTimer.Interval * 10;
                                                                                        }
                                                                                        break;
                                                                                }
                                                                            }
                                                                            private void ShutdownTimer_Tick(object sender, EventArgs e)
                                                                            {
                                                                                if (timer == 0)
                                                                                {
                                                                                    lblTimer.Visible = false;
                                                                                    ComputerTermination();
                                                                                    ShutdownTimer.Enabled = false;
                                                                                }
                                                                                else if (QEvent == "abort")
                                                                                {
                                                                                    timer = 10;
                                                                                    lblTimer.Visible = false;
                                                                                    ShutdownTimer.Enabled = false;
                                                                                }
                                                                                else
                                                                                {
                                                                                    timer = timer - .01;
                                                                                    lblTimer.Text = timer.ToString();
                                                                                }
                                                                            }
                                                                            private void ComputerTermination()
                                                                            {
                                                                                switch (QEvent)
                                                                                {
                                                                                    case "shutdown":
                                                                                        System.Diagnostics.Process.Start("shutdown", "-s");
                                                                                        break;
                                                                                    case "logoff":
                                                                                        System.Diagnostics.Process.Start("shutdown", "-l");
                                                                                        break;
                                                                                    case "restart":
                                                                                        System.Diagnostics.Process.Start("shutdown", "-r");
                                                                                        break;
                                                                                }
                                                                            }
                                                                            private void StopWindow()
                                                                            {
                                                                                System.Diagnostics.Process[] procs = System.Diagnostics.Process.GetProcessesByName(ProcWindow);
                                                                                foreach (System.Diagnostics.Process proc in procs)
                                                                                {
                                                                                    proc.CloseMainWindow();
                                                                                }
                                                                            }

                                                                    Thursday, May 30, 2013

                                                                    JARVIS Speech Recognition Program


                                                                    Imports System.Speech.Recognition
                                                                    Imports System.Speech.Recognition.SrgsGrammar
                                                                    Imports System.Runtime.InteropServices 'For Monitor Command

                                                                    Public Class Form1
                                                                        'This object represents the Speech recognition engine
                                                                        Private recognizer As SpeechRecognizer
                                                                        Dim QuestionEvent As String

                                                                        Public Sub New()

                                                                            InitializeComponent() ' This call is required by the Windows Form Designer.

                                                                            recognizer = New SpeechRecognizer() ' Add any initialization after the InitializeComponent() call.

                                                                            AddHandler recognizer.SpeechDetected, AddressOf recognizer_SpeechDetected 'this event is raised when the user begins to speak

                                                                            AddHandler recognizer.SpeechRecognitionRejected, AddressOf recognizer_SpeechRecognitionRejected 'this is raised when spoken words are not recognized as compliant to our grammar rules

                                                                            AddHandler recognizer.SpeechRecognized, AddressOf recognizer_SpeechRecognized 'this is raised when the application correctly recognizes spoken words

                                                                            Dim grammar As New GrammarBuilder()
                                                                            grammar.Append(New Choices(System.IO.File.ReadAllLines("Commands.txt")))

                                                                            recognizer.LoadGrammar(New Grammar(grammar))
                                                                        End Sub

                                                                        Private Sub recognizer_SpeechRecognized(ByVal sender As Object, ByVal e As SpeechRecognizedEventArgs)
                                                                            Dim Random As New Random
                                                                            Dim Number As Integer = Random.Next(1, 10)
                                                                            Dim Jarvis = CreateObject("sapi.spvoice")
                                                                            Select Case e.Result.Text.ToUpper

                                                                                'GREETINGS
                                                                                Case Is = "HELLO JARVIS"
                                                                                    Jarvis.Speak("Hello sir")
                                                                                Case Is = "GOODBYE JARVIS"
                                                                                    Jarvis.Speak("Until next time")
                                                                                    Me.Close()

                                                                                    'DATE / TIME / WEATHER
                                                                                Case Is = "WHAT TIME IS IT"
                                                                                    Jarvis.Speak(Format(Now, "Short Time"))
                                                                                Case Is = "WHAT DAY IS IT"

                                                                                    Jarvis.Speak(Format(Now, "Long Date"))
                                                                                Case Is = "HOWS THE WEATHER"
                                                                                    System.Diagnostics.Process.Start("https://www.google.com/webhp?sourceid=chrome-instant&ion=1&ie=UTF-8#output=search&sclient=psy-ab&q=weather&oq=&gs_l=&pbx=1&bav=on.2,or.r_cp.r_qf.&bvm=bv.47008514,d.eWU&fp=6c7f8a5fed4db490&biw=1366&bih=643&ion=1&pf=p&pdl=300")
                                                                                    Jarvis.Speak("Searching for local weather")

                                                                                    'SHELL COMMANDS
                                                                                Case Is = "RUN GOOGLE CHROME"
                                                                                    Jarvis.Speak("Right Away")
                                                                                    Shell()
                                                                                Case Is = "RUN ITUNES"
                                                                                    Jarvis.speak("I'm in the mood for a bit of music actually")
                                                                                    Shell()

                                                                                    'WEBSITES
                                                                                Case Is = "RUN FACEBOOK"
                                                                                    System.Diagnostics.Process.Start("http://www.facebook.com")
                                                                                Case Is = "RUN GOOGLE"
                                                                                    System.Diagnostics.Process.Start("http://www.google.com")
                                                                                Case Is = "RUN YAHOO"
                                                                                    System.Diagnostics.Process.Start("http://www.yahoo.com")
                                                                                Case Is = "RUN PANDORA"
                                                                                    System.Diagnostics.Process.Start("http://www.pandora.com")
                                                                                Case Is = "RUN THE PIRATE BAY"
                                                                                    System.Diagnostics.Process.Start("http://www.thepiratebay.se")
                                                                                Case Is = "RUN YOUTUBE"
                                                                                    System.Diagnostics.Process.Start("http://www.youtube.com")

                                                                                    'MISCELLANEOUS
                                                                                Case Is = "SHOW COMMANDS"
                                                                                    lstboxCommands.Visible = True
                                                                                    Jarvis.speak("Here we are")
                                                                                Case Is = "HIDE COMMANDS"
                                                                                    lstboxCommands.Visible = False
                                                                                    Jarvis.speak("Very well")
                                                                                Case Is = "OUT OF THE WAY JARVIS", "OUT OF THE WAY"
                                                                                    Select Case Number
                                                                                        Case Is < 6
                                                                                            Jarvis.speak("My apologies sir")
                                                                                        Case Is > 5
                                                                                            Jarvis.speak("Right away")
                                                                                    End Select
                                                                                    Me.WindowState = FormWindowState.Minimized
                                                                                Case Is = "COME BACK JARVIS", "COME BACK"
                                                                                    Me.WindowState = FormWindowState.Normal

                                                                                    Jarvis.speak("Here I am")
                                                                                Case Is = "OPEN DISK DRIVE"
                                                                                    Dim oWMP = CreateObject("WMPlayer.OCX.7")
                                                                                    Dim CDROM = oWMP.cdromCollection
                                                                                    If CDROM.Count = 2 Then
                                                                                        CDROM.Item(1).Eject()
                                                                                        Jarvis.speak("Its now open")
                                                                                    End If
                                                                                Case Is = "MONITOR OFF"
                                                                                    SendMessage(Me.Handle.ToInt32(), WM_SYSCOMMAND, SC_MONITORPOWER, 2)
                                                                                    Jarvis.Speak("I'll just close my eyes for a minute")
                                                                                Case Is = "SHUTDOWN"
                                                                                    QuestionEvent = "Shutdown"
                                                                                    Timer1.Enabled = True
                                                                                    lblTimer.Visible = True
                                                                                Case Is = "RESTART"
                                                                                    QuestionEvent = "Restart"
                                                                                    Timer1.Enabled = True
                                                                                    lblTimer.Visible = True
                                                                                Case Is = "LOG OFF"
                                                                                    QuestionEvent = "Log Off"
                                                                                    Timer1.Enabled = True
                                                                                    lblTimer.Visible = True
                                                                                Case Is = "ABORT"
                                                                                    Timer1.Enabled = False
                                                                                    lblTimer.Visible = False

                                                                                    QuestionEvent = String.Empty
                                                                                Case Is = "SPEED UP"
                                                                                    If Timer1.Interval = 1 Then
                                                                                        Jarvis.Speak("Performing at maximum capacity")
                                                                                    Else : Timer1.Interval = Timer1.Interval / 10
                                                                                    End If
                                                                                Case Is = "SLOW DOWN"
                                                                                    If Timer1.Interval = 1000 Then
                                                                                        Jarvis.Speak("If it were any slower it would be standing still")
                                                                                    Else : Timer1.Interval = Timer1.Interval * 10

                                                                                    End If
                                                                                  'SOCIAL
                                                                                Case Is = "JARVIS"
                                                                                    Jarvis.speak("Yes?")
                                                                                Case Is = "GOOD", "IM GOOD"
                                                                                    Select Case QuestionEvent
                                                                                        Case Is = "Particularly well"
                                                                                            Jarvis.speak("Glad to hear it")
                                                                                        Case Is = "I'm good"
                                                                                            Jarvis.speak("Of course")
                                                                                        Case Is = "And you"
                                                                                            Jarvis.speak("Good")
                                                                                    End Select
                                                                                Case Is = "HOW ARE YOU", "HOW ARE YOU DOING", "HOW ARE YOU TODAY", "HOWS LIFE"
                                                                                    Select Case Number
                                                                                        Case Is = 1, 2
                                                                                            Jarvis.speak("Good as always. Thanks for asking")
                                                                                        Case Is = 3, 4
                                                                                            Jarvis.speak("I'm doing particularly well actually. How are you?")
                                                                                            QuestionEvent = "Particularly well"
                                                                                        Case Is = 5, 6
                                                                                            Jarvis.speak("I'm good. How about you sir?")
                                                                                            QuestionEvent = "I'm good"
                                                                                        Case Else : Jarvis.speak("Couldn't be better. And you?")
                                                                                            QuestionEvent = "And you"
                                                                                    End Select
                                                                              End Select
                                                                        End Sub

                                                                        'LABEL DETECT / REJECT
                                                                        Private Sub recognizer_SpeechDetected(ByVal sender As Object, ByVal e As SpeechDetectedEventArgs)

                                                                            Label1.ForeColor = Color.Green : Label1.BackColor = Color.Transparent : Label1.Text = "Speech engine has detected that you spoke something"
                                                                        End Sub
                                                                        Private Sub recognizer_SpeechRecognitionRejected(ByVal sender As Object, ByVal e As SpeechRecognitionRejectedEventArgs)

                                                                            Label1.ForeColor = Color.Red : Label1.BackColor = Color.Transparent : Label1.Text = ("Sorry, but the phrase could not be recognized")

                                                                        End Sub

                                                                        'LOADS THE COMMANDS INTO AN ARRAY AND LISTBOX
                                                                        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
                                                                            Dim Commands() As String = System.IO.File.ReadAllLines("Commands.txt")
                                                                            For i As Integer = 0 To Commands.Count - 1
                                                                                lstboxCommands.Items.Add(Commands(i))
                                                                            Next
                                                                        End Sub

                                                                        'HIDES COMMANDS LIST BOX
                                                                        Private Sub lstboxCommands_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstboxCommands.SelectedIndexChanged
                                                                            lstboxCommands.Visible = False
                                                                        End Sub

                                                                        'FOR MONITOR COMMAND
                                                                        Public WM_SYSCOMMAND As Integer = &H112
                                                                        Public SC_MONITORPOWER As Integer = &HF170
                                                                        <DllImport("user32.dll")> _
                                                                        Private Shared Function SendMessage(ByVal hWnd As Integer, ByVal hMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
                                                                        End Function

                                                                    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
                                                                            lblTimer.Text = FormatNumber(Val(lblTimer.Text) - Val(0.01), 2)
                                                                            If lblTimer.Text = 0 Then
                                                                                ShutdownProcedure()
                                                                                Timer1.Enabled = False
                                                                                lblTimer.Visible = False
                                                                            End If
                                                                        End Sub

                                                                        Sub ShutdownProcedure()
                                                                            If QuestionEvent = "Shutdown" Then
                                                                                System.Diagnostics.Process.Start("shutdown", "-s")
                                                                            ElseIf QuestionEvent = "Restart" Then
                                                                                System.Diagnostics.Process.Start("shutdown", "-r")
                                                                            ElseIf QuestionEvent = "Log Off" Then
                                                                                System.Diagnostics.Process.Start("shutdown", "-l")
                                                                            End If

                                                                        End Sub

                                                                    End Class