unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, OleCtrls, SHDocVw, StdCtrls;
type
TForm1 = class(TForm)
WebBrowser1: TWebBrowser;
Button1: TButton;
procedure WebBrowser1DocumentComplete(Sender: TObject;
const pDisp: IDispatch; var URL: OleVariant);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.WebBrowser1DocumentComplete(Sender: TObject;
const pDisp: IDispatch; var URL: OleVariant);
var
o : Olevariant;
begin
o := WebBrowser1.OleObject.document.all.item('user',0);//找到登录用户名的输入框
o.value := 'test';
o := WebBrowser1.oleobject.document.all.item('pass',0);//找到登录密码的输入框
o.value := '123456789';
// WebBrowser1.oleobject.document.Forms.Item(0, 0).submit;//第一个表单提交
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
WebBrowser1.Navigate('126.COM');
end;
end.
試下這個自動輸入賬號密碼的吧