填写一些网络形式的以编程方式使用web浏览器WP​​F控件 [英] Filling some web form programmatically using WebBrowser WPF control

查看:148
本文介绍了填写一些网络形式的以编程方式使用web浏览器WP​​F控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要$ P $在某些网页在我的WPF应用程序对填充某种形式(该网页是一个外部网站),我使用WPF WebBrowser控件。

I need to pre-fill some form in some web page within my WPF app (The web page is in an external website), i am using WPF WebBrowser control.

是,有一些方法来做到这一点。

Is there are some way to do it.

我有一些建议:模拟键盘strocks,并使用Tab键移动穿过田野,(如何做到这一点)

I have some suggestion: emulating keyboard strocks and use tab key to move through fields, (How to do this).

修改

的期望的形式是如此复杂,元素的名称是动态的,但它们总是以相同的顺序

The desired form is so sophisticated and the names of the elements are dynamic, but they are always in the same order.

推荐答案

如果您要提交你检查这一个形式

if you want to submit a form you check this

     // 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 大会。

只需添加引用Microsoft.mshtml。

Just add reference Microsoft.mshtml.

希望这有助于

这篇关于填写一些网络形式的以编程方式使用web浏览器WP​​F控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