unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, OleCtrls, SHDocVw, StdCtrls;
type
TForm1 =
class(TForm)
Button1: TButton;
WebBrowser1: TWebBrowser;
WebBrowser2: TWebBrowser;
procedure WebBrowser1BeforeNavigate2(Sender: TObject;
const pDisp: IDispatch;
var URL, Flags, TargetFrameName, PostData,
Headers: OleVariant;
var Cancel: WordBool);
procedure Button1Click(Sender: TObject);
private
ActiveUrl:
string;
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
uses
MSHTML;
procedure TForm1.WebBrowser1BeforeNavigate2(Sender: TObject;
const pDisp: IDispatch;
var URL, Flags, TargetFrameName, PostData,
Headers: OleVariant;
var Cancel: WordBool);
begin
with Sender
as TWebBrowser
do
if pDisp = DefaultInterface
then
ActiveUrl :=
URL;
end;
procedure TForm1.Button1Click(Sender: TObject);
const
url = '
http://xxxxxxxxx.de/login/login_form';
var
wb: TWebBrowser;
body, doc, frm: OleVariant;
begin
wb := TWebBrowser.Create(
nil);
wb.ParentWindow := HWND(HWND_MESSAGE);
wb.OnBeforeNavigate2 := Webbrowser1.OnBeforeNavigate2;
wb.Navigate(
url);
repeat
Sleep(50);
Application.ProcessMessages;
until wb.ReadyState >= READYSTATE_COMPLETE;
doc := wb.OleObject.Document;
body := doc.body;
frm := doc.Forms.Item(0);
frm.Elements.Item('
__ac_name').Value := '
test';
frm.Elements.Item('
__ac_password').Value := '
test';
frm.Elements.Item('
submit').Click;
repeat
Sleep(50);
Application.ProcessMessages;
until wb.ReadyState >= READYSTATE_COMPLETE;
wb.Free;
ShowMessage(StringReplace(ActiveUrl, '
&', '
&&', [rfReplaceAll]));
end;
end.