为什么会出错-在dotnetbrowser中模拟鼠标时?

时间:2018-09-30 10:55:40

标签: c# wpf dotnetbrowser

但是在构建时-调用线程必须是STA,因为许多UI组件在第一个浏览器中都需要这样做.MouseMove(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");
}

1 个答案:

答案 0 :(得分:0)

尝试将代码包装在Dispatcher.BeginInvoke中。

custom:
  webpack:
    includeModules: true