使用WebBrowser WPF控件以编程方式填充某些Web表单

我需要在我的WPF应用程序中的某个网页中预填一些表格(网页在外部网站中),我正在使用WPF WebBrowser控件。

有没有办法做到这一点。

我有一些建议:模拟键盘strocks并使用tab键移动字段,(如何执行此操作)。

编辑

所需的forms是如此复杂,元素的名称是动态的,但它们总是以相同的顺序。

如果您想提交表格,请检查一下

// get the document mshtml.IHTMLDocument2 doc = ((mshtml.HTMLDocumentClass)webBrowser1.Document); // set a variable ((mshtml.IHTMLElement)doc.all.item("q")).setAttribute("value", "my input..."); // click a button ((mshtml.HTMLInputElement)doc.all.item("btnI")).click(); 

命名空间mshtml位于Microsoft.mshtml程序mshtml

只需添加引用Microsoft.mshtml。

希望这可以帮助