Pages

Sabtu, 12 November 2011

QQ2000 chat room scraper machine design

program chat2001; program chat2001;

uses uses
windows,messages,sysutils; windows, messages, sysutils;

{$R *.RES} {$ R *. RES}

const const
CRLF=#13#10; CRLF = # 13 # 10;
exename:pchar='刷屏机器人2001'; exename: pchar = 'scraper robot 2001';
var var
//---------------------- //----------------------
wClass: TWndClass; //窗口类变量 wClass: TWndClass; / / window class variable
Msg: TMSG; //消息变量 Msg: TMSG; / / message variables
hInst, //程序实例 hInst, / / ​​instance
Handle, //主窗口句柄 Handle, / / ​​main window handle
hFont, //字体句柄 hFont, / / ​​font handle
//---------------- //----------------
hButtonStart, //开始按钮 hButtonStart, / / ​​start button
hButtonStop, //停止按钮 hButtonStop, / / ​​stop button
hButtonHelp, //帮助按钮 hButtonHelp, / / ​​Help button
hButtonExit, //退出按钮 hButtonExit, / / ​​exit button
hEditEmail, //e-mail编辑 hEditEmail, / / ​​e-mail editor
hLabelEmail, //e-mail提示 hLabelEmail, / / ​​e-mail tips
mcount,tempwnd,qqmainw,richedit:integer; mcount, tempwnd, qqmainw, richedit: integer;
lp:longint; lp: longint;
newtime:integer; newtime: integer;

//-------------------- //--------------------
//往一个窗口写标题 / / Write to a window title
procedure WriteCaption(hwnd:hwnd;text:pchar);begin procedure WriteCaption (hwnd: hwnd; text: pchar); begin
sendmessage(hwnd,WM_SETTEXT,0,integer(text));end; sendmessage (hwnd, WM_SETTEXT, 0, integer (text)); end;
//从一个窗口读标题 / / Read from a window title
procedure ReadCaption(hwnd:hwnd;text:pchar);begin procedure ReadCaption (hwnd: hwnd; text: pchar); begin
sendmessage(hwnd,WM_GETTEXT,400,integer(text));end; sendmessage (hwnd, WM_GETTEXT, 400, integer (text)); end;

procedure ButtonHelp; procedure ButtonHelp;
var s1:string; var s1: string;
begin begin
s1:='本软件只用学习用,不可害人'+CRLF+ s1: = 'only to learn to use the software, not evil' + CRLF +
'程序向QQ2000B的输入框中输入文字并发送!'+CRLF+ 'Procedure to QQ2000B text input box and send!' + CRLF +
'详细资料,及源码在作者主页上'+CRLF+ 'Details on the home page of the author and source' + CRLF +
'主页:hotsky.363.net'+CRLF; 'Home: hotsky.363.net' + CRLF;
messagebox(handle,pchar(s1),'帮助',0); messagebox (handle, pchar (s1), 'help', 0);
end; end;
//主程序结束 / / End of main program
procedure ShutDown; procedure ShutDown;
begin begin
//删除字体对象 / / Delete the font object
DeleteObject(hFont); DeleteObject (hFont);
//取消窗口类的注册 / / Cancel the window class registration
UnRegisterClass(wClass.lpszClassName,hInst); UnRegisterClass (wClass.lpszClassName, hInst);
//结束主进程 / / End of the main process
ExitProcess(hInst); ExitProcess (hInst);
end; end;

procedure ontimer; procedure ontimer;
var var
len:integer; len: integer;
str:array[0..500] of char; str: array [0 .. 500] of char;
begin begin
inc(mcount); inc (mcount);
//strcopy(str,pchar(format('我是%d / / Strcopy (str, pchar (format ('I% d
号刷屏机器人......',[mcount]))); No. scraper robot ......',[ mcount ])));
readCaption(heditemail,str); readCaption (heditemail, str);

if (mcount mod 2)<>0 then if (mcount mod 2) <> 0 then
begin begin
len:=strlen(str); len: = strlen (str);
str[len]:=' '; str [len]: = '';
str[len+1]:=#0; str [len +1]: = # 0;
end; end;
qqmainw:=FindWindow('AfxFrameOrView42s',nil); qqmainw: = FindWindow ('AfxFrameOrView42s', nil);
qqmainw:=FindWindowEx(qqmainw,0,'AfxMDIFrame42s',nil); qqmainw: = FindWindowEx (qqmainw, 0, 'AfxMDIFrame42s', nil);

qqmainw:=FindWindowEx(qqmainw,0,'AfxFrameOrView42s',nil); qqmainw: = FindWindowEx (qqmainw, 0, 'AfxFrameOrView42s', nil);

qqmainw:=GetNextWindow(qqmainw,GW_HWNDNEXT); qqmainw: = GetNextWindow (qqmainw, GW_HWNDNEXT);
qqmainw:=FindWindowEx(qqmainw,0,'#32770',nil); qqmainw: = FindWindowEx (qqmainw, 0, '# 32770', nil);
richedit:=FindWindowEx(qqmainw,0,'RICHEDIT',nil); richedit: = FindWindowEx (qqmainw, 0, 'RICHEDIT', nil);

