Board index » delphi » Simulating a button press in the browser?????

Simulating a button press in the browser?????

Is there a way programmatically, to simulate or initiate a press of a submit
button from within a browser window, or in one of the Delphi HTML viewer
components.

I don't have control over the web page itself, or I would add a JavaScript
method to initiate the submit for me, but I need to make this process
automated.

Any thoughts, suggestions, comments are greatly appreciated.

Thanks,
Clayton

 

Re:Simulating a button press in the browser?????


Quote
>Is there a way programmatically, to simulate or initiate a press of a submit
>button from within a browser window, or in one of the Delphi HTML viewer
>components.

I think you can use all Javascript commands and you can also fill FormFields from TWebBrowser.

Regards

Michael

Procedure TMainForm.HtmlSend;
var
  i, j: Integer;
  FormItem: Variant;
begin
  //no form on document
  if WebBrowser1.OleObject.Document.All.Tags('FORM').Length = 0 then
  begin
    Exit;
  end;
  //count forms on document
  for I := 0 to WebBrowser1.OleObject.Document.forms.Length - 1 do
  begin
    FormItem := WebBrowser1.OleObject.Document.forms.Item(I);
    for j := 0 to FormItem.Length - 1 do
    begin
      try
        if FormItem.Item(j).Name = 'btnSend' then
        begin
          FormItem.Item(j).Click;
        end;
      except
        Exit;
      end;
    end;
  end;
end;

Quote
>Is there a way programmatically, to simulate or initiate a press of a submit
>button from within a browser window, or in one of the Delphi HTML viewer
>components.

>I don't have control over the web page itself, or I would add a JavaScript
>method to initiate the submit for me, but I need to make this process
>automated.

>Any thoughts, suggestions, comments are greatly appreciated.

>Thanks,
>Clayton

Re:Simulating a button press in the browser?????


I know this is a stupid question, but where do I find TWebBrowser???    I
know it's basically a wrapper for the IE ActiveX control, but I can't find
it in my version of Delphi, or references on where to get it.  Is it Delphi
version specific?

Can someone shed some light on this for me, please.

Quote
"Michael Vimetal" <m...@viscom-online.com> wrote in message

news:3c785229_2@dnews...
Quote
> >Is there a way programmatically, to simulate or initiate a press of a
submit
> >button from within a browser window, or in one of the Delphi HTML viewer
> >components.

> I think you can use all Javascript commands and you can also fill

FormFields from TWebBrowser.
Quote

> Regards

> Michael

> Procedure TMainForm.HtmlSend;
> var
>   i, j: Integer;
>   FormItem: Variant;
> begin
>   //no form on document
>   if WebBrowser1.OleObject.Document.All.Tags('FORM').Length = 0 then
>   begin
>     Exit;
>   end;
>   //count forms on document
>   for I := 0 to WebBrowser1.OleObject.Document.forms.Length - 1 do
>   begin
>     FormItem := WebBrowser1.OleObject.Document.forms.Item(I);
>     for j := 0 to FormItem.Length - 1 do
>     begin
>       try
>         if FormItem.Item(j).Name = 'btnSend' then
>         begin
>           FormItem.Item(j).Click;
>         end;
>       except
>         Exit;
>       end;
>     end;
>   end;
> end;

> >Is there a way programmatically, to simulate or initiate a press of a
submit
> >button from within a browser window, or in one of the Delphi HTML viewer
> >components.

> >I don't have control over the web page itself, or I would add a
JavaScript
> >method to initiate the submit for me, but I need to make this process
> >automated.

> >Any thoughts, suggestions, comments are greatly appreciated.

> >Thanks,
> >Clayton

Re:Simulating a button press in the browser?????


