主要代码如下,主要参考的就是 盒子上面的 灌水机 代码。<br>type<br>sendmsgthread=class(TThread)<br>public<br>procedure execute;override;<br>end;<br><br>var<br> Form1: TForm1;<br> qqformid:hwnd;<br> mysend:sendmsgthread;<br>//找到class是richedit的,发文本发给它。<br>function FmsgID(ahwnd:hwnd;w:integer):boolean;stdcall;<br>var<br> wintext
char;<br>begin<br> result:=true;<br> getmem(wintext,100);<br> getclassname(ahwnd,wintext,100);<br> if wintext='RICHEDIT' then<br> sendmessage(ahwnd,WM_settext,0,integer(pchar(form1.Memo1.lines.text)));<br> freemem(wintext);<br>end;<br><br>//找到发送按钮,点击他。<br>function FsendID(ahwnd:hwnd;w:integer):boolean;stdcall;<br>var<br> wintext
char;<br>begin<br> result:=true;<br> getmem(wintext,100);<br> getwindowtext(ahwnd,wintext,100);<br> if wintext='发送(&S)' then<br> sendmessage(ahwnd,bm_click,0,0);<br> freemem(wintext);<br>end;<br><br>//找QQ聊天窗口<br>function FqqID(ahwnd:hwnd;w:integer):boolean;stdcall;<br>var<br> wintext
char;<br>begin<br> result:=true;<br> getmem(wintext,100);<br> getwindowtext(ahwnd,wintext,100);<br> if wintext='与 '+form1.Edit2.Text+' 聊天中' then<br> begin<br> qqformid:=ahwnd;<br> enumchildwindows(qqformid,@fmsgid,0);<br> enumchildwindows(qqformid,@fsendid,0);<br> end;<br>end;<br>//用线程发送消息。<br>procedure sendmsgthread.execute;<br>var<br> i:integer;<br>begin<br> FreeOnTerminate:=True;<br> for i:=1 to strtoint(Form1.Edit1.text) do<br> begin<br> if terminated then exit;<br> qqformid:=0;<br> enumwindows(@fqqid,0);<br> if qqformid=0 then<br> begin<br> Messagebox(0,'没有找到对话模式窗口','注意',0);<br> form1.button2.Enabled:=false;<br> form1.button1.Enabled:=true;<br> exit;<br> end;<br> sleep(StrToInt(form1.Edit3.text));//暂停时间<br> end;<br> form1.button1.Enabled:=true;<br> form1.button2.Enabled:=false;<br>end;<br>//sendmsgthread.Create(false);即可启动线程