locked
C# WebBrowser Control Automate Download RRS feed

  • Question

  • I have a C# application which is designed to automate a process to get required data.

    The steps are:

    1) Automate login using home page.

    2) Then on the next page, set various values and select an export button.

    All is working, but I can't figure out how to intercept the downloading of the file.

    When I invoke the download, a script is run to validate the selections and then a dialog appears (which is IE) and requires me to either Save. Open or Save As , etc.

    I can't directly download the file as it coming from another PHP being invoked by the page I am using (the reqults depend on what is selected on the page).

    So in short, after executing HtmlElement.InvokeMember("click"), I would like the resulting download to be automatically saved to a set location rather than a dialog.

    Friday, October 12, 2012 2:19 AM

All replies

  • Hi Cheese,

    Welcome to the MSDN Forum.

    How about this similar thread: http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/b75bd0c3-a719-4e6d-abcf-f9432922d5ba 

    I hope this will be helpful.

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, October 12, 2012 10:21 AM
  • Thanks Mike.I read the link, but this looks like you need the URL to the actual file.

    I am clicking a button on a PHP page which returns data from another PHP page which is querying a database and returning records in a csv format.

    I have also now found that when I click this button, a new window is temporarily displayed before the download dialog.

    Maybe I need to perform some actions in the NewWindow event of the WebBrowser control.

    • Edited by Mr Cheese Monday, October 15, 2012 11:27 PM
    Monday, October 15, 2012 11:11 PM
  • Hi Cheese,

    If so, please try the COM Web Browser control:http://msdn.microsoft.com/en-us/library/aa752085(v=vs.85).aspx 

    It provide NewWindow and NewWindow2 events, you can handle this event in the com browser much easier.

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, October 17, 2012 4:05 AM
  • Thanks for the info.

    I am unsure how to use this control or where it is to be found yet.

    Need to spend some more time looking.

    If there are any links to examples that would be great to get them.

    Wednesday, October 17, 2012 6:30 AM
  • Hi Cheese, 

    Here are two thread about Axwebbrowser:

    http://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/f59f5593-117d-44ea-b480-e8bedc8b86d3/

    http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/89e5a532-5a5c-4ade-857a-4ec1c0ca1549/

    I hope they are helpful.

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, October 17, 2012 7:13 AM
  • Thanks again.

    I am marking your response as helpfull, however I have not been able to get the result I need as the technical knowledge exceeds my ability. I think the answer is there somewhere.

    From my limited knowledge, I believe I am just seeking the specific event that is raised that invokes the Save File dialog. I am then hoping to be able to intercept this and force this dialog to automatically save the file to a desired location.

    I am still reading and trying.

    If I get a result I will post my working code.

    Friday, October 19, 2012 3:18 AM
  • Hi Cheese,

    After further research, I suggest you try this way: http://social.msdn.microsoft.com/Forums/en-US/winforms/thread/710e14d1-9e5a-4650-a732-bc5825ce4472  

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, October 23, 2012 10:01 AM
  • Thanks for your efforts Mike.

    I still can't firgure out a solution yet.

    The last reference still points to having access to the file's URL.  I just can't seem to see this being available to me.

    I invoke the button click which executes a PHP page. The URL I get is only a PHP link, not a link to a file to download. Yet I get a downlaod dialog for a CSV file. ?????.

    Again the answer may be here, but I simply do not understand enough yet.

    I am still looking for the event I need to code in to get the result, but I think the solution is not going to be as simple as that from all these post I have read.

    Thanks again.

    If I get it, I will post my solution.

    Tuesday, October 23, 2012 11:44 PM
  • This is the first time I'm seeing this posting.  You have a very common problem.  The POP up window that is displayed is a new IE Application.  YOu need to search all the IE Applications that are open and find the pop window by using the title Name of the window.  If somebody else doesn't give you a solution I will post one tomorrow.  You have to enumerate through each IE browser application something like this.  Not sur eof the syntac.

    foreach(Webbrowser IE in WebBrowsers)

          Check the title name of each Browser for one that matches tohe pop up window


    jdweng

    Wednesday, October 24, 2012 12:16 AM