邦定没有办法,在WebBrower里面点击按钮就有办法,不管楼主要不要,我先帖上
界面上放一个WebBrower1和一个BitBtn1
unit Main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, OleCtrls, SHDocVw, MSHTML;
type
TForm1 = class(TForm)
WebBrowser1: TWebBrowser;
BitBtn1: TBitBtn;
procedure BitBtn1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure WebBrowser1DownloadComplete(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
FDownComplete : Boolean;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.BitBtn1Click(Sender: TObject);
var
ovDoc, ovInput, ovTag: OleVariant;
I : Integer;
begin
if not FDownComplete then Application.MessageBox('网页正在下载中,请稍后……', '提示', MB_OK + MB_ICONINFORMATION)
else begin
ovDoc := WebBrowser1.Document;
ovInput := ovDoc.all.tags('FORM');
for I := 0 to ovInput.length -1 do begin
ovTag := ovInput.item(I);
if (ovTag.Type = 'text') or (ovTag.Type = 'password') then begin
if ovTag.Name = 'ID' then ovTag.Value := '113';
if ovTag.Name = 'passwd' then ovTag.Value := '******';
end
else if ovTag.Type = 'image' then begin
if ovTag.alt = '登录ChinaRen' then
ovTag.Click;
end;
end;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
FDownComplete := False;
WebBrowser1.Navigate('http://www.cng.com.cn/');
end;
procedure TForm1.WebBrowser1DownloadComplete(Sender: TObject);
begin
FDownComplete := True;
end;
end.