예제 #1
0
 private void OnExit(object sender, EventArgs e)
 {
     Console.WriteLine(" ! OSK exited.");
     trayIcon.Dispose();
     m_KeyboardHookManager.Dispose();
     Application.Exit();
     ShowToolbars();
 }
예제 #2
0
        /// <summary>
        /// Function triggered when program is closing.
        /// </summary>
        /// <param name="sender">Sender of the close event.</param>
        /// <param name="e">Event arguments.</param>
        private void MainWindowFormClosing(object sender, FormClosingEventArgs e)
        {
            Logger.Instance.Debug("Program closing");

            // Hopefully removes all hooks.
            try
            {
                _listenerKeyboard.Dispose();
                _listenerMouse.Dispose();
            }
            catch (Win32Exception exc)
            {
                // Listeners have already been disposed, probably.
                // See http://globalmousekeyhook.codeplex.com/workitem/929
                Logger.Instance.Exception("Disposing keyhooks, exception ignored.", exc);
            }

            if (_capturer.Shots.Count != 0)
            {
                Logger.Instance.Debug("Shots left in buffer.");
                // There are still screenshots in the buffer! D:
                var res = MessageBox.Show(this, strings.dialog_closingProgram_UnsavedContent, strings.dialog_closingProgram_UnsavedTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

                if (res == DialogResult.Yes)
                {
                    Logger.Instance.Debug("Saving screenshots before exiting.");
                    SaveShots();
                }
            }
        }
        public KeyboardKeyDownUpSource(
            Enums.Keys triggerKey,
            IPointSource pointSource)
        {
            this.triggerKey  = (System.Windows.Forms.Keys)triggerKey; //Cast to the Windows.Forms.Keys enum
            this.pointSource = pointSource;

            keyboardHookListener = new KeyboardHookListener(new GlobalHooker())
            {
                Enabled = true
            };

            System.Windows.Application.Current.Exit += (sender, args) =>
            {
                keyboardHookListener.Dispose();
                Log.Debug("Keyboard hook listener disposed.");
            };

            /*
             * Keys: http://msdn.microsoft.com/en-GB/library/system.windows.forms.keys.aspx
             * KeyDown: happens when the person presses a key (when the keyboard first detects a finger on a key, this happens when the key is pressed down).
             * KeyPress: happens when a key is pressed and then released.
             * KeyUp: happens when the key is released
             */
        }
 private static void Enable(bool force)
 {
     if (force)
     {
         m_KeyboardHookManager.Enabled = false;
     }
     else
     {
         m_KeyboardHookManager.Enabled = false;
         m_KeyboardHookManager.Dispose();
     }
 }
예제 #5
0
 private void Dispose(bool disposing)
 {
     if (!this.disposed)
     {
         if (disposing)
         {
             closeLogFiles();
         }
         _keyboardListener.Dispose();
         _mouseListener.Dispose();
         this.disposed  = true;
         this.InSession = false;
     }
 }
예제 #6
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);
        }
예제 #7
0
 private void exitButton_Click(object sender, EventArgs e) //on exit event
 {
     //display exit confirm
     if (MessageBox.Show("Are you sure you want to exit?",
                         "Confirm Exit", MessageBoxButtons.YesNo,
                         MessageBoxIcon.Question) ==
         DialogResult.No)
     {
     }
     else
     {
         m_KeyboardHookManager.Dispose(); //exit keyhook
         ShowWindow(hwnd, SW_SHOW);       //restore taskbar
         //restore batch in hidden window
         System.Diagnostics.Process          process   = new System.Diagnostics.Process();
         System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
         startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
         startInfo.FileName    = "cmd.exe";
         startInfo.Arguments   = @"/c showScreen.exe";
         process.StartInfo     = startInfo;
         process.Start();
         Application.Exit(); //bye!
     }
 }
 public void Dispose() //TODO: need to learn .NET disposal
 {
     unhookInputs();
     keyboardHookManager.Dispose();
 }
예제 #9
0
 private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
 {
     m_keyboardListener.Dispose();
 }
 public void Dispose()
 {
     _hook.Enabled = false;
     _hook.Dispose();
 }
예제 #11
0
 private void closeToolStripMenuItem_Click(object sender, EventArgs e)
 {
     keyHook.Dispose();
     Application.Exit();
 }