Never mind, I think I found it in the Feature Matrix, and it's not in the
Personal Edition, only the Professional and Enterprise.  :(
Quote
"Clayton Peirens" <clayton.peir...@okotoks.net> wrote in message

news:3c7872aa$1_1@dnews...
Quote
> I know this is a stupid question, but where do I find TWebBrowser???    I
> know it's basically a wrapper for the IE ActiveX control, but I can't find
> it in my version of Delphi, or references on where to get it.  Is it
Delphi
> version specific?

> Can someone shed some light on this for me, please.
> "Michael Vimetal" <m...@viscom-online.com> wrote in message
> news:3c785229_2@dnews...
> > >Is there a way programmatically, to simulate or initiate a press of a
> submit
> > >button from within a browser window, or in one of the Delphi HTML
viewer
> > >components.

> > I think you can use all Javascript commands and you can also fill
> FormFields from TWebBrowser.

> > Regards

> > Michael

> > Procedure TMainForm.HtmlSend;
> > var
> >   i, j: Integer;
> >   FormItem: Variant;
> > begin
> >   //no form on document
> >   if WebBrowser1.OleObject.Document.All.Tags('FORM').Length = 0 then
> >   begin
> >     Exit;
> >   end;
> >   //count forms on document
> >   for I := 0 to WebBrowser1.OleObject.Document.forms.Length - 1 do
> >   begin
> >     FormItem := WebBrowser1.OleObject.Document.forms.Item(I);
> >     for j := 0 to FormItem.Length - 1 do
> >     begin
> >       try
> >         if FormItem.Item(j).Name = 'btnSend' then
> >         begin
> >           FormItem.Item(j).Click;
> >         end;
> >       except
> >         Exit;
> >       end;
> >     end;
> >   end;
> > end;

> > >Is there a way programmatically, to simulate or initiate a press of a
> submit
> > >button from within a browser window, or in one of the Delphi HTML
viewer
> > >components.

> > >I don't have control over the web page itself, or I would add a
> JavaScript
> > >method to initiate the submit for me, but I need to make this process
> > >automated.

> > >Any thoughts, suggestions, comments are greatly appreciated.

> > >Thanks,
> > >Clayton

Re:Simulating a button press in the browser?????


"Clayton Peirens" <clayton.peir...@okotoks.net> schreef in bericht
news:3c78797c_1@dnews...

Quote
> Never mind, I think I found it in the Feature Matrix, and it's not in the
> Personal Edition, only the Professional and Enterprise.  :(

Heh, that wouldn't help, that one is broken and bugged beyond belief..
Better use a 3rd party tool for that..

Re:Simulating a button press in the browser?????


Do you have any suggestions for a third-party component????     I managed to
install the ActiveX last night and got it working, but if there is a more
elegant way, then by all means, I'm listening.

Quote
"Arthuro" <he...@haxor.vaxor.com> wrote in message

news:3c78c8b5$1_2@dnews...
Quote
> "Clayton Peirens" <clayton.peir...@okotoks.net> schreef in bericht
> news:3c78797c_1@dnews...
> > Never mind, I think I found it in the Feature Matrix, and it's not in
the
> > Personal Edition, only the Professional and Enterprise.  :(

> Heh, that wouldn't help, that one is broken and bugged beyond belief..
> Better use a 3rd party tool for that..

Re:Simulating a button press in the browser?????


"Clayton Peirens" <clayton.peir...@okotoks.net> schreef in bericht
news:3c790942_1@dnews...

Quote
> Do you have any suggestions for a third-party component????     I managed
to
> install the ActiveX last night and got it working, but if there is a more
> elegant way, then by all means, I'm listening.

There was one advertised not so long ago here, but i'm not sure what it was
called.. It came in 2 flavors that i know of..

Re:Simulating a button press in the browser?????


Well, I got it to work with Delphi 6 Personal with the ActiveX control
supplied by IE 5.5

Now I have another problem.  Is there any way to make sure that the program
I create will work on any machine?   I've had reports that it doesn't work
on 98 and ME.  I run 98 and have not problems, so it must be related to the
version of IE.

Quote
"Michael Vimetal" <m...@viscom-online.com> wrote in message

news:3c785229_2@dnews...
Quote
> >Is there a way programmatically, to simulate or initiate a press of a
submit
> >button from within a browser window, or in one of the Delphi HTML viewer
> >components.

> I think you can use all Javascript commands and you can also fill

FormFields from TWebBrowser.
Quote

> Regards

> Michael

> Procedure TMainForm.HtmlSend;
> var
>   i, j: Integer;
>   FormItem: Variant;
> begin
>   //no form on document
>   if WebBrowser1.OleObject.Document.All.Tags('FORM').Length = 0 then
>   begin
>     Exit;
>   end;
>   //count forms on document
>   for I := 0 to WebBrowser1.OleObject.Document.forms.Length - 1 do
>   begin
>     FormItem := WebBrowser1.OleObject.Document.forms.Item(I);
>     for j := 0 to FormItem.Length - 1 do
>     begin
>       try
>         if FormItem.Item(j).Name = 'btnSend' then
>         begin
>           FormItem.Item(j).Click;
>         end;
>       except
>         Exit;
>       end;
>     end;
>   end;
> end;

> >Is there a way programmatically, to simulate or initiate a press of a
submit
> >button from within a browser window, or in one of the Delphi HTML viewer
> >components.

> >I don't have control over the web page itself, or I would add a
JavaScript
> >method to initiate the submit for me, but I need to make this process
> >automated.

> >Any thoughts, suggestions, comments are greatly appreciated.

> >Thanks,
> >Clayton

Re:Simulating a button press in the browser?????


On Mon, 25 Feb 2002 02:27:51 +0100, Clayton Peirens found a keyboard and
hacked in:

Quote
> Now I have another problem.  Is there any way to make sure that the
> program I create will work on any machine?  

No. Use only the basic IE control (not any of the fancy stuff), and hope
that no people run it that still use *old* versions of IE (3, maybe 4?).
Other than that there's not much you can do.

Quote
> I've had reports that it
> doesn't work on 98 and ME.  I run 98 and have not problems, so it must
> be related to the version of IE.

Depends. If it doesn't load then there's some function imports in your program
that another IE version doesn't have.

johannes

Other Threads