请教delphi自动填写网页表单框问题
表单如下:<formid="form1"name="form1"method="post"action=""><inputname="username"type="tex...
表单如下:
<form id="form1" name="form1" method="post" action="">
<input name="username" type="text" id="username" />
<input name="password" type="text" id="password" />
<input type="submit" name="Submit" value="提交" />
</form>
为了不至于每次都手工输入用户名admin和密码admin,我想用delphi写个程序,放了个webbrower空间,点个按钮就自动把用户名和密码输入进去了。怎么实现?(我百度里搜了好多文章,都没成功)
WebBrowser1.OleObject.Document.All.Item('admin',0).Value:= 'shandongbuyi';老是提示错误 展开
<form id="form1" name="form1" method="post" action="">
<input name="username" type="text" id="username" />
<input name="password" type="text" id="password" />
<input type="submit" name="Submit" value="提交" />
</form>
为了不至于每次都手工输入用户名admin和密码admin,我想用delphi写个程序,放了个webbrower空间,点个按钮就自动把用户名和密码输入进去了。怎么实现?(我百度里搜了好多文章,都没成功)
WebBrowser1.OleObject.Document.All.Item('admin',0).Value:= 'shandongbuyi';老是提示错误 展开
1个回答
展开全部
var
Doc:IHTMLDocument2;
UserInputeLement,PwdInputeLement:IHTMLInputElement;
begin
doc:=webbrowser1.document as ihtmldocument2;
UserInputeLement :=(doc.all.item('username',0) as IHTMLInputElement);
UserInputeLement.value :=User; //用户名
PwdInputeLement :=(doc.all.item('password',0) as ihtmlinputelement);
PwdInputeLement.value :=Password; //密码
end;
Doc:IHTMLDocument2;
UserInputeLement,PwdInputeLement:IHTMLInputElement;
begin
doc:=webbrowser1.document as ihtmldocument2;
UserInputeLement :=(doc.all.item('username',0) as IHTMLInputElement);
UserInputeLement.value :=User; //用户名
PwdInputeLement :=(doc.all.item('password',0) as ihtmlinputelement);
PwdInputeLement.value :=Password; //密码
end;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询