下面是从网上找到的。看能不能帮上你!<br>======================<br>unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> Dialogs, Mask, StdCtrls, Buttons, ComCtrls;<br><br>type<br> TForm1 = class(TForm)<br> ListBox1: TListBox;<br> GroupBox1: TGroupBox;<br> Memo1: TMemo;<br> CheckBox1: TCheckBox;<br> Label1: TLabel;<br> BitBtn1: TBitBtn;<br> BitBtn2: TBitBtn;<br> Button1: TButton;<br> Button2: TButton;<br> Edit1: TEdit;<br> StatusBar1: TStatusBar;<br> procedure Button1Click(Sender: TObject);<br> procedure Button2Click(Sender: TObject);<br> procedure ListBox1DblClick(Sender: TObject);<br> procedure FormCreate(Sender: TObject);<br> procedure BitBtn1Click(Sender: TObject);<br> procedure BitBtn2Click(Sender: TObject);<br> procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br><br>sendmsgthread=class(TThread)<br>public<br>procedure execute;override;<br>end;<br><br>var<br> Form1: TForm1;<br> qqformid:hwnd;<br> rid,chishu:integer;<br> mysend:sendmsgthread;<br>implementation<br><br>{$R *.dfm}<br>//找QQ聊天窗口<br>function FqqID(ahwnd:hwnd;w:integer):boolean;stdcall;<br> var wintext,w2
char;<br> begin<br> result:=true;<br> getmem(wintext,100);<br> getmem(w2,102);<br> getwindowtext(ahwnd,wintext,100);<br> w2:=strlcopy(w2,wintext,2);<br> if w2='与' then<br> begin<br> qqformid:=ahwnd;<br> end;<br>end;<br><br>//找到class是richedit的,发文本发给它。<br>function FmsgID(ahwnd:hwnd;w:integer):boolean;stdcall;<br> var wintext,w2
char;<br> begin<br> result:=true;<br> getmem(wintext,100);<br> getmem(w2,102);<br> getclassname(ahwnd,wintext,100);<br> if wintext='RICHEDIT' then<br> begin<br> if form1.CheckBox1.Checked then<br> sendmessage(ahwnd,WM_settext,0,integer(pchar(form1.listbox1.Items[random(form1.listbox1.Count-1)])))<br> else<br> begin<br> if length(form1.memo1.Lines.text)=0 then<br> sendmessage(ahwnd,WM_settext,0,integer(pchar(form1.listbox1.Items[rid])))<br> else<br> sendmessage(ahwnd,WM_settext,0,integer(pchar(form1.Memo1.lines.text)));<br> end;<br><br> end;<br> freemem(wintext);<br> freemem(w2);<br> end;<br><br>//找到发送按钮,点击他。<br>function FsendID(ahwnd:hwnd;w:integer):boolean;stdcall;<br> var wintext,w2
char;<br> begin<br> result:=true;<br> getmem(wintext,100);<br> getmem(w2,102);<br> getwindowtext(ahwnd,wintext,100);<br> if wintext='发送(&S)' then<br> begin<br> sendmessage(ahwnd,bm_click,0,0);<br> end;<br><br>end;<br><br>//用线程发送消息。<br>procedure sendmsgthread.execute;<br>var i:integer;<br>begin<br>qqformid:=0;<br>enumwindows(@fqqid,0);<br>if qqformid<>0 then<br>begin<br>for i:=1 to chishu do<br> begin<br> if terminated then exit;<br> enumchildwindows(qqformid,@fmsgid,0);<br> enumchildwindows(qqformid,@fsendid,0);<br> form1.StatusBar1.Panels.Items[0].Text:='正在发送第'+inttostr(i)+'条信息...';<br> sleep(1500);<br> if rid>=form1.ListBox1.Count-1 then rid:=0;<br> rid:=rid+1<br> end;<br> form1.StatusBar1.Panels.Items[0].Text:='信息已发送完毕';<br> form1.bitbtn1.Enabled:=true;<br> form1.bitbtn2.Enabled:=false;<br> form1.checkbox1.Enabled:=true;<br> form1.memo1.ReadOnly:=false;<br> form1.edit1.ReadOnly:=false;<br><br> end<br> else<br> form1.StatusBar1.Panels.Items[0].Text:='无法找到QQ聊天窗口';<br>end;<br><br><br>//增加列表内容<br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br>f:textfile;<br>begin<br><br> if trim(memo1.Lines.text)<>'' then<br> begin<br> assignfile(f,'qqmsg.txt');<br> append(f);<br> write(f,memo1.lines.text+#13#10'[next]'#13#10);<br> closefile(f);<br> listbox1.Items.Add(memo1.lines.text);<br> memo1.Lines.text:='';<br> end;<br><br><br>end;<br><br>//删除列表一个内容<br>procedure TForm1.Button2Click(Sender: TObject);<br>var<br>i:integer;<br>f:textfile;<br>temp:string;<br>begin<br> assignfile(f,'qqmsg.txt');<br> rewrite(f);<br> listbox1.Items.Delete(listbox1.itemindex);<br> for i:=0 to listbox1.count-1 do<br> begin<br> temp:=listbox1.Items
;<br> write(f,temp+#13#10'[next]'#13#10);<br> end;<br> closefile(f);<br><br><br>end;<br><br><br>//列表被双击时,把选项转入memo<br>procedure TForm1.ListBox1DblClick(Sender: TObject);<br>begin<br>memo1.Lines.text:=listbox1.Items[listbox1.itemindex];<br>end;<br><br>//窗口建立时,把列表读入;<br>procedure TForm1.FormCreate(Sender: TObject);<br>var<br>f:textfile;<br>temp,st:string;<br>begin<br> randomize;<br> assignfile(f,'qqmsg.txt');<br> reset(f);<br> while not eof(f) do<br> begin<br> st:='';<br> temp:='';<br> while (temp<>'[next]') and (not eof(f)) do<br> begin<br> st:=st+temp;<br> readln(f,temp);<br> end;<br> listbox1.Items.Add(st);<br> end;<br> closefile(f);<br>end;<br><br>//开始灌水<br>procedure TForm1.BitBtn1Click(Sender: TObject);<br>begin<br>if strtoint(edit1.text)>0 then<br> begin<br> rid:=0;<br> chishu:=strtoint(edit1.text);<br> mysend:=sendmsgthread.Create(false);<br> bitbtn1.Enabled:=false;<br> bitbtn2.Enabled:=true;<br> checkbox1.Enabled:=false;<br> memo1.ReadOnly:=true;<br> edit1.ReadOnly:=true;<br> end<br> else<br> begin<br><br> end;<br>end;<br><br><br>//停止灌水<br>procedure TForm1.BitBtn2Click(Sender: TObject);<br>begin<br>bitbtn1.Enabled:=true;<br>bitbtn2.Enabled:=false;<br>checkbox1.Enabled:=true;<br>memo1.ReadOnly:=false;<br>edit1.ReadOnly:=false;<br>mysend.Terminate;<br>form1.StatusBar1.Panels.Items[0].Text:='你终止了操作.......';<br><br>end;<br><br>procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);<br>begin<br>application.MessageBox('欢迎你使用QQ灌水机'#13#10#13#10+'技术支持:yzp0755@163.com','再见');<br>end;<br>end.