Sodori Posted July 25, 2014 Share Posted July 25, 2014 Hi all, Problems, problems and, you guessed it problems. This is something I cannot wrap my head around at all despite understanding example scripts, reading forums etc. This is the script I am truing to run: #include <InetConstants.au3> #include <MsgBoxConstants.au3> ; Download a file in the background. ; Wait for the download to complete. Example() Func Example() ; Download the file in the background with the selected option of 'force a reload from the remote site.' Local $hDownload = InetGet("http://www.autoitscript.com/autoit3/files/beta/update.dat", "C:\Temp\", $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND) ; Wait for the download to complete by monitoring when the 2nd index value of InetGetInfo returns True. Do Sleep(250) Until InetGetInfo($hDownload, $INET_DOWNLOADCOMPLETE) ; Retrieve the number of total bytes received and the filesize. Local $iBytesSize = InetGetInfo($hDownload, $INET_DOWNLOADREAD) Local $iFileSize = FileGetSize("C:\Temp\") Local $iFiledownload = InetGetInfo($hDownload, $INET_DOWNLOADCOMPLETE) ; Close the handle returned by InetGet. InetClose($hDownload) ; Display details about the total number of bytes read and the filesize. MsgBox($MB_SYSTEMMODAL, "", "The total download size: " & $iBytesSize & @CRLF & _ "The total filesize: " & $iFileSize & @CRLF & _ "Did we download it: " & $iFiledownload) EndFunc ;==>Example It is 95% one of the example scripts but I've Frankensteined it a bit in order to try and achieve agreement with it. No success. I have double checked so the URL exists, it does, and I have even copy pasted the directory. Tried much of anything and everything. How to download this elusive "update.dat" and put it in "C:Temp"?? And also, why does it actually return true from "$INET_DOWNLOADCOMPLETE" when it's clearly not there!! Link to comment Share on other sites More sharing options...
Geir1983 Posted July 25, 2014 Share Posted July 25, 2014 you need to specify a complete filepath to download to (including filename!), you just specify a folder. Link to comment Share on other sites More sharing options...
guinness Posted July 25, 2014 Share Posted July 25, 2014 It downloads just doesn't save. Try adding DirCreate(). But really you should use @TempDir and not clutter the root drive of the home directory. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Sodori Posted July 25, 2014 Author Share Posted July 25, 2014 you need to specify a complete filepath to download to (including filename!), you just specify a folder. Like: Local $hDownload = InetGet("http://www.autoitscript.com/autoit3/files/beta/update.dat", "C:\Temp\update.dat", $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND) [questionmark] because that just makes and endless Do... Until loop.. It downloads just doesn't save. Try adding DirCreate(). But really you should use @TempDir and not clutter the root drive of the home directory. Please evaluate, the directory does exist so I do not see how recreating it would solve it. But I added it and nothing. Link to comment Share on other sites More sharing options...
Geir1983 Posted July 25, 2014 Share Posted July 25, 2014 Maybe some access rights missing in that folder.. Try #RequireAdmin in the start of the script of use @TempDir as guinness suggested. Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted July 25, 2014 Share Posted July 25, 2014 (edited) This is wrong:Local $iFiledownload = InetGetInfo($hDownload, $INET_DOWNLOADCOMPLETE) "Did we download it: " & $iFiledownload) $INET_DOWNLOADCOMPLETE is only whether the download is finished (as in stopped receiving data) or not. $INET_DOWNLOADSUCCESS is what tells you if it succeeded. Edited July 25, 2014 by AdmiralClaws Sodori and pixelsearch 2 .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
Sodori Posted July 25, 2014 Author Share Posted July 25, 2014 Big help Admiral, I could now see that it actually do download successfully. and after a bit of maneuver whilst returning to downloading to temp folder, I could see it as well!! Bit of a hassle IMHO though. So now I need to figure how to extract the image name from each link (I got a few hundred and every tenth is a new location on the web) xD The solution is that you do need to specify file not just path... I guess that you could download it as another name that way? *insight* So Local $hDownload = InetGet("http://www.autoitscript.com/autoit3/files/beta/update.dat", @TempDir & "\wentbathing.txt", $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND) Would download the file to TempDir and name it wentbathing.txt instead of update.dat {verified myself} I would kinda say Autoit should make an option inside that command if you just want to specify folder and download same as downloaded name (if default 0, do like this, if 1 then name it same as on the web). But I digress! Thank you all!! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now