SendMessage(richedit,EM_SETSEL,0,-1); SendMessage (richedit, EM_SETSEL, 0, -1);
SendMessage(richedit,EM_REPLACESEL,1,integer(@str)); SendMessage (richedit, EM_REPLACESEL, 1, integer (@ str));
PostMessage(richedit,WM_KEYDOWN ,VK_RETURN,$001c0001); PostMessage (richedit, WM_KEYDOWN, VK_RETURN, $ 001c0001);
PostMessage(richedit,WM_KEYUP,VK_RETURN,$c01c0001); PostMessage (richedit, WM_KEYUP, VK_RETURN, $ c01c0001);
end; end;

//这是主窗口的消息处理函数 / / This is the main window's message handler
function function
WindowProc(hWnd,Msg,wParam,lParam:integer):Longint; WindowProc (hWnd, Msg, wParam, lParam: integer): Longint;
stdcall; stdcall;
begin begin
Result:=DefWindowProc(hWnd,Msg,wParam,lParam); Result: = DefWindowProc (hWnd, Msg, wParam, lParam);
case Msg of case Msg of
WM_COMMAND: WM_COMMAND:
begin begin
if lParam=hButtonStart then begin if lParam = hButtonStart then begin
mcount:=0;newtime:=SetTimer(handle,100,3000,nil); end; mcount: = 0; newtime: = SetTimer (handle, 100,3000, nil); end;
if lParam=hButtonStop then begin if lParam = hButtonStop then begin
mcount:=0;killtimer(handle,newtime); end; mcount: = 0; killtimer (handle, newtime); end;
if lParam=hButtonHelp then ButtonHelp; if lParam = hButtonHelp then ButtonHelp;
if lParam=hButtonExit then ShutDown; if lParam = hButtonExit then ShutDown;
end; end;
WM_TIMER:ontimer; WM_TIMER: ontimer;
WM_DESTROY: ShutDown; WM_DESTROY: ShutDown;
end; end;
end; end;
//定义几个窗口创建函数 / / Define a function to create a few windows
function function
CreateButton(name:pchar;x1,y1,x2,y2:integer):hwnd;begin CreateButton (name: pchar; x1, y1, x2, y2: integer): hwnd; begin
Result:=CreateWindow('Button',name,WS_VISIBLE or Result: = CreateWindow ('Button', name, WS_VISIBLE or
WS_CHILD or BS_PUSHLIKE or WS_CHILD or BS_PUSHLIKE or
BS_TEXT,x1,y1,x2,y2,Handle,0,hInst,nil);end; BS_TEXT, x1, y1, x2, y2, Handle, 0, hInst, nil); end;
function function
CreateEdit(name:pchar;x1,y1,x2,y2:integer):hwnd;begin CreateEdit (name: pchar; x1, y1, x2, y2: integer): hwnd; begin
Result:=CreateWindowEx(WS_EX_CLIENTEDGE,'Edit',name,WS_VISIBLE Result: = CreateWindowEx (WS_EX_CLIENTEDGE, 'Edit', name, WS_VISIBLE
or WS_CHILD or ES_LEFT or or WS_CHILD or ES_LEFT or
ES_AUTOHSCROLL,x1,y1,x2,y2,Handle,0,hInst,nil);end; ES_AUTOHSCROLL, x1, y1, x2, y2, Handle, 0, hInst, nil); end;
function function
CreateLabel(name:pchar;x1,y1,x2,y2:integer):hwnd;begin CreateLabel (name: pchar; x1, y1, x2, y2: integer): hwnd; begin
Result:=CreateWindow('Static',name,WS_VISIBLE or Result: = CreateWindow ('Static', name, WS_VISIBLE or
WS_CHILD or SS_LEFT,x1,y1,x2,y2,Handle,0,hInst,nil);end; WS_CHILD or SS_LEFT, x1, y1, x2, y2, Handle, 0, hInst, nil); end;

function function
CreateMain(name:pchar;x1,y1,x2,y2:integer):hwnd; CreateMain (name: pchar; x1, y1, x2, y2: integer): hwnd;
begin begin
//取得应用程序实例句柄 / / Get the application instance handle
hInst:=GetModuleHandle(nil); hInst: = GetModuleHandle (nil);
//初使化窗口类的信息 / / Initialization of the window class information
with wClass do with wClass do
begin begin
Style:= CS_PARENTDC; Style: = CS_PARENTDC;
hIcon:= LoadIcon(hInst,'MAINICON'); hIcon: = LoadIcon (hInst, 'MAINICON');
lpfnWndProc:= @WindowProc; lpfnWndProc: = @ WindowProc;
hInstance:= hInst; hInstance: = hInst;
hbrBackground:= COLOR_BTNFACE+1; hbrBackground: = COLOR_BTNFACE +1;
lpszClassName:= 'MainClass'; lpszClassName: = 'MainClass';
hCursor:= LoadCursor(0,IDC_ARROW); hCursor: = LoadCursor (0, IDC_ARROW);
end; end;
// 注册窗口类 / / Register the window class
RegisterClass(wClass); RegisterClass (wClass);
// 建立主窗口 / / Create the main window
Result:=CreateWindow(wClass.lpszClassName,name,WS_OVERLAPPEDWINDOW Result: = CreateWindow (wClass.lpszClassName, name, WS_OVERLAPPEDWINDOW
or WS_VISIBLE,x1,y1,x2,y2,0,0,hInst,nil); or WS_VISIBLE, x1, y1, x2, y2, 0,0, hInst, nil);
end; end;

