看看这个偶写的自动发qq或uc消息的(要打开对聊),发送表情的没有写完<br>可能对你有用<br>unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> Dialogs, Buttons, StdCtrls, ExtCtrls,SHELLAPI;<br><br>type<br> TForm1 = class(TForm)<br> Panel1: TPanel;<br> RadioGroup1: TRadioGroup;<br> RB_QQ: TRadioButton;<br> RB_UC: TRadioButton;<br> Edit_QQ: TEdit;<br> Edit_uc: TEdit;<br> GroupBox1: TGroupBox;<br> Memo1: TMemo;<br> Panel2: TPanel;<br> Sbtn_send: TSpeedButton;<br> Sbtn_stop: TSpeedButton;<br> Sbtn_close: TSpeedButton;<br> StaticText1: TStaticText;<br> Ed_time: TEdit;<br> Timer1: TTimer;<br> GroupBox2: TGroupBox;<br> StaticText2: TStaticText;<br> CBox_QQ: TComboBox;<br> CBox_UC: TComboBox;<br> Button1: TButton;<br> procedure RB_QQClick(Sender: TObject);<br> procedure Sbtn_sendClick(Sender: TObject);<br> procedure Ed_timeKeyPress(Sender: TObject; var Key: Char);<br> procedure Sbtn_closeClick(Sender: TObject);<br> procedure Timer1Timer(Sender: TObject);<br> procedure Sbtn_stopClick(Sender: TObject);<br> procedure FormClose(Sender: TObject; var Action: TCloseAction);<br> procedure Button1Click(Sender: TObject);<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br><br>var<br> Form1: TForm1;<br> edit_hd,btn_hd,edit_hd1,myqq:Thandle;<br> str_send:string;<br> qqbq:array[0..49] of string=('/jy','/pz','/se','/fd','/dy','/ll','/hx','/bz',<br> '/shui','/dk','/gg','/fn','/tp','/cy','/wx', '/ng','/ku','/feid',<br> '/zk','/tu','/jk','/lh','/hanx','/db','/shan','/fad','/zt','/xg','/maom','/yb',<br> '/gf','/fan','/yw','/mg','/dx','/wen','/xin','/xs','/hy','/lw','/dh','/sj',<br> '/yj','/ds','/ty','/yl','/qiang','/ruo','/ws','/bb');<br> ucbq:array[0..62] of string=('~!','~@','~#','~$','~%','~^','~&','~*','~(','~)','~-',<br> '~=','~+','~|','~/','!@','!#','!$','!%','!^','!&','!*',<br> '!(','!)','!_','!+','!|','@~','@!','@#','@$','@%','@^',<br> '@*','@(','@)','@_','@+','@|','#~','#!','#@','##','#$',<br> '#%','#^','#&','#*','#(','#)','#_','#+','#|','$~','$!',<br> '$@','$#','$$','$%','$^','$&','$*','$(');<br>implementation<br><br>{$R *.dfm}<br><br>procedure TForm1.RB_QQClick(Sender: TObject);<br>begin<br> if TRadioButton(sender).Name='RB_QQ' then begin<br> if TRadioButton(sender).Checked then begin<br> Edit_QQ.Enabled:=true;<br> Edit_UC.Enabled:=false;<br> end else<br> Edit_QQ.Enabled:=false;<br> end else begin<br> if TRadioButton(sender).Checked then begin<br> Edit_UC.Enabled:=true;<br> Edit_QQ.Enabled:=false;<br> end else<br> Edit_UC.Enabled:=false;<br> end;<br>end;<br>function EnumProc(Hwnd: THandle;lparam: LPARAM): boolean; stdcall;<br>var<br>lpText,txt: Array[0..255] of char;<br>begin<br>Result := true;<br>GetClassName(hwnd,@lpText,255);<br>{form1.Memo1.Lines.Add(string(lptext));<br>form1.Memo1.Lines.Add(' ');<br>GetWindowText(HWnd,@lptext,255);<br>form1.Memo1.Lines.Add(string(lptext)); }<br>if form1.RB_QQ.Checked then begin<br> if LowerCase(lptext)='richedit' then<br> begin<br> if edit_hd=0 then<br> edit_hd := HWnd<br> else<br> edit_hd1 := HWnd;<br> end;<br> if LowerCase(lptext)='button' then begin<br> GetWindowText(HWnd,@txt,255);<br> if txt='发送(&S)' then<br> btn_hd:= HWnd;<br> end;<br> if LowerCase(lptext)='static' then begin<br> GetWindowText(HWnd,@txt,255);<br> if txt='QQ:103301880' then<br> myqq:= HWnd;<br> end;<br>end else begin<br> if LowerCase(lptext)='tucpredit' then<br> begin<br> edit_hd := HWnd;<br> end;<br> if LowerCase(lptext)='tucbutton' then begin<br> GetWindowText(HWnd,@txt,255);<br> if txt='发送(&S)' then<br> btn_hd:= HWnd;<br> end;<br> if LowerCase(lptext)='tedit' then begin<br> GetWindowText(HWnd,@txt,255);<br> if txt='45778742' then<br> myqq:= HWnd;<br> end;<br>end ;<br> result:=true;<br>end;<br><br>procedure TForm1.Sbtn_sendClick(Sender: TObject);<br>var<br> w_hd:Thandle;<br> i:integer;<br> str_title:string;<br>begin<br>edit_hd:=0;<br>btn_hd:=0;<br>edit_hd1:=0;<br>myqq:=0;<br> if RB_QQ.Checked then<br> str_title:=edit_qq.Text<br> else if RB_UC.Checked then<br> str_title:=edit_UC.Text<br> else begin<br> application.MessageBox('请选择骚扰对象!','提示',MB_ICONINFORMATION+MB_OK);<br> exit;<br> end;<br> W_hd:=FindWIndow(nil,pchar(str_title));<br> if W_hd=0 then begin<br> application.MessageBox('对象不存在!','提示',MB_ICONWARNING+MB_OK);<br> exit;<br> end;<br> if trim(Memo1.Text)='' then begin<br> application.MessageBox('请输入发送内容!','提示',MB_ICONINFORMATION+MB_OK);<br> exit;<br> end else<br> str_send:=memo1.Text;<br> EnumChildWindows(W_hd, @EnumProc,Longint(Self));<br> if (edit_hd<>0)and(btn_hd<>0) then<br> begin<br> if trim(Ed_time.Text)='' then i:=1<br> else begin<br> try<br> i:=strtoint(Ed_time.Text);<br> except<br> application.MessageBox('输入的时间不是整数!','错误',MB_ICONERROR+MB_OK);<br> exit;<br> end;<br> end;<br> if myqq<>0 then begin<br> application.MessageBox('不想混了呀,作者你也敢骚扰!!!','警告',MB_ICONWARNING+MB_OK);<br> exit;<br> end;<br> Timer1.Interval:=i*1000;<br> Timer1.Enabled:=true;<br> Sbtn_send.Enabled:=false;<br> RB_QQ.Enabled:=false;<br> RB_UC.Enabled:=false;<br> Sbtn_stop.Enabled:=true;<br> end else<br> application.MessageBox('未知错误!','提示',MB_ICONERROR+MB_OK);<br>end;<br><br>procedure TForm1.Ed_timeKeyPress(Sender: TObject; var Key: Char);<br>begin<br> if not(key in ['0'..'9']) then key:=#0;<br>end;<br><br>procedure TForm1.Sbtn_closeClick(Sender: TObject);<br>begin<br>close;<br>end;<br><br>procedure TForm1.Timer1Timer(Sender: TObject);<br>begin<br> sendMessage(edit_hd,WM_SETTEXT,0,Integer(pchar(str_send)));<br> if RB_QQ.Checked then begin<br> sendMessage(edit_hd1,WM_SETTEXT,0,Integer(pchar(str_send)));<br> sendMessage(btn_hd,BM_CLICK,0,0);<br> end else<br> SendMessage(btn_hd,WM_KEYDOWN,VK_RETURN,0);<br>end;<br><br>procedure TForm1.Sbtn_stopClick(Sender: TObject);<br>begin<br> Timer1.Enabled:=false;<br> Sbtn_send.Enabled:=true;<br> Sbtn_stop.Enabled:=false;<br> RB_QQ.Enabled:=true;<br> RB_UC.Enabled:=true;<br>end;<br><br>procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);<br>begin<br>timer1.Enabled:=false;<br>end;<br>function EnumProc1(Hwnd: THandle;lparam: LPARAM): boolean; stdcall;<br>var<br>lpText: Array[0..255] of char;<br>begin<br>Result := true;<br>GetClassName(hwnd,@lpText,255);<br>form1.Memo1.Lines.Add(string(lptext));<br>GetWindowText(HWnd,@lptext,255);<br>form1.Memo1.Lines.Add(string(lptext));<br>end;<br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br> hd:thandle;<br>begin<br> hd:=FindWIndow(nil,'QQ') ;<br> EnumChildWindows(hd, @EnumProc1,Longint(Self));<br>end;<br><br>end.