NHotkey icon indicating copy to clipboard operation
NHotkey copied to clipboard

HotkeyEventArgs.Handled property not passing through keys

Open chocobot opened this issue 3 years ago • 1 comments

Regardless of whether the HotkeyEventArgs.Handled property is set to true or false, the key is being blocked.

What I am trying to do is limit the hotkey to certain windows.. if its not a window that I recognize, I set the handled property to false. I would expect this to allow the key to passthru to the unrecognized window. This is not the case.

Example:

            HotkeyManager.Current.AddOrReplace("RotateLeft", Key.Left, ModifierKeys.None, (sender, e) =>
            {
                if (HotkeyWindow.ActiveWindowSupported())
                    {
                          OnRotateHotkey(sender, e);
                          e.Handled = true;
                    }
                else
                    e.Handled = false;
            });

chocobot avatar Nov 03 '21 13:11 chocobot

Hi @chocobot,

Sorry you're having problems with NHotkey. Unfortunately, I'm afraid there's not much I can do about it in this case... As long as a key combination is registered as a hotkey, it's only a hotkey, and it can no longer function as a "normal" key. In other words, if it's registered as a hotkey, other applications won't be able to handle it, ever (well, unless they use low level keyboard hooks, but most apps don't normally do that). That behavior comes from the RegisterHotKey function, so it's not something NHotkey can control; that's just how hotkeys work in Windows.

The effect of the Handled property is just to skip the default processing for the WM_HOTKEY message. Since the default processing doesn't actually do anything for this message, the Handled property doesn't actually do anything useful... I didn't realize that when I first implemented this library; I should probably remove it.

thomaslevesque avatar Nov 03 '21 22:11 thomaslevesque