http://www.delphibbs.com/delphibbs/dispq.asp?lid=551816<br><br>dana的程序<br><br>uses<br> SHDocVw,MSHTML;<br><br>procedure TForm1.Button1Click(Sender:TObject);<br>var<br> ShellWindow: IShellWindows;<br> nCount: integer;<br> spDisp: IDispatch;<br> i,j,X: integer;<br> vi: OleVariant;<br> IE1: IWebBrowser2;<br> IDoc1: IHTMLDocument2;<br> iELC : IHTMLElementCollection ;<br> S,S2 : string;<br> HtmlInputEle : IHTMLInputElement;<br> HtmlSelEle : IHTMLSelectElement;<br>begin<br> ShellWindow := CoShellWindows.Create;<br> nCount := ShellWindow.Count;<br><br> for i := 0 to nCount - 1 do<br> begin<br> vi := i;<br> spDisp := ShellWindow.Item(vi);<br> if spDisp = nil then continue;<br> spDisp.QueryInterface( iWebBrowser2, IE1 );<br> if IE1 <> nil then<br> begin<br> IE1.Document.QueryInterface(IHTMLDocument2,iDoc1);<br> if iDoc1 <> nil then<br> begin<br><br> ielc:=idoc1.Get_all;<br><br> for j:=0 to ielc.length-1 do<br> begin<br> Application.ProcessMessages;<br> spDisp := ielc.item(J, 0);<br> if SUCCEEDED(spDisp.QueryInterface(IHTMLInputElement ,HtmlInputEle))then<br> with HtmlInputEle do<br> begin<br> S2:=Type_;<br> S2:=UpperCase(S2);<br>//我把所有的input都填上 try , checkbox 都打勾<br> if (StrComp(PChar(S2),'TEXT')=0) or (StrComp(PChar(S2),'PASSWORD')=0) then<br> value :='try' //S:=S+#9+Value<br> else if StrComp(PChar(S2),'CHECKBOX')=0 then<br> begin<br> checked := True;<br> end;<br> end;<br> if SUCCEEDED(spDisp.QueryInterface(IHTMLselectelement ,HtmlSelEle))then<br> with HtmlSelEle, Memo1.Lines do<br> begin<br> S:=S+#9+IntToStr(selectedIndex+1); //这个是获取数据了<br> end;<br> end; //END FOR<br> Memo2.Lines.Add(S);<br> exit;<br> end;<br> end;<br> end;<br><br>附:打开一个网页,如www.163.net试试看