AutoHotkey Community

It is currently May 27th, 2012, 4:00 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: September 8th, 2009, 1:17 pm 
Offline

Joined: November 24th, 2005, 8:16 am
Posts: 851
Hello everybody,

I have probably complained about this several times, but I am still desperate to find an alternative to UrlDownloadToFile.

Two major problems with this function, on my XP machine:
1. When it downloads, the script is not responding.
2. It does not have any timeout, so if it cannot download, it stays like this forever or until I end the process, the ugly way.

Have tried UrlDownloadToVar and HttpQuery - all the same.
Have looked into the libcurl AHK wrappers, and it is way over my head - I want to download simple files, and this libcurl looks like I have to write 10-20 lines just to do this with callback functions and all sorts of overhead.

@Chris - I am BEGGING you, please do something about this UrlDownloadToFile ... :)

Anybosy else, if you have some suggestion I will call my first born in your name...

_________________
Sector-Seven - Freeware tools built with AutoHotkey


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 8th, 2009, 1:31 pm 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
the fact that urldownloadtofile urldownloadtovar and httpquery all have the same result make it more likely to be machine specific.

windows attempts to load downloaded content into memory. I had a PC with a bad stick of memory recently that would do similar behavior when i dragged files back off my web server

I am not suggesting this is the same as your problem but I am saying i have seen similar behavior and that in my case the cause was bad memory

try clearing your temporary internet files it does help

I am guessing these are particularly large files. have you tried using
Code:
settimer,timeout,-600000 ; example calls a subroutine after 10 minutes


timeout:
msgbox timeout occured
exitapp

_________________
No matter what your oppinion Please join this discussion
Formal request to Polyethene
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 8th, 2009, 1:46 pm 
Offline

Joined: November 24th, 2005, 8:16 am
Posts: 851
Tank,

Are you saying that on your machine, UrlDownloadToFile does not halt the script for the duration of the download?
And, if the server is not responding, your machine does let UrlDownloadToFile timeout and return to normal operation?

I do not think this is machine specific - I am seeing reports of this all over the forums, even reporting same problem about the alternatives that are out there (httpQuery and the COM alternative).

Here is a sample script, the progress bar halts while the download is in progress.
Code:
#SingleInstance Force
SetWorkingDir %A_ScriptDir%

Gui Add, Progress, vMyProgress 0x8
Gui Add, Text, vStatus, Doing Nothing...
Gui Show
SetTimer MoveProgress, 10
SetTimer Download, -800

Return

MoveProgress:
   GuiControl,,MyProgress,1
Return

Download:
   GuiControl,,Status,Downloading...
   UrlDownloadToFile http://rss.news.yahoo.com/rss/topstories, tmp.txt
   GuiControl,,Status,Doing Nothing...
Return

ESC::
   FileDelete tmp.txt   
   ExitApp
Return



Although this halting is a problem, the much bigger problem is if there is no response from the server - in this case your script is stuck.

_________________
Sector-Seven - Freeware tools built with AutoHotkey


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 8th, 2009, 1:55 pm 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
You mentioned UrlDownloadToVar, however, you seemed never read the thread actually. Of course you have to use asynchronous routine for your need.
http://www.autohotkey.com/forum/topic10466-29.html


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 8th, 2009, 2:00 pm 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
Icarus wrote:
Tank,

Are you saying that on your machine, UrlDownloadToFile does not halt the script for the duration of the download?
And, if the server is not responding, your machine does let UrlDownloadToFile timeout and return to normal operation?
.
this is exactly what im saying
i get the following screen the counter never hesitates and your progress bar moves freely
Image
Code:
#SingleInstance Force
SetWorkingDir %A_ScriptDir%

Gui Add, Progress, vMyProgress 0x8
Gui Add, Text, vStatus, Doing Nothing...
Gui Show
SetTimer MoveProgress, 10
SetTimer Download, -800
Gosub,Not_Dead
Return

MoveProgress:
   GuiControl,,MyProgress,1
Return

Download:
   GuiControl,,Status,Downloading...
   UrlDownloadToFile http://rss.news.yahoo.com/rss/topstories, tmp.txt
   GuiControl,,Status,Doing Nothing...
Return

ESC::
   FileDelete tmp.txt   
   ExitApp
Return

Not_Dead:
i=0
Loop
   ToolTip,% "Not Dead or Halted " i++
Return

_________________
No matter what your oppinion Please join this discussion
Formal request to Polyethene
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 8th, 2009, 2:08 pm 
Offline

Joined: November 24th, 2005, 8:16 am
Posts: 851
Odd...
Are you on XP?

_________________
Sector-Seven - Freeware tools built with AutoHotkey


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 8th, 2009, 2:10 pm 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
yes XP

_________________
No matter what your oppinion Please join this discussion
Formal request to Polyethene
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 7th, 2010, 11:24 pm 
Offline

