我正在尝试为浏览器控件发送击键 (Ctrl + t)。但是,SendKeys.Send()
在 WPF 应用程序中显示错误?
我的问题是:
- 我可以在 WPF 应用程序中使用
SendKeys.Send()
方法吗? - 是否有发送自动击键的替代方法?
最佳答案
SendKeys 是 System.Windows.Forms 命名空间的一部分,在 Wpf 中没有等效的方法。您不能将 SendKeys.Send 与 WPF 一起使用,但可以使用 SendKeys.SendWait方法,如果您将 System.Windows.Forms 添加到项目引用中。您唯一的其他选择是 PInvoke SendInput .
请注意,这两种方法都会将数据发送到当前事件的窗口。
关于c# - WPF 应用程序中的 SendKeys.Send 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11572411/