Unit1.cpp
资源名称:QQ消息自动发送器.rar [点击查看]
上传用户:icamtech04
上传日期:2007-03-13
资源大小:278k
文件大小:5k
源码类别:
ICQ弱点检测代码
开发平台:
C++ Builder
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #pragma hdrstop
- #include <Clipbrd.hpp>
- #include "Unit1.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma link "EditValue"
- #pragma resource "*.dfm"
- TForm1 *Form1;
- HANDLE parent; //RICHEDIT的父窗口句柄
- HANDLE rich; //RICHEDIT的句柄
- HANDLE rich_s; //用于查找 RICHEDIT
- HANDLE hSend_s; //用于查找 发送 按钮
- HANDLE hSend; //保存发送按钮句柄
- static bool anniu = true;
- static int index1 = 0;
- bool CALLBACK EnumProc(HWND,long); //枚举窗口
- bool CALLBACK EnumChildProc(HWND,LPARAM); //枚举子窗口
- struct Node //设置一结构,用于保存聊天窗口,RICHEDIT和发送句柄
- {
- HANDLE Savehwnd[20];
- HANDLE Saverich[20];
- HANDLE SavehSend[20];
- }Saveinfo;
- //---------------------------------------------------------------------------
- __fastcall TForm1::TForm1(TComponent* Owner)
- : TForm(Owner)
- {
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button2Click(TObject *Sender)
- {
- Close();
- }
- //---------------------------------------------------------------------------
- bool CALLBACK EnumProc(HWND hwnd,long lp)
- {
- char biaoti[80];
- GetWindowText(hwnd,biaoti,81);
- if ( AnsiString(biaoti).Pos("与") || AnsiString(biaoti).Pos("群"))
- { //判断标题是否是QQ聊天窗口,如果你还开着其他窗口与这样的查找设置巧合
- //的话。。。。。。 唉~~
- Form1->ComboBox1->Items->Add(biaoti);
- Saveinfo.Savehwnd[index1++] = hwnd; //保存聊天窗口句柄
- }
- EnumChildWindows(hwnd,reinterpret_cast<WNDENUMPROC>(EnumChildProc),0L);
- return true;
- }
- bool CALLBACK EnumChildProc(HWND hwnd,LPARAM lParam)
- {
- char buf[80];
- GetClassName(hwnd, buf, sizeof(buf));
- hSend_s = FindWindowEx(hwnd, NULL, "Button", "发送(&S)");
- if (hSend_s != NULL)
- {
- Saveinfo.SavehSend[index1-1] = hSend_s;
- hSend = hSend_s;
- }
- if ( AnsiString(buf).Pos("AfxWnd42") )
- { //QQ发送消息的RICHEDIT的父窗口类名是 AfxWnd42
- parent = hwnd;
- rich_s = FindWindowEx(parent, NULL, "RICHEDIT",0);
- if (GetParent(rich_s) == parent) //RICHEDIT类名有很多,关键看他的父窗口是否是AfxWnd42
- {
- Saveinfo.Saverich[index1-1] = rich_s;
- }
- return true;
- }
- else
- {
- EnumChildWindows(hwnd,reinterpret_cast<WNDENUMPROC>(EnumChildProc),0L);
- return true;
- }
- }
- void __fastcall TForm1::FormCreate(TObject *Sender)
- {
- EnumWindows(reinterpret_cast<WNDENUMPROC>(EnumProc),0L);
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Timer1Timer(TObject *Sender)
- {
- RichEdit1->SelectAll(); //本程序的‘消息内容’全选
- RichEdit1->CopyToClipboard(); //复制到剪贴板
- if (IsWindow(Saveinfo.Savehwnd[ComboBox1->ItemIndex])) //判断句柄是否有效
- {
- SendMessage(Saveinfo.Saverich[ComboBox1->ItemIndex], WM_PASTE, 0, 0);
- SendMessage(Saveinfo.SavehSend[ComboBox1->ItemIndex],WM_LBUTTONDOWN,MK_LBUTTON ,0);
- SendMessage(Saveinfo.SavehSend[ComboBox1->ItemIndex],WM_LBUTTONUP,MK_LBUTTON,0);
- }
- else
- {
- Timer1->Enabled = false;
- ShowMessage("该聊天窗口已经无效了!");
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button1Click(TObject *Sender)
- {
- if (anniu)
- {
- if (ComboBox1->GetTextLen() !=0 ) //判断是否选择了窗口
- {
- Button1->Caption = "停止";
- Timer1->Enabled = true;
- int x = StrToInt(Edit2->Text);
- if (x<500 )
- { //时间间隔太小的话对网速不利,限制在500ms
- ShowMessage("时间间隔太小,最好不低于500ms");
- x = 500;
- }
- Timer1->Interval = x;
- }
- else
- {
- ShowMessage("没有找到QQ聊天窗口");
- return;
- }
- }
- else
- {
- Button1->Caption = "发送";
- Timer1->Enabled = false;
- }
- anniu = !anniu;
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button3Click(TObject *Sender)
- { //重新找窗口时做的事情
- index1 = 0;
- ComboBox1->Items->Clear();
- ComboBox1->Text = "";
- ::EnumWindows(reinterpret_cast<WNDENUMPROC>(EnumProc),0L);
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Edit2KeyPress(TObject *Sender, char &Key)
- { //只容许‘发生时间间隔’ 的输入为数字,原本这个编辑已有禁止输入字符的功能了
- if (Key == (char)'.')
- Key =0;
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::ComboBox1KeyPress(TObject *Sender, char &Key)
- { //禁止向ComboBox1输入字符,只容许选择
- Key = 0;
- }
- //---------------------------------------------------------------------------