uses : MSHTML_TLB wb: Twebbrowser
////////////////////////////////////////////////////////
// 功能:模拟按下网页中的某一个按钮,根据Type和Name判断
// 参数:
// ButtonName: 按钮名
// 日期:2001-12-31
////////////////////////////////////////////////////////
procedure TfrmMain.PressButton(ButtonName: String);
var
spDisp: IDispatch;
j: integer;
IE1: IWebBrowser2;
IDoc1: IHTMLDocument2;
iELC : IHTMLElementCollection ;
sn,Bt : string;
HtmlInputEle : IHTMLInputElement;
itemSec: IHTMLElement;
begin
ButtonName := UpperCase(ButtonName);
spdisp := wb.Application;
if spDisp = nil then exit;
spDisp.QueryInterface( iWebBrowser2, IE1);
if IE1 <> nil then
begin
IE1.Document.QueryInterface(IHTMLDocument2,iDoc1);
if iDoc1 <> nil then
begin
ielc:=idoc1.Get_all;
for j:=0 to ielc.length-1 do
begin
Application.ProcessMessages;
spDisp := ielc.item(J, 0);
spDisp.QueryInterface(IHTMLElement ,itemSec);
if (SUCCEEDED(spDisp.QueryInterface(IHTMLInputElement ,HtmlInputEle))) and
(SUCCEEDED(spDisp.QueryInterface(IHTMLElement ,itemSec))) then
with HtmlInputEle do
begin
sn := HtmlInputEle.name;
sn := UpperCase(sn);
Bt := HtmlInputEle.Get_type_;
Bt := UpperCase(Bt);
// showmessage(sn + ' ' + bt);
if (StrComp(PChar(sn),PChar(ButtonName))=0) and
(StrComp(PChar(Bt),'SUBMIT')=0) then
begin
itemsec.click;
break;
end;
end;
end; //END FOR
end;
end;
end;
解决方案 »
- ListView中item的图片不显示
- 如何取得explorer.exe的handle
- 请问哪儿有关于DELPHI 6 处理压缩文件的资料或书籍下载?
- 帮忙看看[Error] CopyFile.pas(83): '.' expected but '(' found 是什么原因?
- 请各位高手看看这个问题!
- 高手们,就就哦把
- 串口通讯
- dbgrideh中的打印控件Tprintdbgrideh在打印设置时如何自定义纸张大小?
- 高手拿分,
- C++ Builder 5的下栽(无内容)
- 请问 DELPHI 6连接*.DBF(VF 6)文件,用什么方式比较好呢?
- 忘各位告知:ADO连接请问怎样让所有的DB组件禁用....如果禁用ADOTABLE1.????...如果是取消禁止那..
span class="form"><input type="image" name="ok" value="确定" src="images/go.gif" width="37" height="10"></span>
我去试一试,不过这样我还要网页里面填数据,Post方法是比较麻烦。 Post数据包的格式是什么?能不能自己生成包的格式,然后发送请求?
////////////////////////////////////////////////////////
// 功能:向网页中填写内容
// 参数:
// 日期:2001-12-31
////////////////////////////////////////////////////////
procedure TfrmMain.PutData;
var
spDisp: IDispatch;
j: integer;
IE1: IWebBrowser2;
IDoc1: IHTMLDocument2;
iELC : IHTMLElementCollection ;
S2,sn : string;
HtmlInputEle : IHTMLInputElement;
// HtmlSelEle : IHTMLSelectElement;
begin
spdisp := wb.Application;
if spDisp = nil then exit;
spDisp.QueryInterface( iWebBrowser2, IE1 );
if IE1 <> nil then
begin
IE1.Document.QueryInterface(IHTMLDocument2,iDoc1);
if iDoc1 <> nil then
begin
ielc:=idoc1.Get_all;
for j:=0 to ielc.length-1 do
begin
Application.ProcessMessages;
spDisp := ielc.item(J, 0);
if SUCCEEDED(spDisp.QueryInterface(IHTMLInputElement ,HtmlInputEle))then
with HtmlInputEle do
begin
S2:=Type_;
S2:=UpperCase(S2);
if StrComp(PChar(S2),'TEXT')=0 then
begin
sn := name;
sn := UpperCase(sn);
if StrComp(PChar(sn),'CUSTCODE')=0 then value :='12345656';
end;
if StrComp(PChar(S2),'PASSWORD')=0 then
begin
sn := name;
sn := UpperCase(sn);
if StrComp(PChar(sn),'CUSTPASS')=0 then value :='1234';
end;
end;
end; //END FOR
end;
end;
end;