?? unit1.pas
字號:
//此程序實現了不用加好友,直接向QQ號發送信息的功能。
//不過QQ的服務器會限制次數,大家可以考慮用一系列(越多越好)的QQ號不斷地切換來登陸,必要時可以
//不斷地連接和斷開網絡,變換IP來解決QQ服務器的限制。
//傳播或修改本程序,請保留原作者信息,謝謝!
//世紀0769網址收藏站
//網址:http://www.0769cn.com
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, OleCtrls, SHDocVw, ExtCtrls,shellapi;
type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
WebBrowser1: TWebBrowser;
Timer1: TTimer;
Memo2: TMemo;
Label11: TLabel;
procedure Button1Click(Sender: TObject);
function GetQQcaption:string;
procedure Timer1Timer(Sender: TObject);
procedure SendMessages(m:string);
procedure WebBrowser1DocumentComplete(Sender: TObject;
const pDisp: IDispatch; var URL: OleVariant);
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Label11MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure Label11Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
msgs:string;
EditHandle,RichEditHandle: Integer;
captions:string;
Gi:integer;
implementation
{$R *.dfm}
function Tform1.GetQQcaption:string;
var
hCurrentWindow: HWnd;
szText: array[0..254] of char;
begin
result:='';
hCurrentWindow := GetWindow(Handle, GW_HWNDFIRST);
while hCurrentWindow <> 0 do
begin
if GetWindowText(hCurrentWindow, @szText, 255) > 0 then
if pos('會話中',StrPas(@szText))>0 then
result:=StrPas(@szText);
hCurrentWindow := GetWindow(hCurrentWindow, GW_HWNDNEXT);
end;
end;
function GetButtonHandle(hwnd: Integer; lparam: Longint):Boolean; stdcall;
var
buffer: array[0..255] of Char;
buffer1: array[0..255] of Char;
begin
Result := True;
GetClassName(hwnd,buffer,256);
if StrPas(Buffer)='Button' then
begin
GetWindowText(hwnd,buffer1,100);
if trim(buffer1)= captions then
begin
PInteger(lparam)^ := hwnd; //得到目標控件的Hwnd(句柄)
Result:=False; //終止循環
end;
end;
end;
function GetRichEditHandle(hwnd: Integer; lparam: Longint):Boolean; stdcall;
var
buffer: array[0..255] of Char;
begin
Result := True;
//得到目標窗口的控件
GetClassName(hwnd,buffer,256);
//找到發消息的目標窗口的目標控件
if StrPas(Buffer)='RICHEDIT' then
begin
Gi:=Gi+1;
PInteger(lparam)^ := hwnd; //得到目標控件的Hwnd(句柄)
if Gi=1 then
begin
SendMessage(hwnd,WM_SETFOCUS,0,0);
SendMessage(hwnd,WM_SETTEXT,0,Integer(pchar(msgs)));
//PostMessage(hwnd,WM_KEYDOWN, 13, 0);
//PostMessage(hwnd,WM_KEYUP, 13, 0);
Result:=False;//終止循環
end;
end;
end;
procedure Tform1.SendMessages(m:string);
var
FButtonHandle,
ButtonHandle,
WinHandle:Integer;
begin
WinHandle:=0;
WinHandle:=FindWindow(nil,pchar(form1.GetQQcaption)); //就是窗口的Caption
RichEditHandle:=WinHandle;
msgs:=m;
EnumChildWindows(RichEditHandle,@GetRichEditHandle,Integer(@RichEditHandle));
captions:='發送(&S)';
ButtonHandle:=WinHandle;
EnumChildWindows(ButtonHandle,@GetButtonHandle,Integer(@ButtonHandle));
FButtonHandle:=ButtonHandle;
SendMessage(FButtonHandle,WM_LBUTTONDOWN,0,0);
SendMessage(FButtonHandle,WM_LBUTTONUP,0,0);
SendMessage(FButtonHandle,WM_LBUTTONDOWN,0,0);
SendMessage(FButtonHandle,WM_LBUTTONUP,0,0);
sleep(200);
captions:='關閉(&C)';
ButtonHandle:=WinHandle;
EnumChildWindows(ButtonHandle,@GetButtonHandle,Integer(@ButtonHandle));
FButtonHandle:=ButtonHandle;
SendMessage(FButtonHandle,WM_LBUTTONDOWN,0,0);
SendMessage(FButtonHandle,WM_LBUTTONUP,0,0);
sleep(1000);
Button1Click(self)
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Gi:=0;
memo2.Text:=inttostr(strtoint(memo2.Text)+1);
form1.WebBrowser1.Navigate('tencent://Message/?Menu=no&Uin='+form1.memo2.text+'&websiteName=在線咨詢');
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
if GetQQCaption<>'' then
SendMessages(form1.Memo1.Text);
timer1.Enabled:=false;
end;
procedure TForm1.WebBrowser1DocumentComplete(Sender: TObject;
const pDisp: IDispatch; var URL: OleVariant);
begin
timer1.Enabled:=true;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
form1.Label11.Caption:='世紀0769網址收藏站:'+chr(13)+'http://www.0769cn.com';
memo2.Lines.LoadFromFile('QQ.txt');
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
memo2.Lines.SaveToFile('QQ.txt');
end;
procedure TForm1.Label11MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
label11.Font.Style:=label11.Font.Style+[fsunderline];
label11.Font.Color:=clred;
end;
procedure TForm1.Label11Click(Sender: TObject);
begin
shellexecute(handle,nil,'http://www.0769cn.com/?input=qqsend',nil,nil,sw_normal);
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -