Example #1
0
        /**
         * Reads the hotkey string from settings and registers the hotkey combo with windows
         */
        void InitHotkey()
        {
            if (keyHook != null)
            {
                keyHook.UnregisterHotKey();
                keyHook = null;
            }

            var          hotKeyString = QuickCutsUI.Properties.Settings.Default.HotKeyString;
            ModifierKeys modKey;
            Key          regKey;

            if (HotKeyStringConverter.FromString(hotKeyString, out modKey, out regKey))
            {
                try
                {
                    keyHook = new WpfApplicationHotKey.HotKey(modKey, regKey, this);
                    keyHook.HotKeyPressed += new Action <WpfApplicationHotKey.HotKey>(keyHook2_HotKeyPressed);
                }
                catch (Exception ex)
                {
                    var button = MessageBoxButton.OK;
                    var icon   = MessageBoxImage.Warning;
                    MessageBox.Show(this, String.Format("Could not register hotkey '{0}'. {1}", hotKeyString, ex.Message), "Error", button, icon);
                }
            }
            else
            {
                var button = MessageBoxButton.OK;
                var icon   = MessageBoxImage.Warning;
                MessageBox.Show(this, String.Format("Could not load hotkey '{0}'.", hotKeyString), "Error", button, icon);
            }
        }
Example #2
0
        /**
         * Reads the hotkey string from settings and registers the hotkey combo with windows
         */
        void RebuildHotkey()
        {
            if (_keyHook != null)
            {
                _keyHook.UnregisterHotKey();
                _keyHook = null;
            }

            var hotKeyString = JRunUI.Properties.Settings.Default.HotKeyString;
            ModifierKeys modKey;
            Key regKey;

            if (HotKeyString.FromHotKeyString(hotKeyString, out modKey, out regKey))
            {
                try
                {
                    _keyHook = new WpfApplicationHotKey.HotKey(modKey, regKey, this);
                    _keyHook.HotKeyPressed += new Action<WpfApplicationHotKey.HotKey>(_keyHook2_HotKeyPressed);
                }
                catch (Exception ex)
                {
                    var button = MessageBoxButton.OK;
                    var icon = MessageBoxImage.Warning;
                    MessageBox.Show(this, String.Format("Could not register hotkey '{0}'. {1}", hotKeyString, ex.Message), "Error", button, icon);
                }
            }
            else
            {
                var button = MessageBoxButton.OK;
                var icon = MessageBoxImage.Warning;
                MessageBox.Show(this, String.Format("Could not load hotkey '{0}'.", hotKeyString), "Error", button, icon);
            }
        }
Example #3
0
 void keyHook2_HotKeyPressed(WpfApplicationHotKey.HotKey obj)
 {
     OpenConsoleWindow();
 }