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; }