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;
请发表评论