下面是论坛上一为朋友发的帖子,我想你应该是这个意思.<br>先发给你,免得你去找了.<br><br>unit OicqSendForm;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br> StdCtrls, Buttons, ExtCtrls;<br><br>type<br> TfrmMain = class(TForm)<br> memText: TMemo;<br> edtTime: TEdit;<br> Label1: TLabel;<br> Bevel1: TBevel;<br> Label2: TLabel;<br> bbtnStart: TBitBtn;<br> bbtnEnd: TBitBtn;<br> bbtnHelp: TBitBtn;<br> Timer: TTimer;<br> procedure bbtnStartClick(Sender: TObject);<br> procedure bbtnEndClick(Sender: TObject);<br> procedure TimerTimer(Sender: TObject);<br> procedure bbtnHelpClick(Sender: TObject);<br> private<br> { Private declarations }<br> FTextHandle: HWND; //qq消息输入框句柄<br> FButtonHandle: HWND; //发送按钮输入框<br> public<br> { Public declarations }<br> end;<br><br>var<br> frmMain: TfrmMain;<br><br>implementation<br><br><br>//这个函数取当前qq发送窗口上“送讯息”的按钮的句柄<br>//function EnumChildWindowsProc(hwnd: Integer; lparam: Longint):Boolean; stdcall;<br>function GetButtonHandle(hwnd: Integer; lparam: Longint):Boolean; stdcall;<br>var<br> buffer: array[0..255] of Char;<br> buffer1: array[0..255] of Char;<br>begin<br> Result := True;<br> //得到目标窗口的控件<br> GetClassName(hwnd,buffer,256);<br> //找到发消息的目标窗口的目标控件<br> if StrPas(Buffer)='Button' then<br> begin<br> GetWindowText(hwnd,buffer1,100);<br> if buffer1 = '送讯息(&S)' then<br> begin<br> PInteger(lparam)^ := hwnd; //得到目标控件的Hwnd(句柄)<br> Result:=False; //终止循环<br> end;<br> end;<br>end;//end of function<br><br>//这个函数取当前qq发送窗口上消息框句柄<br>//function EnumChildWindowsProc(hwnd: Integer; lparam: Longint):Boolean; stdcall;<br>function GetEditHandle(hwnd: Integer; lparam: Longint):Boolean; stdcall;<br>var<br> buffer: array[0..255] of Char;<br> buffer1: array[0..255] of Char;<br>begin<br> Result := True;<br> //得到目标窗口的控件<br> GetClassName(hwnd,buffer,256);<br> //找到发消息的目标窗口的目标控件<br> if StrPas(Buffer)='Edit' then<br> begin<br> GetWindowText(hwnd,buffer1,100);<br> PInteger(lparam)^ := hwnd; //得到目标控件的Hwnd(句柄)<br> Result:=False; //终止循环<br> end;<br>end;//end of function<br><br>{$R *.DFM}<br><br>procedure TfrmMain.bbtnStartClick(Sender: TObject);<br>var<br> Handle: Integer;<br> tmpHandle: Integer;<br>begin<br> {取句柄}<br> Handle := FindWindow(nil,'对话模式'); //就是窗口的Caption<br> if Handle<>0 then<br> begin<br> tmpHandle := Handle;<br> //在这里循环取到想要的句柄为止<br> //取发送按钮的,FButtonHandle<br> EnumChildWindows(Handle,@GetButtonHandle,Integer(@Handle));<br> FButtonHandle := Handle;<br><br> //取消息输入框的,FTextHandle<br> EnumChildWindows(tmpHandle,@GetEditHandle,Integer(@tmpHandle));<br> FTextHandle := tmpHandle;<br><br> Timer.Interval := StrToInt(edtTime.Text);<br> Timer.Enabled := true;<br> end;//end of if<br><br>end;<br><br>procedure TfrmMain.bbtnEndClick(Sender: TObject);<br>begin<br> Timer.Enabled := false;//关闭定时器<br>end;<br><br>procedure TfrmMain.TimerTimer(Sender: TObject);<br>begin<br> {定时发送}<br> //设发送文本<br> SendMessage(FTextHandle,WM_SETTEXT,0,Integer(pchar(memText.Text)));<br><br> //发送按钮<br> //SendMessage(FButtonHandle,BN_CLICKED,0,0);<br> SendMessage(FButtonHandle,WM_LBUTTONDOWN,0,0);<br> SendMessage(FButtonHandle,WM_LBUTTONUP,0,0);<br>end;<br><br>procedure TfrmMain.bbtnHelpClick(Sender: TObject);<br>var<br> sHelp: String;<br>begin<br> //帮助<br> sHelp := '打开要发送的对象窗口'+#13+<br> '选择对话模式后点[开始]!';<br> ShowMessage(sHelp); <br><br>end;<br><br>end.