Esempio n. 1
0
        // Hotkey triggered
        void Hook_KeyPressed(object sender, KeyPressedEventArgs e)
        {
            List <string> keyBindList = KeyBind.GetKeyBindList();

            foreach (string keyBind in keyBindList)
            {
                string[] lineStrs    = keyBind.Split(',');
                string   inputMethod = lineStrs[0];
                string   culture     = lineStrs[1];
                string   key         = lineStrs[2];
                if (key.Equals(e.Key.ToString()))
                {
                    ChangeInputMethod(inputMethod, culture);
                }
            }
        }
Esempio n. 2
0
        private void TurnOn()
        {
            List <string> keyBindList = KeyBind.GetKeyBindList();

            foreach (string keyBind in keyBindList)
            {
                string[] lineStrs    = keyBind.Split(',');
                string   inputMethod = lineStrs[0];
                string   culture     = lineStrs[1];
                string   keyStr      = lineStrs[2];

                Hook keyboardHook = new Hook();
                keyboardHook.KeyPressed += new EventHandler <KeyPressedEventArgs>(Hook_KeyPressed);

                // Register hotkey
                try { keyboardHook.RegisterHotKey(InputMethodQuickSwitcher.ModifierKeys.None, (Keys)Enum.Parse(typeof(Keys), keyStr)); }
                catch (Exception ex) { MessageBox.Show(ex.Message, "Message"); TurnOff(); return; }

                _KeyboardHookList.Add(keyboardHook);
                _StatusOnOff = true;
            }
        }