用SPY看了下,foxmail的邮件输入框有两个,一个是文本的,一个是Internet Explorer_Server的。句柄倒是容易找到,发送也正常。只是在发送文字的时候对窗口类是Internet Explorer_Server的输入框无效,不知道问题在哪。<br><br>测试的代码:<br><br>//这个函数是获取文本类输入框的句柄<br>Function TFrmMain.FindText(Handle:THandle):THandle;<br>var<br> Hwnd_Panel,<br> Hwnd_Panel2,<br> Hwnd_Panel3,<br> Hwnd_Panel4,<br> Hwnd_HtmlEdit,<br> Hwnd_Text:THandle;<br>begin<br> Result:=0;<br> Hwnd_Panel:=FindWindowEx(Handle,0,'TPanel','Panel_Back');<br> if Hwnd_Panel<>0 then<br> begin<br> Hwnd_Panel2:=FindWindowEx(Hwnd_Panel,0,'TPanel',nil);<br> Hwnd_Panel3:=FindWindowEx(Hwnd_Panel2,0,'TPanel','P_Content');<br> Hwnd_Panel4:=FindWindowEx(Hwnd_Panel3,0,'TPanel','P_HtmlText');<br> Hwnd_HtmlEdit:=FindWindowEx(Hwnd_Panel4,0,'TNewDHTMLEdit',nil);<br> Hwnd_Text:=FindWindowEx(Hwnd_HtmlEdit,0,'TZEditor',nil);<br> if (Hwnd_Text<>0) and (IsWindowVisible(Hwnd_Text)) then<br> Result:=Hwnd_Text;<br> end;<br>end;<br><br>//这个函数是获取Internet Explorer_Server窗口类输入框的句柄<br>Function TFrmMain.FindHtml(Handle:THandle):THandle;<br>var<br> Hwnd_Panel,<br> Hwnd_Panel2,<br> Hwnd_Panel3,<br> Hwnd_Panel4,<br> Hwnd_HtmlEdit,<br> Hwnd_Embedding,<br> Hwnd_DocObjectView,<br> Hwnd_IE:THandle;<br>begin<br> Result:=0;<br> Hwnd_Panel:=FindWindowEx(Handle,0,'TPanel','Panel_Back');<br> if Hwnd_Panel<>0 then<br> begin<br> Hwnd_Panel2:=FindWindowEx(Hwnd_Panel,0,'TPanel',nil);<br> Hwnd_Panel3:=FindWindowEx(Hwnd_Panel2,0,'TPanel','P_Content');<br> Hwnd_Panel4:=FindWindowEx(Hwnd_Panel3,0,'TPanel','P_HtmlText');<br> Hwnd_HtmlEdit:=FindWindowEx(Hwnd_Panel4,0,'TNewDHTMLEdit',nil);<br> Hwnd_Embedding:=FindWindowEx(Hwnd_HtmlEdit,0,'Shell Embedding',nil);<br> Hwnd_DocObjectView:=FindWindowEx(Hwnd_Embedding,0,'Shell DocObject View',nil);<br> Hwnd_IE:=FindWindowEx(Hwnd_DocObjectView,0,'Internet Explorer_Server',nil);<br> if (Hwnd_IE<>0) and (IsWindowVisible(Hwnd_IE)) then<br> Result:=Hwnd_IE;<br> end;<br>end;<br><br>Procedure TFrmMain.SendText(Handle:THandle);<br>begin<br> tex_send.SelectAll;<br> SendMessage(tex_send.Handle,WM_COPY,0,0);<br> SendMessage(Handle,WM_PASTE,0,0);<br> //这里对Internet Explorer_Server窗口无效,不知道怎么处理这类窗体<br>end;<br><br>procedure TFrmMain.bt_sendClick(Sender: TObject);<br>var<br> HwndText,HwndHtml,Hwnd:THandle;<br>begin<br> Hwnd:=FindWindowEx(0,0,'TF_compose',nil);//查找发邮件的窗体<br> if Hwnd<>0 then<br> begin<br> HwndText:=FindText(Hwnd);<br> HwndHtml:=FindHtml(Hwnd);<br> if HwndText<>0 then SendText(HwndText)<br> else if HwndHtml<>0 then SendText(HwndHtml);<br> end;<br>end;