コード例 #1
0
ファイル: Switcher.cs プロジェクト: vrd/AutoMova
 private void SwitchLayout()
 {
     BeginNewSelection();
     ignoreKeyPress = true;
     LowLevelAdapter.ReleasePressedFnKeys();
     LowLevelAdapter.SetNextKeyboardLayout();
     ignoreKeyPress = false;
 }
コード例 #2
0
ファイル: Switcher.cs プロジェクト: vrd/AutoMova
        private void ConvertLast(string lang)
        {
            Debug.WriteLine($"ConvertLast to {lang}...");
            var fnKeys = LowLevelAdapter.ReleasePressedFnKeys();

            // Fix for apps with autocompletion (i.e. omnibox in Google Chrome browser)
            RemoveSelection();

            ignoreKeyPress = true;

            // Remove last word
            var backspaceCount = autoSwitchingIsGoing ? (currentSelection.Count - 1) : currentSelection.Count;
            var backspaces     = Enumerable.Repeat <Keys>(Keys.Back, backspaceCount);

            foreach (var backspace in backspaces)
            {
                Thread.Sleep(settings.SwitchDelay);
                LowLevelAdapter.SendKeyPress(backspace, false);
            }

            //Change layout
            if (lang == "next")
            {
                LowLevelAdapter.SetNextKeyboardLayout();
            }
            else
            {
                LowLevelAdapter.SetKeyboadLayout(langToLayout[lang]);
            }

            // Type last word in new layout
            foreach (var data in currentSelection)
            {
                Thread.Sleep(settings.SwitchDelay);
                LowLevelAdapter.SendKeyPress(data.KeyCode, data.Shift);
            }

            LowLevelAdapter.PressPressedFnKeys(fnKeys);

            ignoreKeyPress = false;
        }
コード例 #3
0
ファイル: Switcher.cs プロジェクト: vrd/AutoMova
        private void ConvertSelection()
        {
            ignoreKeyPress = true;
            LowLevelAdapter.BackupClipboard();
            var fnKeys = LowLevelAdapter.ReleasePressedFnKeys();

            LowLevelAdapter.SendCopy();
            var selection = Clipboard.GetText();

            LowLevelAdapter.RestoreClipboard();
            if (String.IsNullOrEmpty(selection))
            {
                LowLevelAdapter.PressPressedFnKeys(fnKeys);
                return;
            }

            var keys = new List <Keys>(selection.Length);

            for (var i = 0; i < selection.Length; i++)
            {
                keys.Add(LowLevelAdapter.ToKey(selection[i]));
            }

            LowLevelAdapter.SetNextKeyboardLayout();

            ignoreKeyPress = true;
            foreach (var key in keys)
            {
                Debug.Write(key);
                if (key != Keys.None)
                {
                    LowLevelAdapter.SendKeyPress(key, (key & Keys.Shift) != Keys.None);
                }
            }
            Debug.WriteLine("");

            LowLevelAdapter.PressPressedFnKeys(fnKeys);

            ignoreKeyPress = false;
        }