Jump to content

Straight issue with InetGet


Recommended Posts

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

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 parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

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

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 by AdmiralClaws
Link to comment
Share on other sites

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

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...