示例#1
0
 /// <summary>
 ///     Cancels pasting
 /// </summary>
 public void Cancel()
 {
     if (TextList != null)
     {
         TextList = null;
     }
     Unsubscribe();
     OnPastingDeactivated?.Invoke(this, new PastingDeactivatedEventArgs());
 }
示例#2
0
        private void GlobalHook_KeyUp(object sender, KeyEventArgs e)
        {
            switch (ContentType)
            {
            case ContentTypes.NotList:
                switch (e.KeyCode)
                {
                case Keys.V when SendingKeys:
                    e.SuppressKeyPress = true;
                    break;

                case Keys.V when SendingKeys == false:
                    Unsubscribe();
                    OnPastingDeactivated?.Invoke(this, new PastingDeactivatedEventArgs());
                    Reset_V_and_Control();
                    break;
                }

                break;

            case ContentTypes.List:
                switch (e.KeyCode)
                {
                case Keys.V when !SendingKeys:
                    _vUp = true;
                    break;

                case Keys.LControlKey when !SendingKeys:
                    _ctrlUp = true;
                    break;
                }

                switch (ReceivingProgram)
                {
                case ReceivingPrograms.ThisProgram:         //Don't paste to own window if this program has focus.
                    e.SuppressKeyPress = true;
                    break;

                case ReceivingPrograms.Standard:         //All other programs gets standard pasting.
                    break;

                case ReceivingPrograms.Console
                    :         //MobaXterm; mRemoteNG; PuTTY; Windows PowerShell; Kommandotolken.
                    switch (SendingKeys)
                    {
                    case true:
                        switch (e.KeyCode)
                        {
                        case Keys.Packet:
                        case Keys.LControlKey:
                        case Keys.Enter:
                            break;

                        default:
                            e.SuppressKeyPress = true;
                            break;
                        }

                        break;

                    case false:
                        switch (e.KeyCode)
                        {
                        case Keys.V when e.KeyCode == Keys.V && e.Control:
                            CtrlVDetected      = false;
                            CtrlUpBeforeVGotUp = false;
                            e.SuppressKeyPress = true;
                            SendingKeys        = true;
                            _inputSimulator.Keyboard.KeyUp(VirtualKeyCode.LCONTROL);
                            SendVirtualKeys(GetTextForVirtualKeys());
                            SendingKeys = false;
                            _inputSimulator.Keyboard.KeyDown(VirtualKeyCode.LCONTROL);
                            InitiateOrUpdateValuesDependingOnNrOfItemsInList(TextList.Count);
                            break;

                        case Keys.V when CtrlVDetected && CtrlUpBeforeVGotUp:
                            CtrlVDetected      = false;
                            CtrlUpBeforeVGotUp = false;
                            e.SuppressKeyPress = true;
                            SendingKeys        = true;
                            SendVirtualKeys(GetTextForVirtualKeys());
                            SendingKeys = false;
                            InitiateOrUpdateValuesDependingOnNrOfItemsInList(TextList.Count);
                            break;

                        case Keys.LControlKey:
                            CtrlUpBeforeVGotUp = true;
                            SendingKeys        = false;
                            break;
                        }

                        break;
                    }

                    break;
                }

                break;
            }
        }