Joined: April 30th, 2006, 6:23 pm
Posts: 358
Location: Shigle Springs
A simple way

Code:
filecreatedir, c:\temp
filedelete, c:\temp\downloader.exe
fileinstall, downloader.exe, c:\temp\downloader.exe

filedelete, c:\temp\tempdl.txt
;///////// Put in the url below & the file name...


URL = http://www.somesite.com/somefile.exe
file = somefile.exe


fileappend,
(
[download]
url=%URL%

[filename]
file=%file%
), c:\temp\tempdl.txt

run, c:\temp\downloader.exe
sleep, 3000



loop, 10
{
Process, Exist, downloader.exe
If errorLevel   
   sleep, 1000 ;time to sleep X loop amount

   Process, Exist, downloader.exe
If ! errorLevel   
Break
}

Process, Exist, downloader.exe
If errorLevel   
{

process, close, downloader.exe
sleep, 500
process, close, downloader.exe
sleep, 500
process, close, downloader.exe
sleep, 500
process, close, downloader.exe
sleep, 500
process, close, downloader.exe
}




downloader.exe
Code:
#notrayicon
#SingleInstance ignore

setbatchlines, -1

iniread, dl, c:\temp\tempdl.txt, download, url

iniread, fl, c:\temp\tempdl.txt, filename, file

filedelete, %file%

urldownloadtofile, %dl%, %FL%

ugly n fat but it works.

BTW, I still have about 5% of my clients with IE8 unable to get urldownloadtofile to work. After installing IE7, and removeing IE8,it works. :?

Hi. Mr. Tank, been down and out.. but i am almost back...

_________________
CPULOCK.com
virusSWAT.com
Computer Repair Computer Service.com
911PCFIX.com


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 23rd, 2011, 10:15 am 
Did this ever get resolved ?
I have the same issue..

Whilst the page is running, the progress bar freezes !

Any ideas ?
Thanks :)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 23rd, 2011, 10:24 am 
Offline

Joined: November 24th, 2005, 8:16 am
Posts: 851
I resorted to using cURL.
So I use Run or RunWait with curl.exe - this way you can decide if you want to wait, and to set a timeout and other more advanced HTTP request parameters.

It kills the spontaneity of UrlDownloadToFile but I had no other choice.

_________________
Sector-Seven - Freeware tools built with AutoHotkey


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 23rd, 2011, 1:07 pm 
Thanks
I'm using libcurl within my script.. Wonder if that could be used ?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 23rd, 2011, 1:22 pm 
Offline

Joined: November 24th, 2005, 8:16 am
Posts: 851
You say you are using it... so... it can be used. :)

_________________
Sector-Seven - Freeware tools built with AutoHotkey


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 23rd, 2011, 2:45 pm 
sorry I'm using it to download a file from a remote server.

I meant... I wonder if it can be used to call the page, with out pausing the progress bar. !!


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 23rd, 2011, 3:07 pm 
Offline

Joined: November 24th, 2005, 8:16 am
Posts: 851
Yes, I believe so.

_________________
Sector-Seven - Freeware tools built with AutoHotkey


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 23rd, 2011, 6:30 pm 
Offline

Joined: March 31st, 2011, 6:21 am
Posts: 5
Since tov's been looking for a solution for a while, I put together these libraries.

http://www.autohotkey.net/~EmanResu/URL ... ToFile.zip

You use them like any other dll. Pass in the URL and filename along with an address for callback so you get notification when the D/L is done.

The only thing this does is wrap URLDownloadToFile, running it in a new thread so it doesn't block.

Example usage:
Code:
; x86 ANSI

#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%
OnExit, Cleanup

hLib := DllCall("LoadLibrary", "Str", "URLDownloadToFile.dll")
if ( !hLib | ErrorLevel )
{
   MsgBox %hLib% : %ErrorLevel% : %A_LastError%
   ExitApp
}

Gui, Add, Progress, w300 h20 cBlue vMyProgress Range0-100
Gui, Show, Autosize
DllCall("URLDownloadToFile\URLDownloadToFile_AHK"
            ,"Str", "http://www.yahoo.com"
            ,"Str", A_ScriptDir . "\yahoo.txt"
            ,"UInt", RegisterCallback("Done","",1))
SetTimer, UpdateProgress, 500
Return

Done( p1 ){
   Critical
   MsgBox Done!
}

UpdateProgress:
   GuiControl,, MyProgress, % i + 1
   i++
   if ( i >=99 )
      i := 0
Return

Cleanup:
   if ( hLib )
      DllCall("FreeLibrary", "UInt", hLib)
ExitApp


x86 ANSI, x86 Unicode and x64 Unicode versions included. I think I'm using AHK_L x86 Unicode wrong though as I can't get it to load the corresponding library. Maybe someone else can.

Anyhow, use them or not. Up to you :)

_________________
Press Enter To Exit...


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Leef_me, rbrtryn, Yahoo [Bot] and 49 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group