make delphi press a button in a website?

hi ,
is there anyway to make delphi press buttons on websites ?

example :
<input value="test" type="button" id="100" />

Open in new window

how can i make delphi press that button?
im using Tiehttp component


Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

There are two ways of "clicking the button".

The first way, using TWebBrowser and handles (clicking a button according to its name):

Button name (value) is submit
uses ...OleCtrls, SHDocVw, MSHTML;

procedure TForm1.FormCreate(Sender: TObject);
var Url, Flags, TargetFrameName, PostData, Headers: OleVariant;
  Url := ExtractFilePath(Application.ExeName) + 'Test.htm';
  WebBrowser1.Navigate2(Url, Flags, TargetFrameName, PostData, Headers);

procedure TForm1.Button1Click(Sender: TObject);
  doc: IHtmlDocument2;
  i: integer;
  ov: OleVariant;
  disp: IDispatch;
  collection: IHTMLElementCollection;
  inputelement: HTMLInputImage;
  WebBrowser1.ControlInterface.Document.QueryInterface(IHtmlDocument2, doc);
  if not Assigned(doc) then
  ov := 'INPUT';
  disp := doc.all.tags(ov);
  if Assigned(disp) then
    disp.QueryInterface(IHTMLElementCollection, collection);
    if Assigned(collection) then
      for i := 1 to collection.Get_length do
        disp := collection.item(pred(i), 0);
        disp.QueryInterface(HTMLInputImage, inputelement);
        if Assigned(inputelement) then
          if inputelement.Name = 'submit' then

Open in new window

The code's taken from DevShed Forums so don't forget to check the original page for more info.


The second way is submitting data to the webpage.
But we can only guess what does the button do... if the it is supposed to send some data to the webpage via GET or POST method the code'd look kinda like this:
<form method="POST">
	<input type="text" name="data" value="data_value">
	<input type="submit" value"Button">

Open in new window

According to the TieHTTP component this code would perform the same action as if you'd click the button:
iehttp1.RequestMethod := 'POST';

Open in new window

So you will have to find the input values inside the <form> tag and submit them to the webpage...

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
evilkidAuthor Commented:
cant use TWebBrowser

and it dosnt need a post .. like when u press it u get a message
thats it
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Geert GOracle dbaCommented:
you can use TWebBrowser
I don't see why you would only want to use such a component as TIEHTTP

You use the post command with that component
If you need a message dialog to show up when you "click" the button then you have to know entire source code of the webpage - you didn't provide any so we can't help you...

So what exactly is supposed to happen when the button is "clicked"?
What is the entire source code of the webpage?
evilkidAuthor Commented:
well facebook got this page : to share stuff on the fb wall
and it has 2 parameters (i think)
u : the url
t : the default title of the link

now i want when the user click the button , he share something on his wall (supposing he s already connected)

i can use (ieHttp.executeURL(''))
but i still have to press that "share" button in the page
Firstly, share.php uses GET method.

As you can see the POST method is processed via Javascript (AJAX) and there are additional parameters to be sent when you click the Share button:

The page data is sent to:

Open in new window

The data itself:
fb_dtsg	Ur0-x
message_text	YourMessage
message	YourMessage

Open in new window

(Use Tamper Data to find out what is sent between you and the server)

So what you have to do is to load all these parameters and "POST" them to the server... Some parts of the data to be sent are constant and some of them are not. That's why I recomment using TWebBrowser (or you can do it the harder way if you really want to).

I bet the end user won't really care if the "FaceBook" application you're creating will show him share page or an edit with a button instead. Assuming you only want to make things for the end user easier and you are not creating an application that uses his wall without him even knowing about it...
evilkidAuthor Commented:
thx for ur reply
but i cant find most of the parameters in nor in 
and i have to send these parameters thought  sharer/sharer.php or ajax/sharer/submit_page/?__a=1 ?
and about the TWebBrowser , i can post the URL and Titel ?

and yea i told the user is already connected so he knows about it


evilkidAuthor Commented:
ok thx i got it done with the WebBrowser :) thx
evilkidAuthor Commented:
thx ^^
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.