Delphi6Pro + WebBrowserで自動的にID,パスワードを入力してログインするには?
http://delphi.sakura.vg/index2.html
こちらのタブブラウザソース(tabbrowser3src.zip)と、
VC++のサンプルを参考に、
http://forums.microsoft.com/MSDN-JA/ShowPost.aspx?PostID=1528887&SiteID=7
>こんにちは。過去のスレッドにWebBrowserコントロールに表示しているホームページ上にあるフォームに値を自動入力する方法がありました。
private void webBrowser1_DocumentCompleted(object sender, ebBrowserDocumentCompletedEventArgs e)
{
if (e.Url.AbsoluteUri == https://login.yahoo.co.jp/config/login?.src=www&.done=http://www.yahoo.co.jp)
{
webBrowser1.Document.All.GetElementsByName("login")[0].InnerText = "ヤフーID";
webBrowser1.Document.All.GetElementsByName("passwd")[0].InnerText = "パスワード";
webBrowser1.Document.Forms[0].InvokeMember("submit");
}
}
なので、
procedure TMainForm.Refresh1Execute(Sender: TObject);
var
doc : IHTMLDocument2;
doc1 : IHTMLDocument;
begin
if (MDIChildCount > 0) and
(TIEWindow(ActiveMDIChild).WebBrowser1.Document <> nil) then
begin
doc := TIEWindow(ActiveMDIChild).WebBrowser1.Document as IHTMLDocument2;
doc1 := TIEWindow(ActiveMDIChild).WebBrowser1.Document as IHTMLDocument;
TIEWindow(ActiveMDIChild).WebBrowser1.Refresh;
if TIEWindow(ActiveMDIChild).WebBrowser1.LocationURL = 'https://www.kaboo.co.jp/controller.cgi?action_kfu_Login=init&req_url=/friends/realtime.htm' then
begin
{①} TIEWindow(ActiveMDIChild).webBrowser1.Document.All.GetElementsByName('login')[0].InnerText = 'ヤフーID';
{②} doc.All.GetElementsByName('login')[0].InnerText = 'ヤフーID';
end;
end;
end;
①は、All以降が未定義になってしまいます
②は、GetElementsByName以降が未定義です。
もしかして、Delphi6世代のタイプライブラリ(Microsoft Internet Control v1.1)は古くて
対応していないのでしょうか?
ツイート | ![]() |