首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

怎的把数据传递到IE浏览器中所打的网页中对应的输入框内

2012-07-18 
怎样把数据传递到IE浏览器中所打的网页中对应的输入框内?不要使用webbrowser等控件在程序中打开网页的方法

怎样把数据传递到IE浏览器中所打的网页中对应的输入框内?
不要使用webbrowser等控件在程序中打开网页的方法,
网页是在ie浏览器中的。直接操作ie浏览器中网页的输入框,获取和修改其内容。
模拟键盘鼠标 ie接口都可以,有例子么?

[解决办法]
如果有id,根据id找

Delphi(Pascal) code
 var   o:OleVariant;  i:integer;  Doc:IHTMLDocument2;  userinputelement,pwdinputelement,ValidateElement:ihtmlinputelement;begin  Doc:=WebBrowser1.document as ihtmldocument2;  if doc=nil then exit;  userinputelement:=(doc.all.item('payFeeOnlineInfo.productNO',0) as ihtmlinputelement);  userinputelement.value:=ed_ltcode.Text;  userinputelement:=(doc.all.item('payFeeOnlineInfo.productNOAgain',0) as ihtmlinputelement);  userinputelement.value:=ed_ltcode.Text;  userinputelement:=(doc.all.item('payFeeOnlineInfo.checkCode',0) as ihtmlinputelement);  userinputelement.value:=ed_ltyz.Text;  userinputelement:=(doc.all.item('payFeeOnlineInfo.payFee',0) as ihtmlinputelement);  userinputelement.value:=ed_ltprice.Text;  o:=doc.all.item('submit0',0);  state := 101;  o.click;  //o:=doc.all.item('payButton',0);  //o.click;end;
[解决办法]
ie应该没有提供这种接口。

思路:
1. 利用GetActiveWindow取得当前输入框的的handle
2. 给输入框发送wm_gettext取得输入框的值或发送wm_settext设置输入框的值

未测试过。你可以试试
[解决办法]
探讨

从网上找到了一个vc的说法,有delphi的么:

1、通过IE句柄得到IHTMLDocument2接口
http://blog.csdn.net/lion_wing/archive/2006/05/26/756105.aspx
2、通过IHTMLDocumnet2得到网页源代码
http://blog.csdn.net/lion_wing/ar……

热点排行