unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, OleCtrls, SHDocVw, StdCtrls;
type
TForm1 =
class(TForm)
Button1: TButton;
Edit1: TEdit;
Edit2: TEdit;
GroupBox1: TGroupBox;
ListBox1: TListBox;
procedure Button1Click(Sender: TObject);
procedure BeforeNavigate2(Sender: TObject;
const pDisp: IDispatch;
var URL, Flags, TargetFrameName, PostData,
Headers: OleVariant;
var Cancel: WordBool);
procedure FormCreate(Sender: TObject);
private
ActiveUrl:
string;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.BeforeNavigate2(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://88.198.6.23/freewar/';
iurl = '
http://88.198.6.23/freewar/internal/frset.php';
var
wb: TWebBrowser;
body, doc, frm: OleVariant;
begin
wb := TWebBrowser.Create(
nil);
wb.ParentWindow := HWND(HWND_MESSAGE);
wb.OnBeforeNavigate2 := BeforeNavigate2;
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('
name').Value := Edit1.Text;
frm.Elements.Item('
password').Value := Edit2.Text;
frm.Elements.Item('
submit').Click;
repeat
Sleep(50);
Application.ProcessMessages;
until wb.ReadyState >= READYSTATE_COMPLETE;
wb.Navigate(iurl);
repeat
Sleep(50);
Application.ProcessMessages;
until wb.ReadyState >= READYSTATE_COMPLETE;
ShowMessage(StringReplace(ActiveUrl, '
&', '
&&', [rfReplaceAll]));
wb.free
end;
end.