private void ConvertSelection() { LowLevelAdapter.BackupClipboard(); LowLevelAdapter.SendCopy(); var selection = Clipboard.GetText(); LowLevelAdapter.RestoreClipboard(); if (String.IsNullOrEmpty(selection)) { return; } LowLevelAdapter.ReleasePressedFnKeys(); var keys = new List <Keys>(selection.Length); for (var i = 0; i < selection.Length; i++) { keys.Add(LowLevelAdapter.ToKey(selection[i])); } LowLevelAdapter.SetNextKeyboardLayout(); foreach (var key in keys) { Debug.Write(key); if (key != Keys.None) { LowLevelAdapter.SendKeyPress(key, (key & Keys.Shift) != Keys.None); } } }
private void ConvertLast() { LowLevelAdapter.ReleasePressedFnKeys(); var word = currentWord.ToList(); var backspaces = Enumerable.Repeat<Keys>(Keys.Back, word.Count); foreach (var vkCode in backspaces) { LowLevelAdapter.SendKeyPress(vkCode, false); } // funny fix for my skype Thread.Sleep(20); LowLevelAdapter.SetNextKeyboardLayout(); foreach (var data in word) { LowLevelAdapter.SendKeyPress(data.KeyCode, data.Shift); } }
private void OnKeyPress(KeyboardEventArgs evtData) { var vkCode = evtData.KeyCode; if (evtData.Equals(SwitchHotkey)) { ConvertLast(); evtData.Handled = true; return; } if (evtData.Equals(AdditionalSwitch)) { LowLevelAdapter.SetNextKeyboardLayout(); evtData.Handled = true; return; } if (SwitchToLocale.Keys.Any(t=>t.Equals(evtData))) { uint locale = SwitchToLocale.First(t=>Equals(t.Key, evtData)).Value; LowLevelAdapter.SetLayout(locale); } if (evtData.Equals(ConvertSelectionHotkey)) { ConvertSelection(); } if (this.HaveTrackingKeys(evtData)) return; var notModified = !this.HaveModifiers(evtData); if (vkCode == Keys.Space && notModified) { AddToCurrentWord(evtData); return; } if (vkCode == Keys.Back && notModified) { RemoveLast(); return; } if (IsPrintable(evtData)) { if (GetPreviousVkCode() == Keys.Space) { BeginNewWord(); } AddToCurrentWord(evtData); return; } // default: BeginNewWord(); }
private void SwitchLayout() { BeginNewWord(); LowLevelAdapter.SetNextKeyboardLayout(); }