Solved

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

Posted on 2011-03-03
16
215 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

710 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