Jump to content

Function that opens a download dialog.


ezzetabi
 Share

Recommended Posts

In my computer it answers

"Your current security settings do not allow this file to be downloaded."

and I have no idea how to change for testing.

But YOU may like it. :)

$sFile = 'http://crimsonfan.altervista.org/run.zip'
$a = DllCall("shdocvw.dll",'int','DoFileDownload','string',$sFile)
Link to comment
Share on other sites

hm, just found something that says that function needs the string in unicode, would have to use MultiByteToWideChar in kernel32 to convert it... starting to sound like a pain...

I have a catapult. Give me all the money or I will fling an enormous rock at your head.

Link to comment
Share on other sites

I am pretty sure I am close...

$url = 'http://crimsonfan.altervista.org/run.zip'

$ln = StringLen($url)
$space = ""

for $i = 0 to 3 * $ln
   $space = $space + " "
Next

$res = DllCall("kernel32.dll", "int", "MultiByteToWideChar", "int", 1, "long", "", "str_ptr", $url, "long", -1, "str_ptr", $space, "long", $ln, "long", "")
$a = DllCall("shdocvw.dll",'int','DoFileDownload','str',$res[5])

converted from this:

MultiByteStr$ = "http://david.oslb.net/index.htm" + chr$(0)
    CodePage = 1 ' CP_OEMCP
    chMultiByte = -1
    chWideChar = len(MultiByteStr$)
    WideCharStr$ = space$(3 * chWideChar)

    calldll #kernel32, "MultiByteToWideChar", _
        CodePage     as ulong, _
        Flags         as ulong, _
        MultiByteStr$ as ptr, _
        chMultiByte as ulong, _
        WideCharStr$ as ptr, _
        chWideChar    as ulong, _
        result        as ulong

    file$ = WideCharStr$

    Open "Shdocvw.dll" for dll as #shdocvw

    CallDLL #shdocvw, "DoFileDownload", _
        file$ as ptr,_
        ret as long

    Close #shdocvw
end
Who else would I be?
Link to comment
Share on other sites

1) What's str_ptr? All strings are pointers since they of integral type char*.

2) You are attempting to store a wchar_t in a char. What do you think the odds are of that working? Here's the output in the return array:

104 0 116 0 116 0 112 0 58 0 47 0 47 0 99 0 114 0 105 0 109 0 115 0 111 0 110 0 102 0 97 0 110 0 46 0 97 0 108 0

Thus, an h prints and thats it.
Link to comment
Share on other sites

@Valik, Do I understand that autoit cannot even store such a value? If so, then it does look impossible.

@Python, it is not a mistake.

@ezzetabi, For the comments from python, he is used to a website called altavista.com Your url looks like a mistake to him, which it is not. For the part of the code, If Valik validates my assumption, then autoit will only be able to do this when autoit has full support for unicode. That, as we all know, is not going to happen soon.

Who else would I be?
Link to comment
Share on other sites

About BlackDiablo: oh yeah. I forgot the lack of his brain activity.

About the DllCall: Pity. Well, we already have InetGet() so it is not a problem at all.

Still, it is strange that a download Func accepts only unicode where internet addresses often don't.

:)Do you like the lastest version of Run!?

Link to comment
Share on other sites

  • 1 month later...

Jon, Since the new beta, the following should be possible:

$url = 'http://crimsonfan.altervista.org/run.zip'
$a = DllCall("shdocvw.dll", 'int', 'DoFileDownload', 'wstr', $url)

However, the error mentioned above (security settings) still occurs. Is something wrong with the code?

Who else would I be?
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...