Delphi自动填写IE输入框

//自动填写主要过程;
procedure TForm1.FillIEForm(aValidatecode: String; bPost: boolean);
procedure DoWithHtmlElement(aElementCollection:IHTMLElementCollection);
var
k:integer;
vk:oleVariant;
Dispatch: IDispatch;
//声明接口;
HTMLInputElement:IHTMLInputElement;
HTMLSelectElement:IHTMLSelectElement;
HTMLOptionElement: IHTMLOptionElement;
HTMLTextAreaElement: IHTMLTextAreaElement;
HTMLFormElement:IHTMLFormElement;
HTMLOptionButtonElement:IHTMLOptionButtonElement;
begin
for k:=0 to aElementCollection.length -1 do//对当前页的所有对象进行循环断定;
begin
Vk:=k;
Application.ProcessMessages;
Dispatch:=aElementCollection.item(Vk,0);
//如果是页面;
if SUCCEEDED(Dispatch.QueryInterface(IHTMLFormElement,HTMLFormElement))then
begin
with HTMLFormElement do//表单
begin
//处理
if bPost then
begin
HTMLFormElement.submit ;//提交所填写的窗体;
exit;
end;
end;
end
//如果是输入框;
else if Succeeded(Dispatch.QueryInterface(IHTMLInputElement,HTMLInputElement)) then
begin
With HTMLInputElement do//单行文本
begin
if (UpperCase(Type_)=''TEXT'') or (UpperCase(Type_)=''PASSWORD'') then//判断输入框类型;
begin
value:=''luowenfu''; //输入名字;
if Name=''Validatecode'' then Value:=aValidatecode;
if Name=''Passwd'' then Value:=''19820128''; //输入密码;
if Name=''Passwd1'' then Value:=''19820128'';
if Name=''e_mail'' then value:=''luowenfu_1982@163.com'';
if Name=''OICQ'' then Value:=''282839896'';
if Name=''width'' then Value:=''40'';
if Name=''height'' then Value:=''40'';
if Name=''myface'' then Value:='''';
end
else if (UpperCase(Type_)=''CHECKBOX'') then//复选框
begin
checked:=true;
end
else if (UpperCase(Type_)=''RADIO'') then//单选框
begin
checked :=true;
end
else if (UpperCase(Type_)=''FILE'') then//选择路径;
begin
HTMLInputElement.defaultValue:=''E:\LWen\Lwen作品\卡片\ExeFile\pic\cat1\3.bmp'';
end;


end;
end
else if Succeeded(Dispatch.QueryInterface(IHTMLSelectElement,HTMLSelectElement)) then
begin
With HTMLSelectElement do//下拉框
begin
selectedIndex :=1;//默认选择第二个;
end;
end
else if Succeeded(Dispatch.QueryInterface(IHTMLTEXTAreaElement,HTMLTextAreaElement)) then
begin
with HTMLTextAreaElement do//多行文本
begin
value :=''向别人学习!再教别人学习!!'';
end;
end
else if Succeeded(Dispatch.QueryInterface(IHTMLOptionElement,HTMLOptionElement)) then
begin
with HTMLOptionElement do//下拉选项
begin
//处理
end;
end
else if SUCCEEDED(Dispatch.QueryInterface(IHTMLOptionButtonElement,HTMLOptionButtonElement))then
begin
//不明
//处理
end
else
//showmessage(''other'');
;
end;
end;
var
HTMLDocument:IHTMLDocument2;//可修改文档;
ElementCollection:IHTMLElementCollection;
Dispatch: IDispatch;
i,j:integer;
FrameWindow:IHTMLWindow2;//框架窗口;
Vi,Vj:OLEVariant;
HTMLFrameBase :IHTMLFrameBase ;
HTMLFrameElement:IHTMLFrameElement ;
HTMLIFrameElement:IHTMLIFrameElement;
begin
HTMLDocument:=IHTMLDocument2(WebBro1.Document);//指定要修改的文档;
if HTMLDocument<>nil then
begin
begin
if HTMLDocument.frames.length =0 then//如果是无框架
begin
ElementCollection:=HTMLDocument.Get_All;
DoWithHtmlElement(ElementCollection);//调用填写过程;
end
else//有框架
begin
//先填写当前页;

ElementCollection:=HTMLDocument.Get_All 

DoWithHtmlElement(ElementCollection);
//再填写框架页;
for j:=0 to HTMLDocument.frames.length -1 do
begin
Vj:=j;
Dispatch:=HTMLDocument.frames.item(Vj);
if Succeeded(Dispatch.QueryInterface(IHTMLWindow2,FrameWindow)) then
begin
DoWithHtmlElement(FrameWindow.document.all);//调用自动填写过程;
end;
End;
end;
end;
end;
end;

================================================================= EtSoftware 软件库: InternetExplorerCtl 项目概述 ================================================================= 软件介绍: 程序通过自动填充功能,填写网页表格完成自动提交,适用于群发博文,邮件等操作。 软件开发由EtSoftware工作室研发。用户可根据设定的配置文件。定时发送相关内容。 程序仅用于学习使用不得用于商业用途,违法规定后果自负。相关版本可以关注EtSoftware 官方网站与博客。如您有好的建议可以通过发送邮件至EtSoftWare@163.com或QQ466814195留言 提出软件修改建议。我们将虚心接受。感谢您对EtSoftware团队的支持! 适用人群: 1,推广人,每天需大量发送博文或留言人群 2,略懂编程人员,使用起来文件,可通过循环生成配置文件。 配置说明: [set] ;step总数 stepcount=10 ;记录步进位置 Idx=0 ;复制次数 times=1 ;以step+index格式书写 index为动作次序 0为起始点 [step0] ;操作命令 ;SETLOCAL 设置URL ;SETLOCALNOBUSY 设置URL 等待前一次加载完成 ;ONCLICK 单击事件 ;INNERTEXT 以innerText填充控件 ;INNERHTML 以innerHTML填充控件 ;SUBMIT 提交表单 cmd=SETLOCAL ;TagName默认为INPUT TagName= ;网页节点 属性标识 默认为NAME属性 AttName= ;网页节点 属性值 AttVal= ;值 支持自动转码如\r\n自动转换成换行回车符 Value=etsoftware.3322.org ;执行前停留时间单位为毫秒 Pretime=1000 软件名:EtSoftWare.InternetExplorerCtl 支持平台:WinXP,Win2000,Win2003,Win7,Win2008,Vista 软件类型:永久免费,绿色版,破解版 开发:半条虫(466814195) 发行:EtSoftWare 网址:EtSoftWare.3322.org 博客:EtSoftWare.blog.163.com 软件未经授权不得用于商业用途,违者必究。 更新日志: 2013-03-15 研发 3012-03-24 内测 ================================================================ 本压缩包不包涵源码,不便之处敬请原谅。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值