Exemplo n.º 1
0
        /// <summary>
        /// Returns whether or not the hotkey currently set on this form is valid
        /// to be registered as a global hotkey.
        /// </summary>
        private Boolean IsHotkeyAvailable()
        {
            if (Hotkey.Equals(GlobalHotkeyService.Hotkey))
            {
                return(true);
            }

            return(GlobalHotKeyInterop.IsHotkeyAvailable(Hotkey));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Unregisterers the last global hotkey registered by this controller.
        /// </summary>
        private void UnregisterHotkey()
        {
            if (_hotkey != null)
            {
                GlobalHotKeyInterop.UnregisterGlobalHotkey(_hotkeyAtom, _mainFormHwnd);
                _hotkey = null;
            }

            if (_hotkeyAtom != 0)
            {
                Kernel32.GlobalDeleteAtom(_hotkeyAtom);
                _hotkeyAtom = 0;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Registers the currently set hotkey as a global hotkey.
        /// </summary>
        private void RegisterHotkey()
        {
            if (Hotkey == null)
            {
                return;
            }

            _hotkeyAtom = Kernel32.GlobalAddAtom(Resources.ApplicationTitle + HotkeyAtomSuffix);

            bool isRegistered = GlobalHotKeyInterop.RegisterGlobalHotkey(_hotkeyAtom, _mainFormHwnd, Hotkey);

            if (isRegistered == false)
            {
                UnregisterHotkey();
            }
        }