public void RegisterHotKey(HotKey hotKey, Action callback) { // Get codes that represent virtual key and modifiers var virtualKey = KeyInterop.VirtualKeyFromKey(hotKey.Key); var modifiers = (int)hotKey.Modifiers; var hotKeyRegistration = GlobalHotKey.TryRegister(virtualKey, modifiers, callback); if (hotKeyRegistration != null) { _hotKeyRegistrations.Add(hotKeyRegistration); } else { Debug.WriteLine("Failed to register hotkey."); } }
public void RegisterHotKey(HotKey hotKey, Action handler) { // Get codes that represent virtual key and modifiers var virtualKey = KeyInterop.VirtualKeyFromKey(hotKey.Key); var modifiers = (int)hotKey.Modifiers; var registeredHotKey = GlobalHotKey.TryRegister(virtualKey, modifiers, handler); if (registeredHotKey != null) { _registeredHotKeys.Add(registeredHotKey); } else { Debug.WriteLine("Failed to register hotkey."); } }