protected override void WndProc(ref Message m)
        {
            if (m.Msg == (int)WindowsMessages.HOTKEY && !IgnoreHotkeys && CheckRepeatLimitTime())
            {
                HotkeyInfo hotkey = GetHotkeyInfoFromID((ushort)m.WParam);

                if (hotkey != null)
                {
                    if (hotkey.HotkeyPress != null)
                    {
                        hotkey.HotkeyPress();
                    }

                    OnKeyPressed(new KeyEventArgs(hotkey.Key));
                }

                return;
            }

            base.WndProc(ref m);
        }
        public HotkeyStatus RegisterHotkey(Keys hotkey, Action hotkeyPress = null, int tag = 0)
        {
            KeyInfo keyInfo = new KeyInfo(hotkey);

            if (keyInfo.KeyCode == Keys.None)
            {
                return(HotkeyStatus.NotConfigured);
            }

            if (IsHotkeyExist(hotkey))
            {
                DebugHelper.WriteLine("Hotkey already exist: " + keyInfo);
                return(HotkeyStatus.Failed);
            }

            string atomName = Thread.CurrentThread.ManagedThreadId.ToString("X8") + (int)hotkey;

            ushort id = NativeMethods.GlobalAddAtom(atomName);

            if (id == 0)
            {
                DebugHelper.WriteLine("Unable to generate unique hotkey ID. Error code: " + Marshal.GetLastWin32Error());
                return(HotkeyStatus.Failed);
            }

            if (!NativeMethods.RegisterHotKey(Handle, (int)id, (uint)keyInfo.ModifiersEnum, (uint)keyInfo.KeyCode))
            {
                NativeMethods.GlobalDeleteAtom(id);
                DebugHelper.WriteLine("Unable to register hotkey: {0}\r\nError code: {1}", keyInfo, Marshal.GetLastWin32Error());
                return(HotkeyStatus.Failed);
            }

            HotkeyInfo hotkeyInfo = new HotkeyInfo(id, hotkey, hotkeyPress, tag);

            HotkeyList.Add(hotkeyInfo);

            return(HotkeyStatus.Registered);
        }
        public bool UnregisterHotkey(HotkeyInfo hotkeyInfo)
        {
            if (hotkeyInfo != null)
            {
                bool result = UnregisterHotkey(hotkeyInfo.ID);
                HotkeyList.Remove(hotkeyInfo);
                return result;
            }

            return false;
        }
        public HotkeyStatus RegisterHotkey(Keys hotkey, Action hotkeyPress = null, int tag = 0)
        {
            KeyInfo keyInfo = new KeyInfo(hotkey);

            if (keyInfo.KeyCode == Keys.None)
            {
                return HotkeyStatus.NotConfigured;
            }

            if (IsHotkeyExist(hotkey))
            {
                DebugHelper.WriteLine("Hotkey already exist: " + keyInfo);
                return HotkeyStatus.Failed;
            }

            string atomName = Thread.CurrentThread.ManagedThreadId.ToString("X8") + (int)hotkey;

            ushort id = NativeMethods.GlobalAddAtom(atomName);

            if (id == 0)
            {
                DebugHelper.WriteLine("Unable to generate unique hotkey ID. Error code: " + Marshal.GetLastWin32Error());
                return HotkeyStatus.Failed;
            }

            if (!NativeMethods.RegisterHotKey(Handle, (int)id, (uint)keyInfo.ModifiersEnum, (uint)keyInfo.KeyCode))
            {
                NativeMethods.GlobalDeleteAtom(id);
                DebugHelper.WriteLine("Unable to register hotkey: {0}\r\nError code: {1}", keyInfo, Marshal.GetLastWin32Error());
                return HotkeyStatus.Failed;
            }

            HotkeyInfo hotkeyInfo = new HotkeyInfo(id, hotkey, hotkeyPress, tag);
            HotkeyList.Add(hotkeyInfo);

            return HotkeyStatus.Registered;
        }
        public bool UnregisterHotkey(Keys key)
        {
            HotkeyInfo hotkeyInfo = GetHotkeyInfoFromKey(key);

            return(UnregisterHotkey(hotkeyInfo));
        }