Ejemplo n.º 1
0
 private void InterceptorOnKeyDown(object sender, System.Windows.Forms.KeyEventArgs args)
 {
     var key = KeyInterop.KeyFromVirtualKey((int)args.KeyCode);
     if (key.IsModifyKey())
     {
         this.pressedModifiers.Add(key);
     }
     else
     {
         var pressedEventArgs = new ShortcutKeyPressedEventArgs(key, this.pressedModifiers);
         this.Pressed?.Invoke(this, pressedEventArgs);
         if (pressedEventArgs.Handled) args.SuppressKeyPress = true;
     }
 }
Ejemplo n.º 2
0
        private void KeyHookOnPressed(object sender, ShortcutKeyPressedEventArgs args)
        {
            if (ShortcutSettings.OpenDesktopSelector.Value != null) { }

            if (ShortcutSettings.MoveLeft.Value != null &&
                ShortcutSettings.MoveLeft.Value == args.ShortcutKey)
            {
                VisualHelper.InvokeOnUIDispatcher(() => this.MoveToLeft());
                args.Handled = true;
            }

            if (ShortcutSettings.MoveLeftAndSwitch.Value != null &&
                ShortcutSettings.MoveLeftAndSwitch.Value == args.ShortcutKey)
            {
                VisualHelper.InvokeOnUIDispatcher(() => this.MoveToLeft()?.Switch());
                args.Handled = true;
            }

            if (ShortcutSettings.MoveRight.Value != null &&
                ShortcutSettings.MoveRight.Value == args.ShortcutKey)
            {
                VisualHelper.InvokeOnUIDispatcher(() => this.MoveToRight());
                args.Handled = true;
            }

            if (ShortcutSettings.MoveRightAndSwitch.Value != null &&
                ShortcutSettings.MoveRightAndSwitch.Value == args.ShortcutKey)
            {
                VisualHelper.InvokeOnUIDispatcher(() => this.MoveToRight()?.Switch());
                args.Handled = true;
            }

            if (ShortcutSettings.MoveNew.Value != null &&
                ShortcutSettings.MoveNew.Value == args.ShortcutKey)
            {
                VisualHelper.InvokeOnUIDispatcher(() => this.MoveToNew());
                args.Handled = true;
            }

            if (ShortcutSettings.MoveNewAndSwitch.Value != null &&
                ShortcutSettings.MoveNewAndSwitch.Value == args.ShortcutKey)
            {
                VisualHelper.InvokeOnUIDispatcher(() => this.MoveToNew()?.Switch());
                args.Handled = true;
            }

            if (ShortcutSettings.SwitchToLeft.Value != null &&
                ShortcutSettings.SwitchToLeft.Value == args.ShortcutKey)
            {
                if (GeneralSettings.OverrideOSDefaultKeyCombination)
                {
                    VisualHelper.InvokeOnUIDispatcher(() => PrepareSwitchToLeft()?.Switch());
                    args.Handled = true;
                }
            }

            if (ShortcutSettings.SwitchToRight.Value != null &&
                ShortcutSettings.SwitchToRight.Value == args.ShortcutKey)
            {
                if (GeneralSettings.OverrideOSDefaultKeyCombination)
                {
                    VisualHelper.InvokeOnUIDispatcher(() => PrepareSwitchToRight()?.Switch());
                    args.Handled = true;
                }
            }
        }