示例#1
0
 private void Enable()
 {
     if (listener == null)
     {
         timeout           = Convert.ToInt32(ConfigurationManager.AppSettings["Timeout"]);
         listener          = new MouseKeyboardActivityMonitor.KeyboardHookListener(new GlobalHooker());
         listener.KeyDown += ListenerOnKeyDown;
         listener.KeyUp   += ListenerOnKeyUp;
         listener.Enabled  = true;
     }
     else
     {
         listener.Stop();
     }
 }
示例#2
0
        /// <summary>
        /// Event triggered when the window is closing.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            //Save all settings to file.
            Configuration.Instance.Save();

            //Unregister all keyboard events.
            Keyboard_Hook.KeyDown -= Keyboard_Hook_KeyDown;
            Keyboard_Hook.KeyUp   -= Keyboard_Hook_KeyUp;

            //Stop and dispose the keyboard hook.
            Keyboard_Hook.Stop();
            Keyboard_Hook.Dispose();

            //Stop playback and clean-up all resources.
            Stop();

            //Force close.
            Environment.Exit(0);
        }