核心提示:procedure TForm1.Button2Click(Sender: TObject);var Doc,FrameDoc:IHTMLDocument2; Login:IHTMLElement;...
procedure TForm1.Button2Click(Sender: TObject);var
Doc,FrameDoc:IHTMLDocument2;
Login:IHTMLElement;
QQNumber,QQPassword,VerifyCode:IHTMLInputElement;
Frame:IWebBrowser2;
begin
while WebBrowser1.ReadyState<>4 do
Application.ProcessMessages;
if Succeeded(WebBrowser1.Document.QueryInterface(IHTMLDocument2,Doc)) then
begin
if Succeeded(Doc.all.item('login_frame',varEmpty).QueryInterface(IWebBrowser2,Frame)) then
begin
if Succeeded(Frame.Document.QueryInterface(IHTMLDocument2,FrameDoc)) then
begin
if Succeeded(FrameDoc.all.item('u',varEmpty).QueryInterface(IHTMLInputElement,QQNumber)) then
begin
QQNumber.value:='QQ号码';
end;
if Succeeded(FrameDoc.all.item('p',varEmpty).QueryInterface(IHTMLInputElement,QQPassword)) then
begin
QQPassword.value:='QQ密码';
end;
if Succeeded(FrameDoc.all.item('verifycode',varEmpty).QueryInterface(IHTMLInputElement,VerifyCode)) then
begin
VerifyCode.value:='验证码';
end;
if Succeeded(FrameDoc.all.item('login_button',varEmpty).QueryInterface(IHTMLElement,Login)) then
begin
Login.click;
while FrameDoc.ReadyState<>'complete' do
Application.ProcessMessages;
end;
end;
end;
end;
end;