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

 

posted @ 2015-12-28 17:30  倾国倾城何为倾  阅读(458)  评论(0编辑  收藏  举报