vectorscope has asked for the wisdom of the Perl Monks concerning the following question:

Hello,

For the past few days I have been trying to write a little utility that will fire up IE navigate to a page fill out a form and submit it using Win32::OLE. For the most part this work beautifully, however, I am running into a problem with <input type="file"> objects. Apparently these are read only so I can't simply set the value in perl (at least not that I am aware of).

So instead I just use the ->Click() method which brings up a dialog box to choose a file.

The problem is after this ->Click() no other perl code is executed until I close the dialog box...I have a method that will fill in the name of the file and submit it, the problem is when I can't seem to detect when the file chooser dialog comes up :(

IE doesn't seem to fire any events indicating this dialog has been activated.

Basically I need to know when the dialog is open so I can execute code to fill in the file name and submit it.

Is there something I am missing here? Do I need to add another listener (ie Win32::OLE->WithEvents( ????)) that might catch this event?

Is there some other way to do this?

Thank you in advance for any insight anyone can provide.
  • Comment on Catching windows dialog events Win32::OLE?

Replies are listed 'Best First'.
Re: Catching windows dialog events Win32::OLE?
by marto (Cardinal) on Feb 12, 2009 at 23:03 UTC
      Yes Mechanize does work wonderfully for forms...it even lets you set <input type='file'> properties... BUT

      Sadly the site I am trying to do this on uses javascript which Mechanize does not support :(

        Sadly the site I am trying to do this on uses javascript which Mechanize does not support :(

        You're thinking about WWW::Mechanize. Win32::IE::Mechanize is a Win32::OLE wrapper just like the code you are trying to write.

        Another more efficient approach than the one you are taking is to use HTTP::Recorder or similar utility and bypass the browser completely.

        Yet another method that is going to be more efficient than using the raw Win32::OLE API is to use one of the many interfaces to a piece of software called Selenium

        Basically, you are reinventing a wheel that has already been reinvented over and over and over (which of course is okay if... its okay with you).

        regards,