private void KeyboardHookKeyUp(object sender, RawKeyEventArgs args, ref bool handled)
        {
            _wasVDownOnKeyUp = _isVDown;
            _wasRightControlDownOnKeyUp = _isRightControlDown;
            _wasLeftControlDownOnKeyUp = _isLeftControlDown;

            if (args.Key == Key.V)
            {
                _isVDown = false;
            }
            else if (args.Key == Key.LeftCtrl)
            {
                _isLeftControlDown = false;
            }
            else if (args.Key == Key.RightCtrl)
            {
                _isRightControlDown = false;
            }

            if (!_messageHook.IgnoreClipboardActivity)
            {

                var previousHandled = (_wasLeftControlDownOnKeyUp || _wasRightControlDownOnKeyUp) && _wasVDownOnKeyUp; ;
                CheckHook();
                handled = _handled;

                if (handled && args.Key == Key.Escape)
                {

                    KillActiveWindowShowThresholdThreads();

                    if (IsVisible)
                    {

                        Hide();
                    }

                    using (var session = new ClipboardSession(_messageHook.WindowHandle))
                    {
                        if (session.IsOpen)
                        {
                            session.ClearClipboard();
                        }
                    }

                }

                if (!handled && previousHandled)
                {
                    //we need to paste - there was some kind of release.

                    _messageHook.IgnoreClipboardActivity = true;

                    KillActiveWindowShowThresholdThreads();

                    if (IsVisible)
                    {
                        Hide();

                        _messageHook.SwapClipboardItemPositions(lstClipboardContents.SelectedIndex, 0);
                    }

                    var sendPasteThread = new Thread(delegate()
                                                         {

                                                             Thread.Sleep(50);

                                                             //paste data out
                                                             SendPasteCombination();

                                                             _wasLeftControlDownOnKeyDown
                                                                 = false;
                                                             _wasLeftControlDownOnKeyUp
                                                                 = false;
                                                             _wasRightControlDownOnKeyDown
                                                                 = false;
                                                             _wasRightControlDownOnKeyUp
                                                                 = false;
                                                             _wasVDownOnKeyDown = false;
                                                             _wasVDownOnKeyUp = false;

                                                             _isVDown = false;

                                                             var returnIgnoreThread = new Thread(delegate()
                                                             {

                                                                 Thread.Sleep(50);
                                                                 _messageHook.IgnoreClipboardActivity = false;

                                                             });
                                                             returnIgnoreThread.IsBackground = true;
                                                             returnIgnoreThread.Start();

                                                         });
                    sendPasteThread.IsBackground = true;
                    sendPasteThread.Start();

                }

            }
        }
        private void KeyboardHookKeyDown(object sender, RawKeyEventArgs args, ref bool handled)
        {
            _wasVDownOnKeyDown = _isVDown;
            _wasRightControlDownOnKeyDown = _isRightControlDown;
            _wasLeftControlDownOnKeyDown = _isLeftControlDown;

            if (args.Key == Key.V)
            {
                _isVDown = true;
            }
            else if (args.Key == Key.LeftCtrl)
            {
                _isLeftControlDown = true;
            }
            else if (args.Key == Key.RightCtrl)
            {
                _isRightControlDown = true;
            }

            if (!_messageHook.IgnoreClipboardActivity)
            {

                var previousHandled = (_wasLeftControlDownOnKeyDown || _wasRightControlDownOnKeyDown) && _wasVDownOnKeyDown; ;
                CheckHook();
                handled = _handled;

                if (_handled)
                {

                    if (args.Key == Key.PrintScreen)
                    {

                        var path = ScreenshotHelper.SaveScreenshot(0, 0, (int)SystemParameters.PrimaryScreenWidth,
                                                                   (int)SystemParameters.PrimaryScreenHeight);
                        Process.Start(path);
                    }

                    if (IsVisible)
                    {

                        if (args.Key == Key.Down)
                        {

                            SelectNextClipboardItem();

                        }
                        else if (args.Key == Key.Up)
                        {

                            SelectPreviousClipboardItem();

                        }

                        if (args.Key == Key.Delete)
                        {

                            //delete an entry - delete was pressed while holding down CTRL + V
                            _messageHook.RemoveClipboardData(_messageHook.SelectedClipboardItemIndex);

                        }

                    }
                    else if (!previousHandled)
                    {

                        KillActiveWindowShowThresholdThreads();

                        //start thread to monitor if it is time to show the GUI
                        _checkWindowShowThresholdThread = new Thread(delegate()
                                                                         {
                                                                             Thread.Sleep(150);

                                                                             if (_handled)
                                                                             {

                                                                                 _lastInjectionActivity =
                                                                                     Environment.TickCount;

                                                                                 LogHelper.Log(
                                                                                     typeof(IntegratedClipboardManager),
                                                                                     "Showing the user interface");

                                                                                 Dispatcher.Invoke(
                                                                                     new Action(delegate()
                                                                                                    {

                                                                                                        RepositionWindow
                                                                                                            ();
                                                                                                        Show();
                                                                                                        Activate();
                                                                                                        Focus();

                                                                                                        NotificationHelper.ShowInstructions
                                                                                                            ("The Shapeshifter integrated mode interface is now visible. Use the Up and Down keys to choose an item, and release CTRL + V to paste. Hit the Delete key to delete an item.");
                                                                                                    }
                                                                                 ));

                                                                             }

                                                                         });
                        _checkWindowShowThresholdThread.IsBackground = true;
                        _checkWindowShowThresholdThread.Priority = ThreadPriority.Lowest;
                        _checkWindowShowThresholdThread.Start();
                    }

                }

            }
        }