OpenTween.HookGlobalHotkey.RegisterOriginalHotkey C# (CSharp) Method

RegisterOriginalHotkey() public method

public RegisterOriginalHotkey ( Keys hotkey, int hotkeyValue, ModKeys modifiers ) : bool
hotkey Keys
hotkeyValue int
modifiers ModKeys
return bool
        public bool RegisterOriginalHotkey(Keys hotkey, int hotkeyValue, ModKeys modifiers)
        {
            var modKey = Keys.None;
            if ((modifiers & ModKeys.Alt) == ModKeys.Alt) modKey |= Keys.Alt;
            if ((modifiers & ModKeys.Ctrl) == ModKeys.Ctrl) modKey |= Keys.Control;
            if ((modifiers & ModKeys.Shift) == ModKeys.Shift) modKey |= Keys.Shift;
            if ((modifiers & ModKeys.Win) == ModKeys.Win) modKey |= Keys.LWin;
            var key = new KeyEventArgs(hotkey | modKey);
            foreach (var kvp in this._hotkeyID)
            {
                if (kvp.Value.KeyEvent.KeyData == key.KeyData && kvp.Value.Value == hotkeyValue) return true; // 登録済みなら正常終了
            }
            var hotkeyId = Win32Api.RegisterGlobalHotKey(hotkeyValue, (int)modifiers, this._targetForm);
            if (hotkeyId > 0)
            {
                this._hotkeyID.Add(hotkeyId, new KeyEventValue(key, hotkeyValue));
                return true;
            }
            return false;
        }