Solved

is there any way to open my IE from delphi with a determined page?

Posted on 2011-03-03
16
210 Views
Last Modified: 2012-05-11
Hello guys

I would like to know if there is any way to open a IE, FF, Chrome with a determined page and insert into this page, into a field html a value.

thanks
0
Comment
Question by:hidrau
  • 7
  • 5
  • 3
  • +1
16 Comments
 
LVL 1

Author Comment

by:hidrau
ID: 35030983
I got this code and maybe it can help to accomplish this task

http://www.cryer.co.uk/brian/delphi/howto_openiespecificetc.htm
0
 
LVL 9

Expert Comment

by:Mahdi78
ID: 35031019
Add ShellAPI to uses clause and open the url like the following:

with IE

ShellExecute(0, 'open', 'IExplore', 'http://www.google.com', nil, SW_SHOW);

with firefox

ShellExecute(0, 'open', 'FireFox', 'http://www.google.com', nil, SW_SHOW);
0
 
LVL 1

Author Comment

by:hidrau
ID: 35031039
Yeah, I can do this with ShellExecute

but I need to insert into a field a value. This field is in the page.

do you know how to do this?
0
 
LVL 19

Expert Comment

by:Thommy
ID: 35031520
How to open the standard browser on a given URL...
http://www.cryer.co.uk/brian/delphi/howto_openbrowserurl.htm
0
 
LVL 9

Expert Comment

by:Mahdi78
ID: 35031538
for example you have Val1 = "aaa" and Val2 "bbb"

You with make your url like the following:

http://yourdomain.com/index.php?val1=aaa&val2=bbb

so shellExecute with IE will be

ShellExecute(0, 'open', 'IExplore', 'http://www.google.com', nil, SW_SHOW);

to get data in your php page usedo not use the function $_GET instead of $_POST,

This is an example with value above

<?
echo "Val1:";
echo($_GET['val1']);
echo"<br>";
echo "Val2:";
echo($_GET['val2']);
?>
0
 
LVL 9

Expert Comment

by:Mahdi78
ID: 35031549
Sorry the shellExecute with IE will be

ShellExecute(0, 'open', 'IExplore', 'http://yourdomain.com/index.php?val1=aaa&val2=bbb', nil, SW_SHOW);
0
 
LVL 14

Expert Comment

by:systan
ID: 35033608
Here's from Eddie; try that;

procedure TForm1.SendPostData;
Var
  aStream: TMemoryStream;
  Params: TStringStream;
begin
  aStream := TMemoryStream.create;
  Params := TStringStream.create('');

  try
    with IdHTTP1 do
    begin
      Params.WriteString(URLEncode('teste=' + 'yes' + '&'));
      Params.WriteString(URLEncode('name=' + 'ivan' + '&'));
      Params.WriteString(URLEncode('number=' + '102'));
      Request.ContentType := 'application/x-www-form-urlencoded';
      try
        Post('http://localhost/teste.asp', Params, aStream);
      except
        on E: Exception do
          showmessage('Error encountered during POST: ' + E.Message);
      end;
    end;
  aStream.WriteBuffer(#0' ', 1);
  aStream.Position := 0;
  Memo1.Lines.LoadFromStream(aStream);
  except
  end;
end;
0
 
LVL 1

Author Comment

by:hidrau
ID: 35035244
Mahdi78:

Unfortunaly I can show to the user the information passed to the link, as you recomended:

www.mysite.com?vari=xxxxx

in my site, there is a hide field that I will insert the value into it, this value will not be displayed to user.

0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 9

Expert Comment

by:Mahdi78
ID: 35035290
Then, you should use IDHttp or webbrowser component
0
 
LVL 1

Author Comment

by:hidrau
ID: 35035542
My delphi is complainting this URLEncode, I don't know how unit it come from

0
 
LVL 1

Author Comment

by:hidrau
ID: 35035620
systan:

I have this error:
Protocol field is empty

this error occurs in this line:
Params.WriteString(TIdURI.URLEncode('cmp1=' + 'oi' + '&'));

I have in my page a field named cmp1, i'd like to put a string into it, anything to test

0
 
LVL 14

Expert Comment

by:systan
ID: 35037345
hi
if you are using only 1 parameter?, removed the
&
Params.WriteString(TIdURI.URLEncode('cmp1=oi'));

or Use the HTTPEncode in HTTPApp instead
Params.WriteString(HTTPEncode('cmp1=oi'));
0
 
LVL 1

Author Comment

by:hidrau
ID: 35037435
systan:

did you test it? Did It work in your computer?
0
 
LVL 9

Expert Comment

by:Mahdi78
ID: 35037809
This complete is a example to know how to post data with idhttp

copy the following script in post.php file

<?
  echo '<b>Your username:</b>'.$_POST['user_name']
.' <br><b>Your password:</b> '. $_POST['password'];
?>

and use Delphi code

uses IdMultipartFormData;

procedure TForm1.Button1Click(Sender: TObject);
var data: TIdMultiPartFormDataStream;
begin
data := TIdMultiPartFormDataStream.Create;
 try
  data.AddFormField('user_name', 'value1');
  data.AddFormField('password', 'value2');
  Memo1.Text :=IdHTTP1.Post('http://localhost/post.php', data);
 finally
 data.Free;
 end;

end;
0
 
LVL 14

Accepted Solution

by:
systan earned 500 total points
ID: 35041527
>>did you test it? Did It work in your computer?
This is a question of a wise men without a cash, lol, I always ask this.
Sorry, I didn't test the code itself, but I was hoping to work in you.

Ok; here's my last post, try this link, it says something about a good solution
http://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_23128532.html


Good Luck
0
 
LVL 1

Author Closing Comment

by:hidrau
ID: 35082578
thanks for the link
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now