Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 223
  • Last Modified:

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

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
hidrau
Asked:
hidrau
  • 7
  • 5
  • 3
  • +1
1 Solution
 
hidrauAuthor Commented:
I got this code and maybe it can help to accomplish this task

http://www.cryer.co.uk/brian/delphi/howto_openiespecificetc.htm
0
 
Mahdi78Commented:
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
 
hidrauAuthor Commented:
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
ThommyCommented:
How to open the standard browser on a given URL...
http://www.cryer.co.uk/brian/delphi/howto_openbrowserurl.htm
0
 
Mahdi78Commented:
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
 
Mahdi78Commented:
Sorry the shellExecute with IE will be

ShellExecute(0, 'open', 'IExplore', 'http://yourdomain.com/index.php?val1=aaa&val2=bbb', nil, SW_SHOW);
0
 
systanCommented:
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
 
hidrauAuthor Commented:
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
 
Mahdi78Commented:
Then, you should use IDHttp or webbrowser component
0
 
hidrauAuthor Commented:
My delphi is complainting this URLEncode, I don't know how unit it come from

0
 
hidrauAuthor Commented:
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
 
systanCommented:
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
 
hidrauAuthor Commented:
systan:

did you test it? Did It work in your computer?
0
 
Mahdi78Commented:
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
 
systanCommented:
>>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
 
hidrauAuthor Commented:
thanks for the link
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 7
  • 5
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now