QQ2000 的聊天室刷屏机设计技术
生活随笔
收集整理的這篇文章主要介紹了
QQ2000 的聊天室刷屏机设计技术
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
program chat2001;
uses
?windows,messages,sysutils;
{$R *.RES}
const
?CRLF=#13#10;
?exename:pchar='刷屏機器人 2001';
var
//----------------------
?wClass: ? TWndClass; ? //窗口類變量
?Msg: ? ? ?TMSG; ? ? ? ?//消息變量
?hInst, ? ? ? ? ? ? ? ? //程序實例
?Handle, ? ? ? ? ? ? ? ?//主窗口句柄
?hFont, ? ? ? ? ? ? ? ? //字體句柄
//----------------
?hButtonStart, ? //開始按鈕
?hButtonStop, ? ?//停止按鈕
?hButtonHelp, ? ?//幫助按鈕
?hButtonExit, ? ?//退出按鈕
?hEditEmail, ? ? //e-mail編輯
?hLabelEmail, ? ? //e-mail提示
?mcount,tempwnd,qqmainw,richedit:integer;
?lp:longint;
?newtime:integer;
//--------------------
//往一個窗口寫標題
procedure WriteCaption(hwnd:hwnd;text:pchar);begin sendmessage(hwnd,WM_SETTEXT,0,integer(text));end;
//從一個窗口讀標題
procedure ReadCaption(hwnd:hwnd;text:pchar);begin sendmessage(hwnd,WM_GETTEXT,400,integer(text));end;
procedure ButtonHelp;
var s1:string;
begin
?s1:='本軟件只用學習用,不可害人'+CRLF+
? ? ?'程序向QQ2000B的輸入框中輸入文字并發送!'+CRLF+
? ? ?'詳細資料,及源碼在作者主頁上'+CRLF+
? ? ?'主頁:hotsky.363.net'+CRLF;
?messagebox(handle,pchar(s1),'幫助',0);
end;
//主程序結束
procedure ShutDown;
begin
?//刪除字體對象
?DeleteObject(hFont);
?//取消窗口類的注冊
?UnRegisterClass(wClass.lpszClassName,hInst);
?//結束主進程
?ExitProcess(hInst);
end;
procedure ontimer;
var
len:integer;
str:array[0..500] of char;
begin
?inc(mcount);
?//strcopy(str,pchar(format('我是 %d 號刷屏機器人......',[mcount])));
?readCaption(heditemail,str);
?if (mcount mod 2)<>0 then
?begin
? ?len:=strlen(str);
? ?str[len]:=' '; ? ? ? ? ? ? ? ?
? ?str[len+1]:=#0;
?end;
?qqmainw:=FindWindow('AfxFrameOrView42s',nil);
?qqmainw:=FindWindowEx(qqmainw,0,'AfxMDIFrame42s',nil);
?qqmainw:=FindWindowEx(qqmainw,0,'AfxFrameOrView42s',nil);
?qqmainw:=GetNextWindow(qqmainw,GW_HWNDNEXT);
?qqmainw:=FindWindowEx(qqmainw,0,'#32770',nil);
?richedit:=FindWindowEx(qqmainw,0,'RICHEDIT',nil);
?SendMessage(richedit,EM_SETSEL,0,-1);
?SendMessage(richedit,EM_REPLACESEL,1,integer(@str));
?PostMessage(richedit,WM_KEYDOWN ,VK_RETURN,$001c0001);
?PostMessage(richedit,WM_KEYUP,VK_RETURN,$c01c0001);
end;
//這是主窗口的消息處理函數
function WindowProc(hWnd,Msg,wParam,lParam:integer):Longint; stdcall;
begin
?Result:=DefWindowProc(hWnd,Msg,wParam,lParam);
?case Msg of
?WM_COMMAND:
?begin
? ?if lParam=hButtonStart then begin mcount:=0;newtime:=SetTimer(handle,100,3000,nil); end;
? ?if lParam=hButtonStop then begin mcount:=0;killtimer(handle,newtime); end;
? ?if lParam=hButtonHelp then ButtonHelp;
? ?if lParam=hButtonExit then ShutDown;
?end;
?WM_TIMER:ontimer;
?WM_DESTROY: ShutDown;
?end;
end;
//定義幾個窗口創建函數
function CreateButton(name:pchar;x1,y1,x2,y2:integer):hwnd;begin ?Result:=CreateWindow('Button',name,WS_VISIBLE or WS_CHILD or BS_PUSHLIKE or BS_TEXT,x1,y1,x2,y2,Handle,0,hInst,nil);end;
function CreateEdit(name:pchar;x1,y1,x2,y2:integer):hwnd;begin ?Result:=CreateWindowEx(WS_EX_CLIENTEDGE,'Edit',name,WS_VISIBLE or WS_CHILD or ES_LEFT or ES_AUTOHSCROLL,x1,y1,x2,y2,Handle,0,hInst,nil);end;
function CreateLabel(name:pchar;x1,y1,x2,y2:integer):hwnd;begin ?Result:=CreateWindow('Static',name,WS_VISIBLE or WS_CHILD or SS_LEFT,x1,y1,x2,y2,Handle,0,hInst,nil);end;
function CreateMain(name:pchar;x1,y1,x2,y2:integer):hwnd;
begin
?//取得應用程序實例句柄
?hInst:=GetModuleHandle(nil);
?//初使化窗口類的信息
?with wClass do
?begin
? ?Style:= ? ? ? ? CS_PARENTDC;
? ?hIcon:= ? ? ? ? LoadIcon(hInst,'MAINICON');
? ?lpfnWndProc:= ? @WindowProc;
? ?hInstance:= ? ? hInst;
? ?hbrBackground:= COLOR_BTNFACE+1;
? ?lpszClassName:= 'MainClass';
? ?hCursor:= ? ? ? LoadCursor(0,IDC_ARROW);
?end;
?// 注冊窗口類
?RegisterClass(wClass);
?// 建立主窗口
?Result:=CreateWindow(wClass.lpszClassName,name,WS_OVERLAPPEDWINDOW or WS_VISIBLE,x1,y1,x2,y2,0,0,hInst,nil);
end;
function EnumChildProc(hwnd:integer;uint:integer):bool;
var classname,c2:array[0..100] of char;
hp:integer;
begin
?if hwnd<>0 then
?begin
?hp:=hwnd;
?//hp:=getparent(hwnd);
// ?hp:=getparent(hp);
// ?hp:=getparent(hp);
// ?hp:=getparent(hp);
?writeCaption(hlabelemail,pchar(format('%x',[hp])));
?end;
?// ?GetClassName(hwnd,classname,100);
// ?GetClassName(hp,c2,100);
// ?if (strcomp(classname,pchar('RICHEDIT'))=0) and (strcomp(c2,pchar('AfxFrameOrView42s'))=0) then richedit:=hwnd;
?result:=true;
end;
//---------主過程,類似于 C語言 中的 WinMain()
begin
?//建立主窗口
?handle:=CreateMain(exename,0,0,384,140);
?//建立四個控制按鈕
?hButtonStart:=CreateButton('開始刷屏',300,4+26*0,70,24);
?hButtonStop:=CreateButton('停止刷屏' ?,300,4+26*1,70,24);
?hButtonHelp:=CreateButton('幫 ?助' ?,300,4+26*2,70,24);
?hButtonExit:=CreateButton('退 ?出' ?,300,4+26*3,70,24);
?//建立兩個編輯框
?hEditEmail:=CreateEdit('我是刷屏機器人1.0',4,26,286,80);
?//建立三個標簽
?hLabelEmail:=CreateLabel('刷屏信息:',4,8,286,16);
?//創建字體對象
?hFont:=CreateFont(-12,0,0,0,0,0,0,0,GB2312_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH or FF_DONTCARE,'宋體');
?//改變字體
?SendMessage(hButtonStart,WM_SETFONT,hFont,0);
?SendMessage(hButtonStop,WM_SETFONT,hFont,0);
?SendMessage(hButtonHelp,WM_SETFONT,hFont,0);
?SendMessage(hButtonExit,WM_SETFONT,hFont,0);
?SendMessage(hEditEmail,WM_SETFONT,hFont,0);
?SendMessage(hLabelEmail,WM_SETFONT,hFont,0);
?//進入消息循環
?while(GetMessage(Msg,Handle,0,0))do
?begin
? ?TranslateMessage(Msg);
? ?DispatchMessage(Msg);
?end;
end.
uses
?windows,messages,sysutils;
{$R *.RES}
const
?CRLF=#13#10;
?exename:pchar='刷屏機器人 2001';
var
//----------------------
?wClass: ? TWndClass; ? //窗口類變量
?Msg: ? ? ?TMSG; ? ? ? ?//消息變量
?hInst, ? ? ? ? ? ? ? ? //程序實例
?Handle, ? ? ? ? ? ? ? ?//主窗口句柄
?hFont, ? ? ? ? ? ? ? ? //字體句柄
//----------------
?hButtonStart, ? //開始按鈕
?hButtonStop, ? ?//停止按鈕
?hButtonHelp, ? ?//幫助按鈕
?hButtonExit, ? ?//退出按鈕
?hEditEmail, ? ? //e-mail編輯
?hLabelEmail, ? ? //e-mail提示
?mcount,tempwnd,qqmainw,richedit:integer;
?lp:longint;
?newtime:integer;
//--------------------
//往一個窗口寫標題
procedure WriteCaption(hwnd:hwnd;text:pchar);begin sendmessage(hwnd,WM_SETTEXT,0,integer(text));end;
//從一個窗口讀標題
procedure ReadCaption(hwnd:hwnd;text:pchar);begin sendmessage(hwnd,WM_GETTEXT,400,integer(text));end;
procedure ButtonHelp;
var s1:string;
begin
?s1:='本軟件只用學習用,不可害人'+CRLF+
? ? ?'程序向QQ2000B的輸入框中輸入文字并發送!'+CRLF+
? ? ?'詳細資料,及源碼在作者主頁上'+CRLF+
? ? ?'主頁:hotsky.363.net'+CRLF;
?messagebox(handle,pchar(s1),'幫助',0);
end;
//主程序結束
procedure ShutDown;
begin
?//刪除字體對象
?DeleteObject(hFont);
?//取消窗口類的注冊
?UnRegisterClass(wClass.lpszClassName,hInst);
?//結束主進程
?ExitProcess(hInst);
end;
procedure ontimer;
var
len:integer;
str:array[0..500] of char;
begin
?inc(mcount);
?//strcopy(str,pchar(format('我是 %d 號刷屏機器人......',[mcount])));
?readCaption(heditemail,str);
?if (mcount mod 2)<>0 then
?begin
? ?len:=strlen(str);
? ?str[len]:=' '; ? ? ? ? ? ? ? ?
? ?str[len+1]:=#0;
?end;
?qqmainw:=FindWindow('AfxFrameOrView42s',nil);
?qqmainw:=FindWindowEx(qqmainw,0,'AfxMDIFrame42s',nil);
?qqmainw:=FindWindowEx(qqmainw,0,'AfxFrameOrView42s',nil);
?qqmainw:=GetNextWindow(qqmainw,GW_HWNDNEXT);
?qqmainw:=FindWindowEx(qqmainw,0,'#32770',nil);
?richedit:=FindWindowEx(qqmainw,0,'RICHEDIT',nil);
?SendMessage(richedit,EM_SETSEL,0,-1);
?SendMessage(richedit,EM_REPLACESEL,1,integer(@str));
?PostMessage(richedit,WM_KEYDOWN ,VK_RETURN,$001c0001);
?PostMessage(richedit,WM_KEYUP,VK_RETURN,$c01c0001);
end;
//這是主窗口的消息處理函數
function WindowProc(hWnd,Msg,wParam,lParam:integer):Longint; stdcall;
begin
?Result:=DefWindowProc(hWnd,Msg,wParam,lParam);
?case Msg of
?WM_COMMAND:
?begin
? ?if lParam=hButtonStart then begin mcount:=0;newtime:=SetTimer(handle,100,3000,nil); end;
? ?if lParam=hButtonStop then begin mcount:=0;killtimer(handle,newtime); end;
? ?if lParam=hButtonHelp then ButtonHelp;
? ?if lParam=hButtonExit then ShutDown;
?end;
?WM_TIMER:ontimer;
?WM_DESTROY: ShutDown;
?end;
end;
//定義幾個窗口創建函數
function CreateButton(name:pchar;x1,y1,x2,y2:integer):hwnd;begin ?Result:=CreateWindow('Button',name,WS_VISIBLE or WS_CHILD or BS_PUSHLIKE or BS_TEXT,x1,y1,x2,y2,Handle,0,hInst,nil);end;
function CreateEdit(name:pchar;x1,y1,x2,y2:integer):hwnd;begin ?Result:=CreateWindowEx(WS_EX_CLIENTEDGE,'Edit',name,WS_VISIBLE or WS_CHILD or ES_LEFT or ES_AUTOHSCROLL,x1,y1,x2,y2,Handle,0,hInst,nil);end;
function CreateLabel(name:pchar;x1,y1,x2,y2:integer):hwnd;begin ?Result:=CreateWindow('Static',name,WS_VISIBLE or WS_CHILD or SS_LEFT,x1,y1,x2,y2,Handle,0,hInst,nil);end;
function CreateMain(name:pchar;x1,y1,x2,y2:integer):hwnd;
begin
?//取得應用程序實例句柄
?hInst:=GetModuleHandle(nil);
?//初使化窗口類的信息
?with wClass do
?begin
? ?Style:= ? ? ? ? CS_PARENTDC;
? ?hIcon:= ? ? ? ? LoadIcon(hInst,'MAINICON');
? ?lpfnWndProc:= ? @WindowProc;
? ?hInstance:= ? ? hInst;
? ?hbrBackground:= COLOR_BTNFACE+1;
? ?lpszClassName:= 'MainClass';
? ?hCursor:= ? ? ? LoadCursor(0,IDC_ARROW);
?end;
?// 注冊窗口類
?RegisterClass(wClass);
?// 建立主窗口
?Result:=CreateWindow(wClass.lpszClassName,name,WS_OVERLAPPEDWINDOW or WS_VISIBLE,x1,y1,x2,y2,0,0,hInst,nil);
end;
function EnumChildProc(hwnd:integer;uint:integer):bool;
var classname,c2:array[0..100] of char;
hp:integer;
begin
?if hwnd<>0 then
?begin
?hp:=hwnd;
?//hp:=getparent(hwnd);
// ?hp:=getparent(hp);
// ?hp:=getparent(hp);
// ?hp:=getparent(hp);
?writeCaption(hlabelemail,pchar(format('%x',[hp])));
?end;
?// ?GetClassName(hwnd,classname,100);
// ?GetClassName(hp,c2,100);
// ?if (strcomp(classname,pchar('RICHEDIT'))=0) and (strcomp(c2,pchar('AfxFrameOrView42s'))=0) then richedit:=hwnd;
?result:=true;
end;
//---------主過程,類似于 C語言 中的 WinMain()
begin
?//建立主窗口
?handle:=CreateMain(exename,0,0,384,140);
?//建立四個控制按鈕
?hButtonStart:=CreateButton('開始刷屏',300,4+26*0,70,24);
?hButtonStop:=CreateButton('停止刷屏' ?,300,4+26*1,70,24);
?hButtonHelp:=CreateButton('幫 ?助' ?,300,4+26*2,70,24);
?hButtonExit:=CreateButton('退 ?出' ?,300,4+26*3,70,24);
?//建立兩個編輯框
?hEditEmail:=CreateEdit('我是刷屏機器人1.0',4,26,286,80);
?//建立三個標簽
?hLabelEmail:=CreateLabel('刷屏信息:',4,8,286,16);
?//創建字體對象
?hFont:=CreateFont(-12,0,0,0,0,0,0,0,GB2312_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH or FF_DONTCARE,'宋體');
?//改變字體
?SendMessage(hButtonStart,WM_SETFONT,hFont,0);
?SendMessage(hButtonStop,WM_SETFONT,hFont,0);
?SendMessage(hButtonHelp,WM_SETFONT,hFont,0);
?SendMessage(hButtonExit,WM_SETFONT,hFont,0);
?SendMessage(hEditEmail,WM_SETFONT,hFont,0);
?SendMessage(hLabelEmail,WM_SETFONT,hFont,0);
?//進入消息循環
?while(GetMessage(Msg,Handle,0,0))do
?begin
? ?TranslateMessage(Msg);
? ?DispatchMessage(Msg);
?end;
end.
總結
以上是生活随笔為你收集整理的QQ2000 的聊天室刷屏机设计技术的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: py12306 购票助手
- 下一篇: 安卓应用出海指南--发布到Google