Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/262.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 向webbrowser控件WPF发送命令_C#_Wpf - Fatal编程技术网

C# 向webbrowser控件WPF发送命令

C# 向webbrowser控件WPF发送命令,c#,wpf,C#,Wpf,我有一个web浏览器控件,用于使用本机Adobe reader插件显示PDF。我想要一个按钮,可以在浏览器中调用读卡器的查找功能(即相当于按CTRL+F) private void browserSearch_Click(object sender, RoutedEventArgs e) { this.browserComponent.Focusable = true; this.browserComponent.Focus(); System.Windows

我有一个web浏览器控件,用于使用本机Adobe reader插件显示PDF。我想要一个按钮,可以在浏览器中调用读卡器的查找功能(即相当于按CTRL+F)

private void browserSearch_Click(object sender, RoutedEventArgs e)
{      
    this.browserComponent.Focusable = true;
    this.browserComponent.Focus();
    System.Windows.Forms.SendKeys.SendWait("^f");
}
这段代码可以工作,但它只在第二次单击时显示“查找”框。
每次,您都必须在弹出“查找”框之前单击两次按钮。

经过多次尝试,这对我很有用:

this.browserComponent.Focusable = true;
this.browserComponent.Focus();

System.Windows.Forms.SendKeys.SendWait("{Tab}");

this.browserComponent.Focus();

System.Windows.Forms.SendKeys.SendWait("^f");

这感觉像是一次黑客攻击,所以最好的解决方案总是受欢迎的。

尝试在Focus和SendWait命令之间插入一个睡眠,可惜这没有帮助