function EnumChildProc(hwnd:integer;uint:integer):bool; function EnumChildProc (hwnd: integer; uint: integer): bool;
var classname,c2:array[0..100] of char; var classname, c2: array [0 .. 100] of char;
hp:integer; hp: integer;
begin begin
if hwnd<>0 then if hwnd <> 0 then
begin begin
hp:=hwnd; hp: = hwnd;
//hp:=getparent(hwnd); / / Hp: = getparent (hwnd);
// hp:=getparent(hp); / / Hp: = getparent (hp);
// hp:=getparent(hp); / / Hp: = getparent (hp);
// hp:=getparent(hp); / / Hp: = getparent (hp);
writeCaption(hlabelemail,pchar(format('%x',[hp]))); writeCaption (hlabelemail, pchar (format ('% x', [hp ])));
end; end;
// GetClassName(hwnd,classname,100); / / GetClassName (hwnd, classname, 100);
// GetClassName(hp,c2,100); / / GetClassName (hp, c2, 100);
// if (strcomp(classname,pchar('RICHEDIT'))=0) and / / If (strcomp (classname, pchar ('RICHEDIT')) = 0) and
(strcomp(c2,pchar('AfxFrameOrView42s'))=0) then (Strcomp (c2, pchar ('AfxFrameOrView42s')) = 0) then
richedit:=hwnd; richedit: = hwnd;
result:=true; result: = true;
end; end;

//---------主过程,类似于C语言中的WinMain() //--------- The main process, similar to the C language in the WinMain ()
begin begin
//建立主窗口 / / Create the main window
handle:=CreateMain(exename,0,0,384,140); handle: = CreateMain (exename, 0,0,384,140);
//建立四个控制按钮 / / Create four control buttons
hButtonStart:=CreateButton('开始刷屏',300,4+26*0,70,24); hButtonStart: = CreateButton ('start refresh', 300,4 +26 * 0,70,24);
hButtonStop:=CreateButton('停止刷屏' ,300,4+26*1,70,24); hButtonStop: = CreateButton ('stop refresh', 300,4 +26 * 1,70,24);
hButtonHelp:=CreateButton('帮助' ,300,4+26*2,70,24); hButtonHelp: = CreateButton ('help', 300,4 +26 * 2,70,24);
hButtonExit:=CreateButton('退出' ,300,4+26*3,70,24); hButtonExit: = CreateButton ('exit', 300,4 +26 * 3,70,24);
//建立两个编辑框 / / Create two edit boxes
hEditEmail:=CreateEdit('我是刷屏机器人1.0',4,26,286,80); hEditEmail: = CreateEdit ('I am a scraper robot 1.0', 4,26,286,80);
//建立三个标签 / / Create three tags
hLabelEmail:=CreateLabel('刷屏信息:',4,8,286,16); hLabelEmail: = CreateLabel ('refresh information:' 4,8,286,16);
//创建字体对象 / / Create a font object
hFont:=CreateFont(-12,0,0,0,0,0,0,0,GB2312_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH 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,'宋体'); or FF_DONTCARE, 'Arial');
//改变字体 / / Change the font
SendMessage(hButtonStart,WM_SETFONT,hFont,0); SendMessage (hButtonStart, WM_SETFONT, hFont, 0);
SendMessage(hButtonStop,WM_SETFONT,hFont,0); SendMessage (hButtonStop, WM_SETFONT, hFont, 0);
SendMessage(hButtonHelp,WM_SETFONT,hFont,0); SendMessage (hButtonHelp, WM_SETFONT, hFont, 0);
SendMessage(hButtonExit,WM_SETFONT,hFont,0); SendMessage (hButtonExit, WM_SETFONT, hFont, 0);
SendMessage(hEditEmail,WM_SETFONT,hFont,0); SendMessage (hEditEmail, WM_SETFONT, hFont, 0);
SendMessage(hLabelEmail,WM_SETFONT,hFont,0); SendMessage (hLabelEmail, WM_SETFONT, hFont, 0);

//进入消息循环 / / Into the message loop
while(GetMessage(Msg,Handle,0,0))do while (GetMessage (Msg, Handle, 0,0)) do
begin begin
TranslateMessage(Msg); TranslateMessage (Msg);
DispatchMessage(Msg); DispatchMessage (Msg);
end; end;
end. end.

Tidak ada komentar:

Posting Komentar