For Programmers: Free Programming Magazines  


Home > Archive > Visual Basic > February 2006 > File Download dialog box









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author File Download dialog box
michael.blaustein@gmail.com

2006-02-27, 6:56 pm

I am writing an application that goes to a website and downloads some
files. This has been somewhat complicated, and I don't know if I'm
doing it the best possible way, but what I have so far clicks on a
link, which brings up the "File Download" dialog box. Using some API
calls, I am able to get the handle of this dialog box.

Now that I have the handle of the dialog box, I would like to click the
save button, and then be able to control the Save As dialog box. I
suspect that I could create a variable for a dialog box object, and set
that variable to the File Download box using it's handle, but I'm not
sure exactly how to do this.

Once I click on the Save button, do I have to go through all the open
windows using the API calls, like I did to get the handle for the File
Download box, or is there a way I could reference it as it's child?

Thank you,
Michael Blaustein

michael.blaustein@gmail.com

2006-02-27, 6:56 pm

I found out how to click on the button object using the following API
call:

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA"
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal
lParam As Any) As Long

Const BM_CLICK = &HF5

Call SendMessage(hSaveButton, BM_CLICK, ByVal 0&, ByVal 0&)



But that still leaves my other question, is something like this
possible:

Dim SaveAsDialog as CommonDialog

Set SaveAsDialog = {The Save As Dialog Which has just been opened and
fot which I can get the handle for}

allowing me to use the properties and methods of the CommonDialog. Any
help on this would be greatly appreciated.

Michael

Jeff Johnson [MVP: VB]

2006-02-27, 6:56 pm


<michael.blaustein@gmail.com> wrote in message
news:1141055748.439042.192980@i39g2000cwa.googlegroups.com...

>I am writing an application that goes to a website and downloads some
> files. This has been somewhat complicated, and I don't know if I'm
> doing it the best possible way, but what I have so far clicks on a
> link, which brings up the "File Download" dialog box. Using some API
> calls, I am able to get the handle of this dialog box.


You can use the WinHTTP library to make calls to URLs and download things
directly. You can also use the Internetxxx() API function to do this. Either
one would be easier than the "pretend I'm an interactive user" method which
you seem to be going for.


michael.blaustein@gmail.com

2006-02-27, 6:56 pm

Jeff,
Thank you for your response. By the WinHTTP library do you mean
MSHTML.tlib? If so, do you know what function I can use to download
directly? I had thought of going that route, but thought it not
possible because the URL which downloads the file contains POST data,
i.e.
https://services.website.com/servle...entId=47996601.
Or perhaps you mean something else entirely?

What is the Internetxxx()API Function? I have never heard of this.
Can you point me in some direction which might enlighten me a bit?
Thanks,

Michael

Jeff Johnson [MVP: VB]

2006-02-27, 6:56 pm


<michael.blaustein@gmail.com> wrote in message
news:1141067480.755611.82690@i39g2000cwa.googlegroups.com...

> Thank you for your response. By the WinHTTP library do you mean
> MSHTML.tlib?


No. Start here:
http://msdn.microsoft.com/library/d....asp?frame=true

> If so, do you know what function I can use to download
> directly?


I believe it's a combination of the Open and Send methods.

> What is the Internetxxx()API Function?


Oops, I left off an "s." That should have read "the Internetxxx() API
functions." A starting point:
http://msdn.microsoft.com/library/d....asp?frame=true


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com