Code: Select all
;-------- saved at 星期五 十月 2020-10-23 17:18 UTC --------------
;- Dateien download
;- https://www.autohotkey.com/boards/viewtopic.php?f=9&t=82414
#Warn
#Noenv
setworkingdir,%a_scriptdir%
;-----------
;URL:="http://www.cheeseheadhosting.us/downloads/golden%20age%20of%20television%20vault%201/1955%20alfred%20hitchcock%20presents/Alfred%20Hitchcock%20Presents%201x30%20NeverAgain.avi"
url:="http://74.136.132.35/MUSIC/ORIG/J/Jim%20Reeves/The%20Essential%20Jim%20Reeves/Jim%20Reeves%20-%20The%20Essential%20Jim%20Reeves%20-%2010%20-%20I%20Love%20You%20Because.mp3"
SplitPath,url,name, dir, ext, name_no_ext, drive
name1:= uriDecode(name) ;- remove %20 etc
dname=%a_scriptdir%\%name1%
;-----------
WebRequest := ComObjCreate("WinHttp.WinHttpRequest.5.1")
WebRequest.Open("HEAD", URL)
WebRequest.Send()
try
{
ByteSize := WebRequest.GetResponseHeader("Content-Length")
KilobyteSize := ByteSize/1024
;MegabyteSize := KilobyteSize/1024
;MB:=floor(MegabyteSize)
Filesize:=floor(KilobyteSize)
}
catch e
{
xxx:=e.Message
msgbox, 262208,Failure ,URL not found
exitapp
}
FileGetSize,AktSize,%dname%,K
If(FileSize==Aktsize)
{
msgbox, 262208,,File already exist`n%dname%
exitapp
}
;-----------
Gui,1: +alwaysontop
GUI,1:Font,s12 cWhite,Lucida Console
Gui,color,black,blue
Gui, +LastFound -Caption -MinSize -MaxSize -E0x200 -Resize
Gui,Add,Progress,x0 y0 w500 h30 BackgroundTrans vProgress1 -Smooth cDefault,0
Gui,Add,Text ,x20 y5 w50 h30 BackgroundTrans vText1 cWhite,0 `%
Gui,Show,xcenter ycenter w500 h30,LOAD
;-----------
SetTimer,Updater,100
URLDownloadToFile,%URL%,%dname%
Return
;-------------------------------
Guiescape:
GuiClose:
ExitApp
esc::exitapp
;-------------------------------
Updater:
IfExist,%dname%
{
FileGetSize,AktSize,%dname%,K
Pos:=Round((AktSize/FileSize)*100)
If(FileSize==Aktsize)
{
GuiControl,1:,Progress1,100
SetTimer,Updater,Off
run,%dname%
exitapp
}
GuiControl,1:,Progress1,%Pos%
GuiControl,1:,Text1,%Pos% `%
}
Return
;---------------
uriDecode(str) {
Loop
If RegExMatch(str, "i)(?<=%)[\da-f]{1,2}", hex)
StringReplace, str, str, `%%hex%, % Chr("0x" . hex), All
Else Break
Return, str
}
;===============================