Click here to Skip to main content
15,891,204 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
I have a number business users who regularly download reports from a vendor website. I'd like to automate this process for them using a VB.NET or C# form.

It looks like the vendor has gone out of their way to make this difficult for me. Upon entering the website, the user needs to enter their username and password via a HTTPS form. The rest of the site is HTTPS. They then need to navigate thru a few different pages, which set up session variables (cookies) necessary for the report request. The reports are finally returned from HTTP POST requests which take a bucketload of different parameters. There is also embedded JS which sets up some of these parameters before the form is posted.

I've played with a number of different options, but have finally opted for using the WebBrowser control to navigate thru the site as if I were a normal user. This allows me to ignore the convoluted logic involved in formatting up the final POST request, and also (somewhat) future proofs my code from changes the vendor might make to their website.

So far, so good.

When the form is POSTed, two dialog boxes are displayed; a "File Download" (showing Open, Save and Cancel buttons) and then, if you click Save, a "Save As" dialog. Using an modified version of BimJeam's excellent article (Suppressing Hosted WebBrowser Control Dialogs), I can intercept and click Save on the "File Download" dialog. My problem is, I can't work out how to intercept the "Save As" dialog. It doesn't seem to fire the WM_INITDIALOG message, and doesn't appear in the message queue with any expected name.

Has anyone done this before, or know a good way to approach it?

Thanks in advance.
Posted
Updated 6-Aug-12 17:59pm
v2

1 solution

Ok, as a work around I'm polling
GetWindowHandle
every 50ms for a dialog with the title "Save As" and interacting with it when it appears. This works, but I do get the dialog visibly flashing up and then disappearing, which is not ideal.

Hopefully a better solution will appear...
 
Share this answer
 
Comments
pparya27 6-Dec-16 12:51pm    
Hi! I am also stuck in a similar problem, can you please share the code of polling evry 50ms for dialog with title "save as".

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900