------------------ Delphi version: --------------
PROGRAM CHAT2001;
Uses
Windows, Messages, SysuTils;
{$ R * .res}
Const
CRLF = # 13 # 10;
Exename: pchar = 'Brushing Robot 2001';
VAR
// ----------------------
WCLASS: TwndClass; // window class variable
MSG: TMSG; // message variable
Hinst, // program example
Handle, // main window handle
HFONT, / / font handle
// ----------------
HButtonStart, // Start button
HButtonStop, // Stop button
HButtonHelp, // Help button
hbuttonexit, // Exit button
Heditemail, // e-mail editor
HLabElemail, // E-mail
McOUNT, TempWnd, QQmainw, Richedit: Integer
lp: longint;
NewTime: integer;
// --------------------
// Write a title to one window
Procedure Writecaption (hwnd: hwnd; text: pchar); Begin SendMessage (hwnd, wm_settext, 0, integer);
// Read title from one window
Procedure readcaption (hwnd: hwnd; text: pchar); Begin SendMessage (hwnd, wm_gettext, 400, integer (text));
Procedure buttonhelp;
VAR S1: STRING;
Begin
S1: = 'This software is only used, it is unacivable' CRLF
'Enter text in the input box of QQ2000B and send it!' CRLF
'Details, and source code on the author's page' CRLF
'Home: Hotsky.363.net' CRLF;
MessageBox (Handle, Pchar (S1), 'Help ", 0);
END;
// End of the main program
PROCEDURE SHUTDOWN
Begin
// Delete font objects
DeleteObject (HFONT);
/ / Cancel the registration of the window class
UnregisterClass (wclass.lpszclassname, hinst);
// End the main process
EXITPROCESS (HINST);
END;
Procedure Ontimer;
VAR
Len: integer;
Str: array [0..500] of char;
Begin
inc (McOUNT);
// stropy (str, pchar (format ('I am% D brush screen robot ...', [mcount])));
Readcaption (HedItemail, STR);
Strcopy (Str, Pchar (Format ('I am a% D brush screen robot ...', [mcount])));
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);
// setfocus (richedit);
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);
Strcopy (Str, Pchar (Format ('I am a% D brush screen robot ...', [mcount])));
Writecaption (HLabElemail, STR);
END;
// This is the message handler of the main window
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 the beginning: = 0; newtime: = setTimer (Handle, 100, 2950, NIL);
If lparam = hbuttonstop the beginning: = 0; KillTimer (Handle, NewTime);
IF lparam = hbuttonhelp the buttonhelp;
IF lparam = hbuttonexit kiln;
END;
WM_TIMER: ONTIMER;
WM_DESTROY: SHUTDOWN;
END;
END;
/ / Define several windows creation functions
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);
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 cretemain (name: pchar; x1, y1, x2, y2: integer): hwnd;
Begin
// get the application instance sector
Hinst: = getModuleHandle (NIL);
// Information of the first-enamel window class
WITH WCLASS DO
Begin
STYLE: = CS_PARENTDC;
Hicon: = Loadicon (Hinst, 'MAINICON');
LpfnWndproc: = @windowproc;
Hinstance: = hinst;
HBRBACKGROUND: = Color_BTNFACE 1;
LPSZCLASSNAME: = 'mainclass';
Hcursor: = loadingcursor (0, IDC_ARROW);
END;
// Register window class
RegisterClass (WCLASS);
// Establish a main window
Result: = CREATEWINDOW (wclass.lpszclassname, Name, WS_OVERLAPPEDWINDOW OR WS_Visible, X1, Y1, X2, Y2, 0, 10, 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 (ClassName, Pchar ('RicheDit')) = 0) and (strComp (C2, Pchar ('AFXFrameorView42S')) = 0) The richedit: = hwnd;
RESULT: = true;
END;
// --------- Main process, similar to WinMain in C language ()
Begin
// Establish a main window
Handle: = Createmain (Exename, 0,0,384,140);
// Establish four control buttons
HButtonStart: = CreateButton ('Startbrush ", 300, 4 26 * 0, 70, 24);
HButtonStop: = CreateButton ('Stop Brush ", 300, 4 26 * 1, 70, 24);
HButtonHelp: = CreateButton ('Help ", 300, 4 26 * 2, 70, 24);
HbuttoneXit: = CreateButton ('exits', 300, 4 26 * 3, 70, 24); // Establish two edit boxes
Heditemail: = Createedit ('I am a brush screen robot 1.0', 4, 26, 286, 80);
// Establish three labels
HLabElemail: = CreateLabel ('Brush Screen Information:', 4, 8, 286, 16);
// Create a font object
HFONT: = CREATEFONT (-12, 0, 0, 0, 0, 0, GB2312_CHARS, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, Default_Quality, Default_pitch or FF_DONTCARE, 'Song ";
// change the font
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);
//
// qqmainw: = FindWindow ('AFXFrameorView42S', NIL);
// if qqmainw <> 0 Then MessageBox (0, '', '', 0);
// TempWnd: = FindWindowEx (QQMAINW, 0, 'AFXMDIFRAME42S', NIL);
LP: = 0;
// enumchildWindows (GetDesktopWindow, @ enumchildproc, lp);
// enumchildwindows (QQMainw, @ enumchildproc, lp);
// Enter the message loop
While (GetMessage (MSG, Handle, 0, 0))
Begin
TranslateMessage (MSG);
DispatchMessage (MSG);
END;
End.
----------------------------------------------- -
#include
Int mcount = 0, newtime;
Hwnd hmain, hbutton1, hbutton2, hbutton3;
LPCTSTR htitle = "QQ2000B chat room brush screen V1.0";
Char hhelp [1024];
Void ONTIMER (VOID)
{
Int Len;
Char Str [1024];
HWND Richedit;
McOUNT ;
GetWindowText (Hedit, STR, 1024);
IF ((McOUNT% 2)! = 0) {len = strull (STR); str [len] = ''; str [len 1] = '/ 0';}
Richedit = FindWindow ("AFXFrameorView42s", NULL);
Richedit = FindWindowEx (RicheDit, 0, "Afxmdiframe42S", NULL);
Richedit = FindWindowEx (Richedit, 0, "AfxFrameorView42S", NULL); Richedit = getNextWindow (Richedit, GW_HWndNext);
Richedit = FindWindowEx (RicheDit, 0, "# 32770", null;
Richedit = FindWindowEx (Richedit, 0, "Richedit", NULL;
SendMessage (Richedit, EM_SETSEL, 0, -1);
SendMessage (RicheDit, EM_REPLACESEL, 1, (LPARAM) STR);
Postmessage (richedit, wm_keydown, vk_return, 0x001c0001);
Postmessage (RicheDit, WM_Keyup, VK_RETURN, 0XC01C0001);
WSPrintf (STR, "I am a% D screen robot ...", mcount);
SetWindowText (Hmain, Str);
}
LResult Callback MainwndProc (HWND HWND, UINT MSG, WPARAM WPARAM, LPARAM LPARAM)
{
Switch (msg)
{
Case WM_COMMAND:
IF (lparam == (lparam) hButton1) {mcount = 0; newtime = setTimer (hwnd, 100, 2950, null);}
IF (lparam == (lparam) hButton2) {mcount = 0; KillTimer (hwnd, newtime); setWindowText (hwnd, htitle);}
IF (lparam == (lparam) hbutton3)
{
WSPrintf (hhelp, "Enter the content you want to brush in the edit box, then / n Click Startbrush Screen, if you click Stop Brush Screen / N, the system will no longer brush / n This program is compiled with the LCCWIN32 / n program: NJHACK / NOICQ:10772919/ne-mail: NJH21CN.COM/N Home: Hotsky.363.net ");
MessageBox (hwnd, (lpcstr) Hhelp, System Help, 0);
}
Break;
Case WM_TIMER:
Ontimer ();
Break;
Case WM_DESTROY:
PostquitMessage (0);
Break;
DEFAULT:
Return DefWindowProc (HWND, MSG, WPARAM, LPARAM);
}
Return 0;
}
Int WinApi Winmain (Hinstance Hinstance, Hinstance Hprevinstance, LPSTR LPCMDLINE, INT NCMDSHOW)
{
MSG msg;
WNDCLASS WC;
HFONT HFONT;
//
MEMSET (& WC, 0, SIZEOF (WNDCLASS));
wc.style = 0;
Wc.lpfnWndProc = (WndProc) mainwndproc;
wc.hinstance = hinstance;
wc.hbrbackground = (Hbrush) (Color_BTNFACE 1);
wc.lpszclassname = "chat2001 wndclass";
Wc.lpsz GeneNuname = NULL;
Wc.hcursor = loadingCursor (NULL, IDC_ARROW);
Wc.hicon = loadicon (null, idi_application); if (! RegisterClass (& WC)) Return 0;
Hmain = CreateWindow (wc.lpszclassname, htitle, ws_overlappedwindow|ws_visible, 10, 10, 250, 190, null, null, hinstance, null)
IF (hmain == 0) Return 0;
Hedit = CREATEWINDOWEX (WS_EX_CLIENTEDGE, "Edit", "Brush Screen Robot 1.0 Test Edition", WS_Visible|WS_Child ]_Multiline|, 10, 10, 10, 225, 115, Hmain, Null, Hinstance, NULL;
HButton1 = CreateWindow ("Button", "Startbrush Screen", WS_Visible|WS_Child|bs_pushlike|bs_text, 10, 132, 60, 24, hmain, null, hinstance, null;
Hbutton2 = CreateWindow ("Button", "Stop Brush Screen", WS_Visible|WS_Child|bs_pushlike|bs_text, 80, 132, 60, 24, Hmain, Null, Hinstance, NULL;
HButton3 = CreateWindow ("Button", "System Help", WS_Visible|WS_Child|bs_pushlike|bs_text, 150, 132, 60, 24, hmain, null, hinstance, null;
HFONT = CREATEFONT (-12, 0, 0, 0, 0, 0, 0, GB2312_CHARS, OUT_DEFAULT_PRECIS, Clip_default_Precis, Default_Quality, Default_pitch|ff_dontcare, "Song");
SendMessage (Hedit, WM_SETFONT, (WPARAM) HFONT, (LPARAM) 0);
SendMessage (hbutton1, wm_setfont, (wparam) HFONT, (LPARAM) 0);
SendMessage (hbutton2, wm_setfont, (wparam) HFONT, (LPARAM) 0);
SendMessage (hbutton3, wm_setfont, (wparam) HFONT, (LPARAM) 0);
ShowWindow (hmain, sw_show);
While (GetMessage (& MSG, NULL, 0, 0)) {TranslateMessage (& MSG); DispatchMessage (& MSG);
Return msg.wparam;
}