先取得当前聊天室的窗口的句柄,然后用如下代码获取该窗口中的所有输入框:<br>uses SHDocVw,MSHTML;<br>procedure GetIETextField(w:longint):TStringList;<br>var i,k:integer;<br> ShellWindow: IShellWindows;<br> IE:IWebBrowser2;<br> IDoc:IHTMLDocument2;<br> spDisp:IDispatch;<br> aInputText:IHTMLInputTextElement;<br> v:OLEVariant;<br> tmpList:TStringList;<br>begin<br> tmpList:=TStringList.Create;<br> ShellWindow:=CoShellWindows.Create;<br> for k:=0 to ShellWindow.Count-1 do<br> begin<br> v:=k;<br> spDisp:=ShellWindow.Item(v);<br> spDisp.QueryInterface(IWEBBROWSER2,IE);<br> if IE=nil then continue;<br> if IE.Get_HWND<>w then continue;<br> IDoc:=IE.Document as IHTMLDocument2;<br> if iDoc=nil then continue;<br> if Idoc.Frames.Length<>0 then continue;<br> for i:=0 to Idoc.all.length-1 do<br> begin<br> if Idoc=nil then Break;<br> spDisp:=Idoc.all.item(i,varEmpty);<br> if SUCCEEDED(spDisp.QueryInterface(IHTMLInputTextElement,aInputText)) then<br> if aInputText.value<>'' then //****//<br> tmpList.add('name:'+aInputText.name+' value:'+aInputText.value);<br> end;<br> break;<br> end;<br> result:=tmpList;<br>end;<br><br>如果要对特定的输入框,只需要在//****//那行进行判断:<br>if aInputText.name='xxxxxxx' then <br>