WPF-模拟键盘输入
public static void SendToUIThread(UIElement element, string text) { element.Dispatcher.BeginInvoke( new Action(() => { SendKeys.SendWait(text); }), DispatcherPriority.Input ); } //后台调用 private void Key_Click(object sender, RoutedEventArgs e) { Button btn = (Button)sender; Model.VM_Key.SendToUIThread((UIElement)Keyboard.FocusedElement, btn.Content.ToString()); }