【Delphi】写了一个类似小外挂的程序 O(∩_∩)O~

本文介绍了两个程序:A程序通过按钮点击生成随机数,只有特定组合时显示恭喜信息;B程序读取A程序生成的随机数,若不匹配则进行模拟操作。详细展示了程序逻辑与实现。

程序说明:

A程序:点一次按钮,产生一组随机数,只有随机数为4、4、9、9时,才会弹出"可以啦,恭喜啊~"字样。

B程序:读取A程序随机产生的4组数,如果发现不是4、4、9、9,则进行一次虚拟的A程序按键操作。


程序界面:

 


程序代码:

A程序
procedure TForm1.btn2Click(Sender: TObject);
begin
edt1.Text := IntToStr(Random(10));
edt2.Text := IntToStr(Random(10));
edt3.Text := IntToStr(Random(10));
edt4.Text := IntToStr(Random(10));

if (edt1.Text = '4') and (edt2.Text = '4') and (edt3.Text = '9') and (edt4.Text = '9')then
begin
lbl6.Font.Color := clRed;
lbl6.Caption := '可以啦,恭喜啊!!!';
end;

end;
B程序
procedure TForm2.btn1Click(Sender: TObject);
var
Gameh:HWND;
buttonh:HWND;
buttonc:HWND;
i:Integer;
Grp1h:HWND;
edt1h,edt2h,edt3h,edt4h,C:HWND;
text1,text2,text3,text4:ansistring;
p: array[0..254] of ansichar;
begin
Gameh := FindWindow(nil,'Good!!!!');

if Gameh = 0 then
ShowMessage('Error')
else
begin
buttonh := FindWindowEx(Gameh,0,'TButton','btn1');
C:=findwindowex(Gameh,0,'TEdit',0);

i:=0;
while C <> 0 do
begin
if (i=0) then
begin
edt4h := C;
SendMessage(C,WM_GETTEXT,100,integer(@p));
text4 := p;
i := i + 1;
end
else if (i=1) then
begin
edt1h := C;
SendMessage(C,WM_GETTEXT,100,integer(@p));
text1 := p;
i := i + 1;
end
else if (i=2) then
begin
edt2h := C;
SendMessage(C,WM_GETTEXT,100,integer(@p));
text2 := p;
i := i + 1;
end
else
begin
edt3h := C;
SendMessage(C,WM_GETTEXT,100,integer(@p));
text3 := p;
end;

C:=findwindowex(Gameh,c,'TEdit',0);//查找下一个
end;

while not ((text4 = '9') and (text3 = '9') and (text2 = '4') and (text1 = '4')) do
begin
buttonc := FindWindowEx(Gameh,0,'TButton','生成');
if buttonc = 0 then
Exit;

SendMessage(buttonc,WM_LBUTTONDOWN,0,$000F000E);
SendMessage(buttonc,WM_LBUTTONUP,0,$000F000E);

C:=findwindowex(Gameh,c,'TEdit',0);

i:=0;
while C <> 0 do
begin

if (i=0) then
begin
edt4h := C;
SendMessage(C,WM_GETTEXT,100,integer(@p));
text4 := p;
i := i + 1;
end
else if (i=1) then
begin
edt1h := C;
SendMessage(C,WM_GETTEXT,100,integer(@p));
text1 := p;
i := i + 1;
end
else if (i=2) then
begin
edt2h := C;
SendMessage(C,WM_GETTEXT,100,integer(@p));
text2 := p;
i := i + 1;
end
else
begin
edt3h := C;
SendMessage(C,WM_GETTEXT,100,integer(@p));
text3 := p;
i:=0;
end;

C:=findwindowex(Gameh,c,'TEdit',0);//查找下一个
end;
end;


end;
end;




转载于:https://www.cnblogs.com/dabiao/archive/2012/03/03/2378790.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值