但是在构建时 - 调用线程必须是 STA,因为许多 UI 组件在第一个浏览器中都需要这样做。鼠标移动(x, y(
public MainWindow()
{
// Initialize WPF Application UI.
InitializeComponent();
// Create WPF BrowserView component.
browser = BrowserFactory.Create();
browserView = new WPFBrowserView(browser);
// Embed BrowserView component into main layout.
mainLayout.Children.Add(browserView);
browser.FinishLoadingFrameEvent += delegate(object sender, FinishLoadingEventArgs e)
{
if (e.IsMainFrame)
{
int x = 100;
int y = 10;
browser.MouseMove(x, y);
}
};
browserView.Browser.LoadURL("http://google.com");
}
尝试将代码包装在 Dispatcher.BeginInvoke 中。
if (e.IsMainFrame)
{
int x = 100;
int y = 10;
Dispatcher.BeginInvoke(new Action( ()=> {
browser.MouseMove(x, y);
}
}