如下是源码;unit QQDDPHack;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, Spin;type
ImgList = record
bmp: TBitmap;
ox, oy: Integer;
end; TForm1 = class(TForm)
Button1: TButton;
Image1: TImage;
Image2: TImage;
CheckBox1: TCheckBox;
SpinEdit1: TSpinEdit;
Label1: TLabel;
Label2: TLabel;
SpinEdit2: TSpinEdit;
Label3: TLabel;
Timer1: TTimer;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
procedure Button1Click(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
function fcImage(bmp1, bmp2: TBitmap): boolean;
function searchCell(ddc: THandle; x, y: Integer; bmp: TBitmap): boolean;
overload;
function searchCell(x, y: Integer; bmp: TBitmap): Boolean; overload;
function checkLineTo(x, y: Integer; bmp: TBitmap): boolean;
procedure sendkey(x, y: integer);
procedure DeleteSelf;
public
{ Public declarations }
end;const
cutsize = 18;var
Form1 : TForm1;
hmine : Thandle; //QQ对对碰窗体的句柄
pmine : Thandle; //QQ对对碰窗体的进程柄
mineid : dword; //QQ对对碰窗体的进程ID
mwidth, mheight : integer;
xOffset, yOffset : integer;
mrow, mcol : Integer;
tmpcanvas : tcanvas;
ddc : THandle;
cid : integer;
il : array[0..7, 0..7] of ImgList; //保存图形列表
implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
var x, y : integer; //行数、列数
b : integer;
begin
mwidth := 48;
mheight := 48;
mrow := 7;
mcol := 7;
xOffset := 176;
yOffset := 102;
cid := 0;
if CheckBox1.Checked then
hmine := findwindow('#32770', '对对碰') //找 QQ对对碰 窗口
else
hmine := findwindow(nil, 'test'); //找 QQ对对碰 窗口
GetWindowThreadProcessId(hmine, @mineId); //返回 QQ对对碰 进程的ID,为mineId
pmine := OpenProcess(PROCESS_VM_READ, true, mineId); //打开 QQ对对碰 进程
if pmine = 0 then
begin
messagebox(0, '你还没有运行[QQ对对碰]:)', '找不到哦', mb_ok);
exit
end;
ddc := getdc(hmine); Image1.Canvas.Brush.Color := ClWhite;
Image1.Canvas.FillRect(Canvas.ClipRect); for x := 0 to mrow do //从第一行开始,由左向右,从上而下
for y := 0 to mcol do //
begin
Image2.Canvas.Brush.Color := ClWhite;
Image2.Canvas.FillRect(Canvas.ClipRect); bitblt(image2.Canvas.Handle, 0, 0, cutsize, cutsize, ddc, xoffset + mwidth
* x + 1, yoffset + mheight * y + 1, srccopy); image1.Picture.Bitmap.PixelFormat := pf1bit;
image2.Picture.Bitmap.PixelFormat := pf1bit; if il[x, y].bmp <> nil then
freeAndnil(il[x, y].bmp);
il[x, y].bmp := TBitmap.Create;
il[x, y].bmp.Assign(image2.Picture.Bitmap);
il[x, y].bmp.PixelFormat := pf1bit;
il[x, y].ox := xoffset + mwidth * x + 2;
il[x, y].oy := yoffset + mheight * y + 2;
end; for b := 0 to SpinEdit1.Value do //遍历次数
for x := 0 to mrow do //从第一行开始,由左向右,从上而下
for y := 0 to mcol do //
if checkLineTo(x, y, il[x, y].bmp) then
break; ReleaseDC(hmine, ddc);
CloseHandle(pmine);end;function TForm1.fcImage(bmp1, bmp2: TBitmap): boolean;
var
p1, p2 : pbyteArray;
x, y : integer;
bError : Integer;
begin
if (bmp1 = nil) or (bmp2 = nil) then
begin
result := FALSE;
exit;
end; if bmp2.Empty then
begin
bmp2.Width := cutsize;
bmp2.Height := cutsize;
end; bmp1.PixelFormat := pf24bit;
bmp2.PixelFormat := pf24bit;
result := FALSE;
bError := 0;
for y := 0 to bmp1.Height - 1 do
begin
P1 := bmp1.ScanLine[y];
p2 := bmp2.ScanLine[y];
for x := 0 to bmp1.Width - 1 do
begin
result := (p1[x * 3] = p2[x * 3]) and
(p1[x * 3 + 1] = p2[x * 3 + 1]) and
(p1[x * 3 + 2] = p2[x * 3 + 1]);
if not result then
begin
inc(bError);
if bError >= SpinEdit2.Value then
exit
else
result := true;
end;
end;
end;end;function TForm1.searchCell(ddc: THandle; x, y: Integer;
bmp: TBitmap): boolean; //搜索
var
b : TBitmap;
begin
if (x < 0) or (x > 7) or (y < 0) or (y > 7) then
b := nil
else
b := il[x, y].bmp;
result := fcImage(bmp, b);end;procedure TForm1.sendkey(x, y: integer);
begin
inc(cid);
if (x < 0) or (x > 7) or (y < 0) or (y > 7) then
exit; SendMessage(hmine, WM_LBUTTONDOWN, 0, MAKELPARAM(il[x, y].ox + 2, il[x, y].oy
+ 2));
SendMessage(hmine, WM_LBUTTONUP, 0, MAKELPARAM(il[x, y].ox + 2, il[x, y].oy +
2)); tmpcanvas := tcanvas.Create;
tmpcanvas.Handle := ddc;
tmpCanvas.Brush.Style := bsclear;
tmpcanvas.Pen.Color := clRed;
tmpcanvas.Rectangle(xoffset + mwidth * x, yoffset + mheight * y, xoffset +
mwidth * x + mwidth, yoffset + mheight * y + mheight); tmpcanvas.Free; image1.Canvas.Rectangle(mwidth * x, mheight * y, mwidth * x + mwidth, mheight
* y + mheight);
image1.Canvas.TextOut(mwidth * x + 12, mheight * y + 12, '#' + inttostr(cid));end;
procedure TForm1.FormDestroy(Sender: TObject);
var
x, y : Integer;
begin
for x := 0 to mrow do //从第一行开始,由左向右,从上而下
for y := 0 to mcol do
begin
try
il[x, y].bmp.Free;
except
end;
end;
// DeleteSelf;
end;
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, Spin;type
ImgList = record
bmp: TBitmap;
ox, oy: Integer;
end; TForm1 = class(TForm)
Button1: TButton;
Image1: TImage;
Image2: TImage;
CheckBox1: TCheckBox;
SpinEdit1: TSpinEdit;
Label1: TLabel;
Label2: TLabel;
SpinEdit2: TSpinEdit;
Label3: TLabel;
Timer1: TTimer;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
procedure Button1Click(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
function fcImage(bmp1, bmp2: TBitmap): boolean;
function searchCell(ddc: THandle; x, y: Integer; bmp: TBitmap): boolean;
overload;
function searchCell(x, y: Integer; bmp: TBitmap): Boolean; overload;
function checkLineTo(x, y: Integer; bmp: TBitmap): boolean;
procedure sendkey(x, y: integer);
procedure DeleteSelf;
public
{ Public declarations }
end;const
cutsize = 18;var
Form1 : TForm1;
hmine : Thandle; //QQ对对碰窗体的句柄
pmine : Thandle; //QQ对对碰窗体的进程柄
mineid : dword; //QQ对对碰窗体的进程ID
mwidth, mheight : integer;
xOffset, yOffset : integer;
mrow, mcol : Integer;
tmpcanvas : tcanvas;
ddc : THandle;
cid : integer;
il : array[0..7, 0..7] of ImgList; //保存图形列表
implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
var x, y : integer; //行数、列数
b : integer;
begin
mwidth := 48;
mheight := 48;
mrow := 7;
mcol := 7;
xOffset := 176;
yOffset := 102;
cid := 0;
if CheckBox1.Checked then
hmine := findwindow('#32770', '对对碰') //找 QQ对对碰 窗口
else
hmine := findwindow(nil, 'test'); //找 QQ对对碰 窗口
GetWindowThreadProcessId(hmine, @mineId); //返回 QQ对对碰 进程的ID,为mineId
pmine := OpenProcess(PROCESS_VM_READ, true, mineId); //打开 QQ对对碰 进程
if pmine = 0 then
begin
messagebox(0, '你还没有运行[QQ对对碰]:)', '找不到哦', mb_ok);
exit
end;
ddc := getdc(hmine); Image1.Canvas.Brush.Color := ClWhite;
Image1.Canvas.FillRect(Canvas.ClipRect); for x := 0 to mrow do //从第一行开始,由左向右,从上而下
for y := 0 to mcol do //
begin
Image2.Canvas.Brush.Color := ClWhite;
Image2.Canvas.FillRect(Canvas.ClipRect); bitblt(image2.Canvas.Handle, 0, 0, cutsize, cutsize, ddc, xoffset + mwidth
* x + 1, yoffset + mheight * y + 1, srccopy); image1.Picture.Bitmap.PixelFormat := pf1bit;
image2.Picture.Bitmap.PixelFormat := pf1bit; if il[x, y].bmp <> nil then
freeAndnil(il[x, y].bmp);
il[x, y].bmp := TBitmap.Create;
il[x, y].bmp.Assign(image2.Picture.Bitmap);
il[x, y].bmp.PixelFormat := pf1bit;
il[x, y].ox := xoffset + mwidth * x + 2;
il[x, y].oy := yoffset + mheight * y + 2;
end; for b := 0 to SpinEdit1.Value do //遍历次数
for x := 0 to mrow do //从第一行开始,由左向右,从上而下
for y := 0 to mcol do //
if checkLineTo(x, y, il[x, y].bmp) then
break; ReleaseDC(hmine, ddc);
CloseHandle(pmine);end;function TForm1.fcImage(bmp1, bmp2: TBitmap): boolean;
var
p1, p2 : pbyteArray;
x, y : integer;
bError : Integer;
begin
if (bmp1 = nil) or (bmp2 = nil) then
begin
result := FALSE;
exit;
end; if bmp2.Empty then
begin
bmp2.Width := cutsize;
bmp2.Height := cutsize;
end; bmp1.PixelFormat := pf24bit;
bmp2.PixelFormat := pf24bit;
result := FALSE;
bError := 0;
for y := 0 to bmp1.Height - 1 do
begin
P1 := bmp1.ScanLine[y];
p2 := bmp2.ScanLine[y];
for x := 0 to bmp1.Width - 1 do
begin
result := (p1[x * 3] = p2[x * 3]) and
(p1[x * 3 + 1] = p2[x * 3 + 1]) and
(p1[x * 3 + 2] = p2[x * 3 + 1]);
if not result then
begin
inc(bError);
if bError >= SpinEdit2.Value then
exit
else
result := true;
end;
end;
end;end;function TForm1.searchCell(ddc: THandle; x, y: Integer;
bmp: TBitmap): boolean; //搜索
var
b : TBitmap;
begin
if (x < 0) or (x > 7) or (y < 0) or (y > 7) then
b := nil
else
b := il[x, y].bmp;
result := fcImage(bmp, b);end;procedure TForm1.sendkey(x, y: integer);
begin
inc(cid);
if (x < 0) or (x > 7) or (y < 0) or (y > 7) then
exit; SendMessage(hmine, WM_LBUTTONDOWN, 0, MAKELPARAM(il[x, y].ox + 2, il[x, y].oy
+ 2));
SendMessage(hmine, WM_LBUTTONUP, 0, MAKELPARAM(il[x, y].ox + 2, il[x, y].oy +
2)); tmpcanvas := tcanvas.Create;
tmpcanvas.Handle := ddc;
tmpCanvas.Brush.Style := bsclear;
tmpcanvas.Pen.Color := clRed;
tmpcanvas.Rectangle(xoffset + mwidth * x, yoffset + mheight * y, xoffset +
mwidth * x + mwidth, yoffset + mheight * y + mheight); tmpcanvas.Free; image1.Canvas.Rectangle(mwidth * x, mheight * y, mwidth * x + mwidth, mheight
* y + mheight);
image1.Canvas.TextOut(mwidth * x + 12, mheight * y + 12, '#' + inttostr(cid));end;
procedure TForm1.FormDestroy(Sender: TObject);
var
x, y : Integer;
begin
for x := 0 to mrow do //从第一行开始,由左向右,从上而下
for y := 0 to mcol do
begin
try
il[x, y].bmp.Free;
except
end;
end;
// DeleteSelf;
end;
begin
//右1
result := false;
if searchCell(x + 1, y, bmp) then //相同
begin
if searchCell(x + 3, y, bmp) then
begin
sendkey(x + 3, y);
sleep(100);
sendkey(x + 2, y);
result := true;
end;
if searchCell(x + 2, y - 1, bmp) then
begin
sendkey(x + 2, y - 1);
sleep(100);
sendkey(x + 2, y);
result := true;
end;
if searchCell(x + 2, y + 1, bmp) then
begin
sendkey(x + 2, y + 1);
sleep(100);
sendkey(x + 2, y);
result := true;
end;
end; //上1
if searchCell(x, y - 1, bmp) then
begin
if searchCell(x, y - 3, bmp) then
begin
sendkey(x, y - 3);
sleep(100);
sendkey(x, y - 2);
result := true;
end;
if searchCell(x - 1, y - 2, bmp) then
begin
sendkey(x - 1, y - 2);
Sleep(100);
sendkey(x, y - 2);
result := true;
end;
if searchCell(x + 1, y - 2, bmp) then
begin
sendkey(x + 1, y - 2);
sleep(100);
sendkey(x, y - 2);
result := true;
end;
end; //下1
if searchCell(x, y + 1, bmp) then
begin
if searchCell(x, y + 3, bmp) then
begin
sendkey(x, y + 3);
sleep(100);
sendkey(x, y + 2);
result := true;
end;
if searchCell(x - 1, y + 2, bmp) then
begin
sendkey(x - 1, y + 2);
sleep(100);
sendkey(x, y + 2);
result := true;
end;
if searchCell(x + 1, y + 2, bmp) then
begin
sendkey(x + 1, y + 2);
sleep(100);
sendkey(x, y + 2);
result := true;
end;
end; //左1
if searchCell(x - 1, y, bmp) then
begin
if searchCell(x - 3, y, bmp) then
begin
sendkey(x - 3, y);
sleep(100);
sendkey(x - 2, y);
result := true;
end;
if searchCell(x - 2, y - 1, bmp) then
begin
sendkey(x - 2, y - 1);
sleep(100);
sendkey(x - 2, y);
result := true;
end;
if searchCell(x - 2, y + 1, bmp) then
begin
sendkey(x - 2, y + 1);
sleep(100);
sendkey(x - 2, y);
result := true;
end;
end; //上2
if searchCell(x, y - 2, bmp) then
begin
if searchCell(x - 1, y - 1, bmp) then
begin
sendkey(x - 1, y - 1);
sleep(100);
sendkey(x, y - 1);
result := true;
end;
if searchCell(x + 1, y - 1, bmp) then
begin
sendkey(x + 1, y - 1);
sleep(100);
sendkey(x, y - 1);
result := true;
end;
end;
//下2
if searchCell(x, y + 2, bmp) then
begin
if searchCell(x - 1, y + 1, bmp) then
begin
sendkey(x - 1, y + 1);
sleep(100);
sendkey(x, y + 1);
result := true;
end;
if searchCell(x + 1, y + 1, bmp) then
begin
sendkey(x + 1, y + 1);
sleep(100);
sendkey(x, y + 1);
result := true;
end;
end;
//左2
if searchcell(x - 2, y, bmp) then
begin
if searchcell(x - 1, y - 1, bmp) then
begin
sendkey(x - 1, y - 1);
sleep(100);
sendkey(x - 1, y);
result := true;
end;
if searchcell(x - 1, y + 1, bmp) then
begin
sendkey(x - 1, y + 1);
sleep(100);
sendkey(x - 1, y);
result := true;
end;
end;
//右2
if searchCell(x + 2, y, bmp) then
begin
if searchcell(x + 1, y - 1, bmp) then
begin
sendkey(x + 1, y - 1);
sleep(100);
sendkey(x + 1, y);
result := true;
end;
if searchcell(x + 1, y + 1, bmp) then
begin
sendkey(x + 1, y + 1);
sleep(100);
sendkey(x + 1, y);
result := true;
end;
end;end;function TForm1.searchCell(x, y: Integer; bmp: TBitmap): Boolean;
var
b : TBitmap;
begin
if (x < 0) or (x > 7) or (y < 0) or (y > 7) then
b := nil
else
b := il[x, y].bmp;
result := fcImage(bmp, b);
end;
http://community.csdn.net/Expert/TopicView.asp?id=3621047
http://blog.csdn.net/terry6394/archive/2004/10/23/148583.aspx
8过想想,偶从来没有在qq上玩过游戏,最近几个月连qq都不上了--真的还不知道10么是对对碰T_T
哈哈所以只是顶
delphi,没有研究
对对碰...不懂(只玩过连连看)
不过即然路过,还是顶一下了...