再问此问题:“如何向IE中的文本框发送文字或字符”(100分)

  • 主题发起人 主题发起人 fxb
  • 开始时间 开始时间
F

fxb

Unregistered / Unconfirmed
GUEST, unregistred user!
如何向IE中的文本框发送文字或字符
 
如果用JAVASCRIPT写是:window.document.form.text.value="text";
 
这个问题已经回答过了啊。这是找到的:<br>dana, 时间:2001-6-3 17:44:52, ID:552324 &nbsp;<br>哇!真给一百分,那就告诉你吧!快给分。<br>procedure TForm1.PutData;<br>var<br>&nbsp; ShellWindow: IShellWindows;<br>&nbsp; nCount: integer;<br>&nbsp; spDisp: IDispatch;<br>&nbsp; i,j,X: integer;<br>&nbsp; vi: OleVariant;<br>&nbsp; IE1: IWebBrowser2;<br>&nbsp; IDoc1: IHTMLDocument2;<br>&nbsp; iELC &nbsp;: IHTMLElementCollection ;<br>&nbsp; S,S2 : string;<br>&nbsp; HtmlInputEle : IHTMLInputElement;<br>&nbsp; HtmlSelEle &nbsp; : IHTMLSelectElement;<br>begin<br>&nbsp; ShellWindow := CoShellWindows.Create;<br>&nbsp; nCount := ShellWindow.Count;<br><br>&nbsp; for i := 0 to nCount - 1 do<br>&nbsp; begin<br>&nbsp; &nbsp; vi := i;<br>&nbsp; &nbsp; spDisp := ShellWindow.Item(vi);<br>&nbsp; &nbsp; if spDisp = nil then continue;<br>&nbsp; &nbsp; spDisp.QueryInterface( iWebBrowser2, IE1 );<br>&nbsp; &nbsp; if IE1 &lt;&gt; nil then<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; IE1.Document.QueryInterface(IHTMLDocument2,iDoc1);<br>&nbsp; &nbsp; &nbsp; if iDoc1 &lt;&gt; nil then<br>&nbsp; &nbsp; &nbsp; begin<br><br>&nbsp; &nbsp; &nbsp; &nbsp; ielc:=idoc1.Get_all;<br><br>&nbsp; &nbsp; &nbsp; &nbsp; for j:=0 to ielc.length-1 do<br>&nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Application.ProcessMessages;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; spDisp := ielc.item(J, 0);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if SUCCEEDED(spDisp.QueryInterface(IHTMLInputElement ,HtmlInputEle))then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; with HtmlInputEle do<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; S2:=Type_;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; S2:=UpperCase(S2);<br>//我把所有的input都填上 try , checkbox 都打勾<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (StrComp(PChar(S2),'TEXT')=0) or (StrComp(PChar(S2),'PASSWORD')=0) then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; value :='try' //S:=S+#9+Value<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if StrComp(PChar(S2),'CHECKBOX')=0 then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; checked := True;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if SUCCEEDED(spDisp.QueryInterface(IHTMLselectelement ,HtmlSelEle))then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; with HtmlSelEle, Memo1.Lines do<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; S:=S+#9+IntToStr(selectedIndex+1); &nbsp;//这个是获取数据了<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; end; &nbsp;//END FOR<br>&nbsp; &nbsp; &nbsp; &nbsp; Memo2.Lines.Add(S);<br>&nbsp; &nbsp; &nbsp; &nbsp; exit;<br>&nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; end;<br>&nbsp; end;<br>end;<br>&nbsp;<br>
 
那么如何模拟点击按钮呢?<br>如果有办法, 我也出点血,给500分 :)
 
TO:Town<br>发送文字之后,文本框是聚焦的。<br>发送回车看看。<br>&nbsp; keybd_event(13, MapVirtualKey(13, 0), 0, 0);<br>&nbsp; keybd_event(13, MapVirtualKey(13, 0), KEYEVENTF_KEYUP, 0);
 
^_^,知道了, 用 form.submit &nbsp;:)<br><br>
 
请问上面的“ &nbsp; <br>&nbsp; Doc1: IHTMLDocument2;<br>&nbsp; iELC &nbsp;: IHTMLElementCollection ;<br>&nbsp; HtmlInputEle : IHTMLInputElement;<br>&nbsp; HtmlSelEle &nbsp; : IHTMLSelectElement;”<br>要在接口单元加入什么控件才能编译通过?<br>
 
D6中,uses mshtml单元~~~~~`这个问题应该自己解决才对!!!<br>难道你现在还不知道应该Uses单元吗?
 
&gt;来自:Town, 时间:2001-12-29 11:14:00, ID:820727 <br>&gt;那么如何模拟点击按钮呢?<br>&gt;如果有办法, 我也出点血,给500分 :)<br>&nbsp;<br>IHTMLElement::click
 
mshtml,shdocvw<br><br>Kingron大侠: &nbsp;是不是动态产生的input无法填入啊? 比如大富翁的input就无法填入内容,<br>如何处理? &nbsp;谢谢啦 :)
 
还有, 当打开多个窗口时,好像就不灵了,如何确定往指定窗口填入内容啊?
 
奇怪,不会啊,我记得当初我测试这段代码,就是在DFW页面上面测试的,可以的。<br>你在Try?至于多个窗口,我想你可以自己分析一下,判断是那个窗口就可以了。<br>这个应该不需要我来吐口水吧?
 
那如果是 TEXTAREA 如何插入数据!
 
后退
顶部