Example #1
0
        private void KeyHookOnPressed(object sender, ShortcutKeyPressedEventArgs args)
        {
            if (args.ShortcutKey == ShortcutKey.None) return;

            var target = this._hookActions.FirstOrDefault(x => x.ShortcutKey == args.ShortcutKey);
            if (target != null && target.CanExecute())
            {
                VisualHelper.InvokeOnUIDispatcher(() => target.Action(InteropHelper.GetForegroundWindowEx()));
                args.Handled = true;
            }
        }
        private void InterceptorOnKeyDown(object sender, KeyEventArgs args)
        {
            if (this._suspended) return;

            if (args.KeyCode.IsModifyKey())
            {
                this._pressedModifiers.Add(args.KeyCode);
            }
            else
            {
                var pressedEventArgs = new ShortcutKeyPressedEventArgs(args.KeyCode, this._pressedModifiers);
                this.Pressed?.Invoke(this, pressedEventArgs);
                if (pressedEventArgs.Handled) args.SuppressKeyPress = true;
            }
        }
Example #3
0
        private void KeyHookOnPressed(object sender, ShortcutKeyPressedEventArgs args)
        {
            if (args.ShortcutKey == ShortcutKey.None)
            {
                return;
            }

            var target = this._hookActions.FirstOrDefault(x => x.ShortcutKey == args.ShortcutKey);

            if (target != null && target.CanExecute())
            {
                VisualHelper.InvokeOnUIDispatcher(() => target.Action(InteropHelper.GetForegroundWindowEx()));
                args.Handled = true;
            }
        }
Example #4
0
        private void InterceptorOnKeyDown(object sender, KeyEventArgs args)
        {
            if (this._suspended)
            {
                return;
            }

            if (args.KeyCode.IsModifyKey())
            {
                this._pressedModifiers.Add(args.KeyCode);
            }
            else
            {
                var pressedEventArgs = new ShortcutKeyPressedEventArgs(args.KeyCode, this._pressedModifiers);
                this.Pressed?.Invoke(this, pressedEventArgs);
                if (pressedEventArgs.Handled)
                {
                    args.SuppressKeyPress = true;
                }
            }
        }
        private void KeyHookOnPressed(object sender, ShortcutKeyPressedEventArgs args)
        {
            if (args.ShortcutKey == ShortcutKey.None) return;

            if (Settings.ShortcutKey.MoveLeft.ToShortcutKey() == args.ShortcutKey)
            {
                VisualHelper.InvokeOnUIDispatcher(() => this.MoveToLeft());
                args.Handled = true;
                return;
            }

            if (Settings.ShortcutKey.MoveLeftAndSwitch.ToShortcutKey() == args.ShortcutKey)
            {
                VisualHelper.InvokeOnUIDispatcher(() => this.MoveToLeft()?.Switch());
                args.Handled = true;
                return;
            }

            if (Settings.ShortcutKey.MoveRight.ToShortcutKey() == args.ShortcutKey)
            {
                VisualHelper.InvokeOnUIDispatcher(() => this.MoveToRight());
                args.Handled = true;
                return;
            }

            if (Settings.ShortcutKey.MoveRightAndSwitch.ToShortcutKey() == args.ShortcutKey)
            {
                VisualHelper.InvokeOnUIDispatcher(() => this.MoveToRight()?.Switch());
                args.Handled = true;
                return;
            }

            if (Settings.ShortcutKey.MoveNew.ToShortcutKey() == args.ShortcutKey)
            {
                VisualHelper.InvokeOnUIDispatcher(() => this.MoveToNew());
                args.Handled = true;
                return;
            }

            if (Settings.ShortcutKey.MoveNewAndSwitch.ToShortcutKey() == args.ShortcutKey)
            {
                VisualHelper.InvokeOnUIDispatcher(() => this.MoveToNew()?.Switch());
                args.Handled = true;
                return;
            }

            if (Settings.ShortcutKey.SwitchToLeft.ToShortcutKey() == args.ShortcutKey)
            {
                if (Settings.General.OverrideWindowsDefaultKeyCombination)
                {
                    VisualHelper.InvokeOnUIDispatcher(() => PrepareSwitchToLeft()?.Switch());
                    args.Handled = true;
                    return;
                }
            }

            if (Settings.ShortcutKey.SwitchToRight.ToShortcutKey() == args.ShortcutKey)
            {
                if (Settings.General.OverrideWindowsDefaultKeyCombination)
                {
                    VisualHelper.InvokeOnUIDispatcher(() => PrepareSwitchToRight()?.Switch());
                    args.Handled = true;
                    return;
                }
            }

            if (Settings.ShortcutKey.Pin.ToShortcutKey() == args.ShortcutKey)
            {
                this.PinRequested?.Invoke(this, InteropHelper.GetForegroundWindowEx());
                args.Handled = true;
                return;
            }

            if (Settings.ShortcutKey.Unpin.ToShortcutKey() == args.ShortcutKey)
            {
                this.UnpinRequested?.Invoke(this, InteropHelper.GetForegroundWindowEx());
                args.Handled = true;
                return;
            }
        }