在TWebbrowser 中模拟点击一个提交按钮uses MSHTML; //必须引用这个单元var iDoc: IHtmlDocument2; i: integer; ov: OleVariant; iDisp: IDispatch; iColl: IHTMLElementCollection; InputImage: HTMLInputImage; //-----------------form http://blog.csdn.net/laoli/---------------------- begin WebBrowser1.ControlInterface.Document.QueryInterface(IHtmlDocument2, iDoc); if not Assigned(iDoc) then begin Exit; end; ov := 'INPUT'; iDisp := iDoc.all.tags(ov); if Assigned(IDisp) then begin IDisp.QueryInterface(IHTMLElementCollection, iColl); if Assigned(iColl) then begin for i := 1 to iColl.Get_length do begin iDisp := iColl.item(pred(i), 0); iDisp.QueryInterface(HTMLInputImage, InputImage); if Assigned(InputImage) then begin if InputImage.Name = '提交 then // ---------------------------------------如果按钮名是'提交',就填提交,否则填其他 begin InputImage.Click; // ------------模拟点击 end; end; end; end; end; end;
在TWebbrowser 中模拟点击一个提交按钮uses
MSHTML; //必须引用这个单元var
iDoc: IHtmlDocument2;
i: integer;
ov: OleVariant;
iDisp: IDispatch;
iColl: IHTMLElementCollection;
InputImage: HTMLInputImage; //-----------------form http://blog.csdn.net/laoli/----------------------
begin
WebBrowser1.ControlInterface.Document.QueryInterface(IHtmlDocument2, iDoc);
if not Assigned(iDoc) then
begin
Exit;
end;
ov := 'INPUT';
iDisp := iDoc.all.tags(ov);
if Assigned(IDisp) then
begin
IDisp.QueryInterface(IHTMLElementCollection, iColl);
if Assigned(iColl) then
begin
for i := 1 to iColl.Get_length do
begin
iDisp := iColl.item(pred(i), 0);
iDisp.QueryInterface(HTMLInputImage, InputImage);
if Assigned(InputImage) then
begin
if InputImage.Name = '提交 then
// ---------------------------------------如果按钮名是'提交',就填提交,否则填其他 begin
InputImage.Click; // ------------模拟点击 end;
end;
end;
end;
end;
end;