前几天写的一个游戏帐号自动申请程序.(现在的游戏帐号很多是通过网页申请的)
希望对你有帮助.:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, sendword,
Dialogs, StdCtrls, OleCtrls, SHDocVw, mshtml, ActiveX, Buttons, ExtCtrls;
type
TForm1 = class(TForm)
WB1: TWebBrowser;
BitBtn1: TBitBtn;
Panel1: TPanel;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure WB1DownloadComplete(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
appPath: string;
end;
var
Form1: TForm1;
firstrun: Boolean;
implementation
{$R *.dfm}
procedure delays(Delay_Time: Integer);
var
FirstTickCount: real;
begin
FirstTickCount := GetTickCount;
repeat
Application.ProcessMessages;
until ((GetTickCount - FirstTickCount) >= Delay_Time); //delay time
Application.ProcessMessages;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if WB1.Document <> nil then
IHTMLWindow2(WB1.Document).focus
end;
procedure TForm1.FormShow(Sender: TObject);
begin
WB1.Navigate('file:///E:/csw/gametools/regaccount/newreg.htm');
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
var
I: Integer;
str: string;
begin
firstrun := False;
if WB1.Document <> nil then
begin
with (WB1.Application as IOleobject) do
DoVerb(OLEIVERB_UIACTIVATE, nil, WB1, 0, Handle, GetClientRect);
//生成用户名
Randomize;
for I := 1 to 7 do
begin
str := str + Inttostr(Random(GetTickCount));
end;
str := Copy(str, 2, 7);
SendKeys('a');
for i := 1 to length(str) do
SendKeys(copy(str, i, 1)); //user name
Application.ProcessMessages;
keybd_event(vk_tab, mapvirtualkey(vk_tab, 0), 0, 0);
keybd_event(vk_tab, mapvirtualkey(vk_tab, 0), keyeventf_keyup, 0);
application.ProcessMessages;
for i := 1 to length(str) do
SendKeys(copy(str, i, 1)); //first password
Application.ProcessMessages;
keybd_event(vk_tab, mapvirtualkey(vk_tab, 0), 0, 0);
keybd_event(vk_tab, mapvirtualkey(vk_tab, 0), keyeventf_keyup, 0);
Application.ProcessMessages;
for i := 1 to length(str) do // confirm password
SendKeys(copy(str, i, 1));
Application.ProcessMessages;
keybd_event(vk_tab, mapvirtualkey(vk_tab, 0), 0, 0); //jump to regiter button
keybd_event(vk_tab, mapvirtualkey(vk_tab, 0), keyeventf_keyup, 0);
Application.ProcessMessages;
keybd_event(VK_Space, mapvirtualkey(VK_Space, 0), 0, 0); //push space key
keybd_event(VK_Space, mapvirtualkey(VK_Space, 0), keyeventf_keyup, 0);
Application.ProcessMessages;
Edit1.Text:=str;
delays(500);
WB1.Navigate('file:///E:/csw/gametools/regaccount/newreg.htm');
WB1.SetFocus;
keybd_event(vk_tab, mapvirtualkey(vk_tab, 0), 0, 0);
keybd_event(vk_tab, mapvirtualkey(vk_tab, 0), keyeventf_keyup, 0);
end;
end;
procedure TForm1.WB1DownloadComplete(Sender: TObject);
begin
if firstrun then
keybd_event(vk_tab, mapvirtualkey(vk_tab, 0), 0, 0);
keybd_event(vk_tab, mapvirtualkey(vk_tab, 0), keyeventf_keyup, 0);
end;
procedure TForm1.FormCreate(Sender: TObject);
var
DetailHtml: TStrings;
begin
firstrun := True;
appPath := ExtractFilePath(application.ExeName);
DetailHtml := TStringList.Create;
try
DetailHtml.Add('');
finally
DetailHtml.Free;
end;
end;
end.