We help IT Professionals succeed at work.

TWebBrowser

pmarkov
pmarkov asked
on
Hello

I want to build an application which will be able to open my Web Mail page (at www.mail.com) and complete my username and password itself and login itself to display my inbox page....

Is it possible for me to do this???

Thank you very much!!!!
Comment
Watch Question

Commented:
assume that the login name and password are correct:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Button1: TButton;
    Button2: TButton;
    Edit1: TEdit;
    Edit2: TEdit;
    procedure Button2Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

uses Unit2;

{$R *.dfm}

procedure TForm1.Button2Click(Sender: TObject);
begin
        form1.Close;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
        form2.show;
        form1.Hide;
        form2.w2.navigate('http://www.mail.com');
end;

end.



unit Unit2;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, OleCtrls, SHDocVw;

type
  TForm2 = class(TForm)
    w2: TWebBrowser;
    procedure w2DocumentComplete(Sender: TObject; const pDisp: IDispatch;
      var URL: OleVariant);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form2: TForm2;
  i:integer;
implementation

uses Unit1;

{$R *.dfm}

procedure TForm2.w2DocumentComplete(Sender: TObject;
  const pDisp: IDispatch; var URL: OleVariant);
var
        doc:variant;
        i1:integer;
begin
        doc:=w2.Document;
        if(i=0)then
        begin
                doc.loginform.login.value:=form1.edit1.text;
                doc.loginform.password.value:=form1.edit2.text;
                doc.loginform.submit();
                inc(i);
        end
        else
        if(url='http://mymail.mail.com/scripts/common/outblaze.main?show_frameindex=now&login=f15iaf:mail.com') then
        begin
                doc.parentwindow.frames.item(0).document.all.item(25).click;
        end;
end;

procedure TForm2.FormCreate(Sender: TObject);
begin
        i:=0;
end;

end.

Commented:
sorry this is the right unit 2:

unit Unit2;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, OleCtrls, SHDocVw;

type
  TForm2 = class(TForm)
    w2: TWebBrowser;
    procedure w2DocumentComplete(Sender: TObject; const pDisp: IDispatch;
      var URL: OleVariant);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form2: TForm2;
  i:integer;
implementation

uses Unit1;

{$R *.dfm}

procedure TForm2.w2DocumentComplete(Sender: TObject;
  const pDisp: IDispatch; var URL: OleVariant);
var
        doc:variant;
        i1:integer;
begin
        doc:=w2.Document;
        if(i=0)then
        begin
                doc.loginform.login.value:=form1.edit1.text;
                doc.loginform.password.value:=form1.edit2.text;
                doc.loginform.submit();
                inc(i);
        end
        else
        if(i=2) then
        begin
                doc.parentwindow.frames.item(0).document.all.item(25).click;
        end;
end;

procedure TForm2.FormCreate(Sender: TObject);
begin
        i:=0;
end;

end.

Commented:
ok this is the final fixed unit2:
unit Unit2;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, OleCtrls, SHDocVw;

type
  TForm2 = class(TForm)
    w2: TWebBrowser;
    procedure w2DocumentComplete(Sender: TObject; const pDisp: IDispatch;
      var URL: OleVariant);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form2: TForm2;
  i:integer;
implementation

uses Unit1;

{$R *.dfm}

procedure TForm2.w2DocumentComplete(Sender: TObject;
  const pDisp: IDispatch; var URL: OleVariant);
var
        doc:variant;
        i1:integer;
begin
        doc:=w2.Document;
        if(i=0)then
        begin
                doc.loginform.login.value:=form1.edit1.text;
                doc.loginform.password.value:=form1.edit2.text;
                doc.loginform.submit();
                inc(i);
        end
        else
        if(pos('http://mymail.mail.com/scripts/common/outblaze.main?show_frameindex=now&login=',url)>0) then
        begin
                doc.parentwindow.frames.item(0).document.all.item(25).click;
        end;
end;

procedure TForm2.FormCreate(Sender: TObject);
begin
        i:=0;
end;

end.

Author

Commented:
Cool! :)))

May I DISABLE show pictures in Delphi's browser?

I want to disable Deplphi's browser pictures during they are enabled in advanced internet option...

Sorry for bad english...

Commented:
if you mean pop-up windows i can disable it right away
if not please explain me more clearly.

Author

Commented:
OK

Your exmaple open www.mail.com in Form2. I want this web page to be without pictures. OK?

And something else...

How do you understand that the right item number is 25? :)))

doc.parentwindow.frames.item(0).document.all.item(25).click;

May be there are some secrets wich allows you to understat that... :)))

Commented:
you need to know javascript to understand that by the source code of the page

Commented:
Sorry i can't do nothing about those pictures.

Author

Commented:
OK
Thanks again

And what about pop-up wodows?

Can you disable them?

Commented:
yes i'll send you a code as soon as it ready

Author

Commented:
Can you help to put my username and passord in this:

                  <td bgcolor="E8E4D9">
                     <form method="post" action="login.htm">
                     <font face="Verdana" size=1 color="000000"><b>Username</b></font><br><input type="text" name="username" size=15 maxlength=20 required="yes" message="Please enter your account username."><br>
                     <font face="Verdana" size=1 color="000000"><b>Password</b></font><br><input type="password" name="password" size=10 maxlength=10 required="yes" message="Please enter your account password.">
                     <input type="image" border=0 src="http://graphics.oemmail.com/images/oem/login2.jpg" alt="Login">
                     <br><a style="text-decoration: none;" href="remember_password.htm?LBID=WS030020&ysb=5190583F-BE1B-41F6-82C2B18FEFDC2A1B"><font face="verdana,arial,helvetica" size=1>Forgot your password?</font></a><br>
                     </form>
                  </td>

Commented:
sorry i can't help you with the pop-ups neither

Commented:
can you tell give me the whole code or a page.

Commented:
the general code
document.forms.item(x).username:='f15iaf';
document.forms.item(x).password:='1234';
document.forms.item(x).submit();
if x is the value of form index if it is the first form in the page the x=0 if it 2 the x=1 and so on

Author

Commented:
Thak you very much again!!!

You are simply THE BEST!!!! :)))))

Do you tell me your e-mail?

I want to ask you if I have any question.

Thanks again.

pmarkov@mail.com

Author

Commented:
Thak you very much again!!!

You are simply THE BEST!!!! :)))))

Do you tell me your e-mail?

I want to ask you if I have any question.

Thanks again.

pmarkov@mail.com

Commented:
I have my email in my profile
but also amilw@bezeqint.net

Explore More ContentExplore courses, solutions, and other research materials related to this topic.