Solved

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

Posted on 2011-03-03
16
214 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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
 
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
oracle global variables 4 76
Reconfigure Delphi Install? 2 61
Find and Replace Stream with 0s 8 69
When i run adoquery my application freezes 26 180
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

828 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