Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to 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 6-Aug-12 18:11pm
Edited 6-Aug-12 18:59pm
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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...
  Permalink  

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

  Print Answers RSS
0 DamithSL 320
1 OriginalGriff 195
2 Afzaal Ahmad Zeeshan 154
3 BillWoodruff 135
4 Peter Leow 115
0 OriginalGriff 7,510
1 DamithSL 5,519
2 Sergey Alexandrovich Kryukov 4,994
3 Maciej Los 4,936
4 Kornfeld Eliyahu Peter 4,514


Advertise | Privacy | Mobile
Web04 | 2.8.141223.1 | Last Updated 10 Aug 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100