ID,Passwordの入力が煩わしいので、プログラムからURL,ID,Passwordを与えて
Webbrowserコンポーネントに表示、またはInternet Explorerを起動するには
どうすればいいのですか?
又は、
ShellExecute(Handle, 'open', PChar('https://fx.rakuten-sec.co.jp/members/'), nil, nil, SW_SHOW) ;
で表示されるID,PasswordボックスにハードコーディングしたID,Passwordを送り込むには、
どうすればいいのですか?
下記のサンプルでは Button1 をクリックすると www.google.co.jp を表示し、
自動的に検索項目に delphi を入力し Google検索 のボタンを押します
unit Unit3;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, MSHTML, OleCtrls, SHDocVw, StdCtrls;
type
TForm3 = class(TForm)
WebBrowser1: TWebBrowser;
Button1: TButton;
procedure WebBrowser1DocumentComplete(ASender: TObject;
const pDisp: IDispatch; var URL: OleVariant);
procedure Button1Click(Sender: TObject);
private
{ Private 宣言 }
public
{ Public 宣言 }
end;
var
Form3: TForm3;
isNavigate : Boolean;
implementation
{$R *.dfm}
procedure TForm3.Button1Click(Sender: TObject);
begin
WebBrowser1.Navigate('http://www.google.co.jp/');
isNavigate := True;
end;
procedure TForm3.WebBrowser1DocumentComplete(ASender: TObject;
const pDisp: IDispatch; var URL: OleVariant);
var
HTMLDoc2 : iHTMLDocument2;
HTMLInputElement : iHTMLInputElement;
HTMLInputImageEvent : HTMLInputImageEvents;
begin
if isNavigate = True then
begin
HTMLdoc2 := Webbrowser1.document as IHTMLDocument2;
HTMLInputElement := HTMLDoc2.All.Item ('q',0) as iHTMLInputElement;
HTMLInputElement.Set_Value ('delphi');
HTMLdoc2 := Webbrowser1.document as IHTMLDocument2;
HTMLInputElement := HTMLDoc2.All.Item ('btnG',0) as iHTMLInputElement;
HTMLInputElement.Form.Submit;
end;
isNavigate := False;
end;
end.
追加
('q',0)
の q は <input name=q の q であり
('btnG',0)
の btnG は <input name=btmG です
自動ログインしたいページのHTMLを調べてください。
HTMLの解析に手間取りましたが、
教えていただきましたサンプルコードで、解決できました。
KHE00221様、ありがとうどざいました。
ツイート | ![]() |