Delphi自动填写IE输入框
来源:互联网 发布:linux vim 保存并退出 编辑:程序博客网 时间:2024/05/22 13:02
//自动填写主要过程;
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
//先填写当前页;
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;
0 0
- Delphi自动填写IE输入框
- 实现Flash的TextInput输入框自动填写功能
- 输入框只能填写数字,其他值自动清空
- 输入框填写提示
- 自动输入填写qq 旺旺密码
- HTML仿CS结构填写注册码,自动切换下一输入框!
- input required字段;django input输入框不填写会自动变红如何修改
- mfc 直接操作ie浏览器自动填写表单实例
- 模仿IE自动完成功能,读取输入框存取记录
- [Delphi] 如何做一个可以帮我向网页自动填写用户名密码的软件啊??
- IE输入框问题解决!
- 自动表单填写
- 自动填写版权信息
- 自动表单填写
- 自动填写网页表单
- vfp 自动填写网页
- 自动填写excel表格
- 自动填写日志
- Caffe+cuda7.5+cuDNN v5.1 在windows10下安装
- [转载]Android HTTPS SSL双向验证
- Sublime Text 3 中文乱码解决方案
- Ubuntu中软件卸载方法
- eclipse搭建 maven项目
- Delphi自动填写IE输入框
- Android利用canvas画各种图形(点、直线、弧、圆、椭圆、文字、矩形、多边形、曲线、圆角矩形)
- CNN可视化
- fmt:formatNumber use locale display negative currency in -$xxx.xx format in JSTL
- python-返回函数的理解
- 团体程序设计天梯赛L2-022 重排链表
- iOS进阶10--动态库和动态库
- 网站总体开发概念
- 最大流算法理解笔记