Exemplo n.º 1
0
        private void RemoveHotKey(HotKeyCombination combination, ref GlobalHotKey globalHotKey)
        {
            try
            {
                combination.ClearKeys();

                if (globalHotKey != null)
                {
                    _HotKeyManager.RemoveGlobalHotKey(globalHotKey);
                }
            }
            catch (Exception e)
            {
                Logger.WriteLog(e);
            }
        }
Exemplo n.º 2
0
        private void RegisterHotKeyDown(ref GlobalHotKey globalHotKey, HotKeyCombination hotKeyCombination, TextBox textBox, KeyEventArgs e)
        {
            try
            {
                var _key = Helper.RealKey(e);

                var pressedKeys = Keys.GetPressdKeys();

                pressedKeys = Keys.ClearRepeatedKeys(pressedKeys);

                pressedKeys = Keys.ClearMousKeys(pressedKeys);

                if (pressedKeys.Length <= 1)
                {
                    hotKeyCombination.ClearKeys();
                }

                hotKeyCombination.AddKey(_key);

                string str = _EmptyHKString;
                if (hotKeyCombination.IsInitialized)
                {
                    str = hotKeyCombination.CombinationKeysName();

                    textBox.Text = str;
                }
                else
                {
                    if (globalHotKey != null)
                    {
                        _HotKeyManager.RemoveGlobalHotKey(globalHotKey);
                    }
                }
                textBox.Text = str;
            }
            catch (Exception ex)
            {
                Logger.WriteLog(ex);
            }
        }
        private void RegisterHotKeyDown(ref GlobalHotKey globalHotKey, HotKeyCombination hotKeyCombination, KeyEventArgs e)
        {
            if (_disposed)
            {
                return;
            }

            try
            {
                var _key = Helper.RealKey(e);

                var pressedKeys = Keys.GetPressdKeys();

                pressedKeys = Keys.ClearRepeatedKeys(pressedKeys);

                pressedKeys = Keys.ClearMousKeys(pressedKeys);

                if (pressedKeys.Length <= 1)
                {
                    hotKeyCombination.ClearKeys();
                }

                hotKeyCombination.AddKey(_key);

                if (!hotKeyCombination.IsInitialized)
                {
                    if (globalHotKey != null)
                    {
                        _HotKeyManager.RemoveGlobalHotKey(globalHotKey);
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.WriteLog(ex);
            }
        }