예제 #1
0
        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.");
            }
        }
예제 #2
0
        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.");
            }
        }