PartyPooper Posted November 30, 2008 Author Posted November 30, 2008 The easiest way is to use SciTE4AutoIt3.
storme Posted December 1, 2008 Posted December 1, 2008 The easiest way is to use SciTE4AutoIt3. YAH! It didn't quite give me the answer but I found what I missed in the first place... I did have to try ALL of the "tools". I was using "Build" and it doesn't prompt for anything. BUT "compile" prompted for all sorts of "GOOD" stuff including the version number and gave me the autowrapper directives I new had to be somewhere. #Region;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Res_Fileversion=1.0.0.0 #AutoIt3Wrapper_Res_FileVersion_AutoIncrement=p #AutoIt3Wrapper_Run_Tidy=y #EndRegion;**** Directives created by AutoIt3Wrapper_GUI **** THANKS! John Morrison Some of my small contributions to AutoIt Browse for Folder Dialog - Automation SysTreeView32 | FileHippo Download and/or retrieve program information | Get installedpath from uninstall key in registry | RoboCopy function John Morrison aka Storm-E
storme Posted December 12, 2008 Posted December 12, 2008 G'day Partypooper I've been integrating your script into a script I'm working I need it to self update when I make changes. Your functions make it real easy. :-) I just call UPDATE() at the start of the script and continue on if there is no update. Just one problem I can see (unless I missed something). The "_InetFile_Install" function creates a Bat file then calls it to update the script BUT it doesn't pass on any of the command line options that may have been specified when running the original script so they are lost. FileWriteLine($h_BatchFile, 'start "Updating..." "' & @ScriptName & '"'); have batch file start the updated program Is there anyway you can add any/all command line options so the new script will run as the old one was instructed to? Thanks John Morrison Some of my small contributions to AutoIt Browse for Folder Dialog - Automation SysTreeView32 | FileHippo Download and/or retrieve program information | Get installedpath from uninstall key in registry | RoboCopy function John Morrison aka Storm-E
PartyPooper Posted December 13, 2008 Author Posted December 13, 2008 Possibly. You'd have to look at integrating the $CmdLineRaw variable into the batch file somehow. I haven't tested it, but I assume it would be something like: FileWriteLine($h_BatchFile, 'start "Updating..." "' & @ScriptName & '" "' & $CmdLineRaw & '"') ; have batch file start the updated program
storme Posted December 13, 2008 Posted December 13, 2008 Possibly. You'd have to look at integrating the $CmdLineRaw variable into the batch file somehow. I haven't tested it, but I assume it would be something like: FileWriteLine($h_BatchFile, 'start "Updating..." "' & @ScriptName & '" "' & $CmdLineRaw & '"') ; have batch file start the updated program That is exactly what I meant. I had a bit of a play and the code but it will put inverted commas around the the parameters that arn't needed and may cause problems for some scripts. This is all you need FileWriteLine($h_BatchFile, 'start "Updating..." "' & @ScriptName & '" ' & $CmdLineRaw); have batch file start the updated program I've tested it in isolation (not in your script) and it gives the following results Test.exe /1 /2 /3 -> start "Updating..." "test.exe" /1 /2 /3 Test -> start "Updating..." "test.exe" Test.exe -> start "Updating..." "test.exe" So should handle any situation and make your UDF more flexable. John Morrison Some of my small contributions to AutoIt Browse for Folder Dialog - Automation SysTreeView32 | FileHippo Download and/or retrieve program information | Get installedpath from uninstall key in registry | RoboCopy function John Morrison aka Storm-E
PartyPooper Posted December 13, 2008 Author Posted December 13, 2008 (edited) Cool, I'll update the UDF. Let me know if it works in the UDF or if you have any problems. Edited December 13, 2008 by PartyPooper
storme Posted December 15, 2008 Posted December 15, 2008 Cool, I'll update the UDF. Let me know if it works in the UDF or if you have any problems. Haven't tried it yet. I was ready for a full scale test of the script I'm working on last night but I've run into another problem and didn't get to try it yet. The script downloads the Spybot install file (14730KB) but it only gets so far through and returns with a successful result. Here is an extract of the code I'm using $DownloadDomain = "http://www.spybotupdates.com"; include HTTP:// $DownloadRemotePath = "/files" $DownloadFileName = "spybotsd160.exe" $DownloadPath = "downloads" DirCreate($DownloadPath) ;MsgBox(0, "Direct created","") _InetFile_Download($DownloadDomain, $DownloadRemotePath, $DownloadFileName, $DownloadPath) If @error Then MsgBox(0, "File downloaded","FAILED " & @error) Else MsgBox(0, "File downloaded","SUCCESS " & @error) EndIf Well I've done some testing and now know what's been happening and I even have a solution. My internet link has been a little sick for a few days and apparently it's been dropping out; specifically dropping out in the middle of the transfer. Looking through your script there is no checking for this particular fault. I've had a tinker with your code and come up with the code below, that I placed below the Fileexist check I've used the unused fault code 2 to indicate a "partly" downloaded file. If @InetGetBytesRead <> $i_CheckRFSize Then Return SetError(2, 0, "262160|" & StringTrimRight(@ScriptName, 4) & " ERROR|DOWNLOAD FAILED|Possible cause: File transfer interupted.") EndIf Here is the full modified function expandcollapse popup; #FUNCTION# ==================================================================================================== ================ ; Name ..........: _InetFile_Download ; Description ...: A UDF used for downloading files from a website. ; Syntax ........: _InetFile_Download($s_WebSite[, $s_RemoteDir = ""[, $s_RemoteFileName = ""[, $s_DownloadDir = ""[, $i_PBar = 0[, $i_Left = -1[, $i_Top = -1[, $i_Suppress = 0]]]]]]]) ; Parameters ....: $s_WebSite - website hosting the file ; $s_RemoteDir - directory located on the website that contains the remote file (default = root ("/")) ; $s_RemoteFileName - filename to be downloaded (default = @ScriptName) ; $s_DownloadDir - directory where file will be downloaded to (default = @TempDir) ; $i_PBar - whether or not a user created progress bar will be displayed [0=No, 1=Yes] (default = No, use local one) ; $i_Left - The left side of the progress bar (default = left will be computed according to GUICoordMode.) ; $i_Top - The top of the progress bar (default = top will be computed according to GUICoordMode.) ; $i_Suppress - suppress local error messages and use returned values instead (default = 0 [No]) ; Return values .: Success - sets @error 0 and returns an integer of the remote file size (for use with user created progressbars/GUI's if needed) ; Failure - either returns an appropriately formatted error message or returns an integer as above and sets @error: ; |@error = 1 (function parameter error) ; |@error = 2 (download interrupted - Part downloaded file) ; |@error = 3 (file error) ; |@error = 4 (internet error) ; Author ........: PartyPooper ; Modified ......: ; Remarks .......: Includes the ability to display either a locally produced progress bar window or one in the calling script. ; Related .......: ; Link ..........: http://www.autoitscript.com/forum/index.php?showtopic= ; Examples ......: ; ==================================================================================================== =========================== Func _InetFile_Download($s_WebSite, $s_RemoteDir = "", $s_RemoteFileName = "", $s_DownloadDir = "", $s_PBar = 0, $i_Left = -1, $i_Top = -1, $i_Suppress = 0) If $s_RemoteDir = "" Or $s_RemoteDir = -1 Then $s_RemoteDir = "/"; set remote directory to root if not specified If $s_RemoteFileName = "" Or $s_RemoteFileName = -1 Then $s_RemoteFileName = @ScriptName; set remote filename to check against if not specified If $s_DownloadDir = "" Or $s_DownloadDir = -1 Then $s_DownloadDir = @TempDir; set download directory to temp if not specified If $s_PBar = "" Or $s_PBar = -1 Then $s_PBar = 0; set to display local progress bar window If $i_Left = "" Then $i_Left = 1; left will be computed according to GUICoordMode if not specified If $i_Top = "" Then $i_Top = -1; top will be computed according to GUICoordMode if not specified If $i_Suppress = "" Or $i_Suppress = -1 Then $i_Suppress = 0; show local error messages ;##################################################### ; check for slash at end of website address and remove if found If StringRight($s_WebSite, 1) = "/" Then $s_WebSite = StringTrimRight($s_WebSite, 1) ;##################################################### ; check for slash at beginning of remote directory and put one in if not found If StringLeft($s_RemoteDir, 1) <> "/" Then $s_RemoteDir = "/" & $s_RemoteDir ;##################################################### ; check for trailing slash on remote directory and put one in if not found If StringRight($s_RemoteDir, 1) <> "/" Then $s_RemoteDir = $s_RemoteDir & "/" ;##################################################### ; check download directory for trailing backslash and put one in if not found If StringRight($s_DownloadDir, 1) <> "\" Then $s_DownloadDir = $s_DownloadDir & "\" ;##################################################### ; get file size for progress bar Local $i_CheckRFSize = InetGetSize($s_WebSite & $s_RemoteDir & $s_RemoteFileName) If @error Then; update not found If $i_Suppress = 0 Then MsgBox(262160, StringTrimRight(@ScriptName, 4) & " ERROR", "DOWNLOAD FAILED" & @CRLF & @CRLF & "Possible cause: File not found on website.") Return SetError(4, 0, "262160|" & StringTrimRight(@ScriptName, 4) & " ERROR|DOWNLOAD FAILED|Possible cause: File not found on website.") EndIf ;##################################################### ; check for old download If FileExists($s_DownloadDir & $s_RemoteFileName) Then; delete old file if found If Not FileDelete($s_DownloadDir & $s_RemoteFileName) Then; problem deleting old download If $i_Suppress = 0 Then MsgBox(262160, StringTrimRight(@ScriptName, 4) & " ERROR", "DOWNLOAD FAILED" & @CRLF & @CRLF & "Possible cause: Old download cannot be overwritten (may be read only).") Return SetError(3, 0, "262160|" & StringTrimRight(@ScriptName, 4) & " ERROR|DOWNLOAD FAILED|Possible cause: Old download cannot be overwritten (may be read only).") EndIf EndIf ;##################################################### ; start downloading remote file to download directory and return with results Local $i_GetFile = InetGet($s_WebSite & $s_RemoteDir & $s_RemoteFileName, $s_DownloadDir & $s_RemoteFileName, 1, 1) If $i_GetFile = 1 Then; remote file can be downloaded If $s_PBar = 0 Then; show progress bar window ProgressOn("Downloading...", $s_RemoteFileName, "0 %", $i_Left, $i_Top); display progress bar Do ProgressSet(Round((@InetGetBytesRead / $i_CheckRFSize) * 100, 0), Int(@InetGetBytesRead / $i_CheckRFSize * 100) & '% (' & Round(@InetGetBytesRead / 1024) & ' KB' & ' of ' & Round($i_CheckRFSize / 1024) & ' KB' & ')'); update progress bar Until Not @InetGetActive; do until file is fully downloaded ProgressSet(100, "Done", "Complete"); successfully downloaded program ProgressOff(); delete progress bar Do Sleep(250); create a delay loop to ensure that file has been downloaded and saved before continuing Until FileExists($s_DownloadDir & $s_RemoteFileName); keep looping until file exists in download directory If @InetGetBytesRead <> $i_CheckRFSize Then Return SetError(2, 0, "262160|" & StringTrimRight(@ScriptName, 4) & " ERROR|DOWNLOAD FAILED|Possible cause: File transfer interupted.") EndIf Return SetError(0, 0, $i_CheckRFSize) Else; don't display progress bar window - user will provide their own Return SetError(0, 0, $i_CheckRFSize); return to calling script with filesize EndIf Else; remote file can't be downloaded for some reason If $i_Suppress = 0 Then MsgBox(262160, StringTrimRight(@ScriptName, 4) & " ERROR", "DOWNLOAD FAILED" & @CRLF & @CRLF & "Possible cause: File cannot be downloaded for some reason.") Return SetError(4, 0, "262160|" & StringTrimRight(@ScriptName, 4) & " ERROR|DOWNLOAD FAILED|Possible cause: File cannot be downloaded for some reason.") EndIf EndFunc ;==>_InetFile_Download Could you run over it and see that I haven't messed something up or maybe you have a better solution then mine. Don't ya just love coding :-) John Morrison Some of my small contributions to AutoIt Browse for Folder Dialog - Automation SysTreeView32 | FileHippo Download and/or retrieve program information | Get installedpath from uninstall key in registry | RoboCopy function John Morrison aka Storm-E
PartyPooper Posted December 17, 2008 Author Posted December 17, 2008 No, that looks to be about the same as I would do, althought, I'm not sure if the @InetGetBytesRead macro will report the number of bytes or a -1 when the download fails. Either way, it should still report something different. I'll update the UDF in the first post.
storme Posted December 17, 2008 Posted December 17, 2008 (edited) No, that looks to be about the same as I would do, althought, I'm not sure if the @InetGetBytesRead macro will report the number of bytes or a -1 when the download fails. Either way, it should still report something different. I'll update the UDF in the first post.In the testing I did @InetGetBytesRead did go to -1 but only after the second loop "Until FileExists".Which is why I put the check for file size after that loop. If @InetGetBytesRead is lower then the actual file size or -1 it is caught.Onward and upwardJohn Morrison Edited December 17, 2008 by storme Some of my small contributions to AutoIt Browse for Folder Dialog - Automation SysTreeView32 | FileHippo Download and/or retrieve program information | Get installedpath from uninstall key in registry | RoboCopy function John Morrison aka Storm-E
PartyPooper Posted December 2, 2010 Author Posted December 2, 2010 ware is a InetFileUpdate.au3 file?No longer available. Newer versions of AutoIt3 made it stop working.
shai Posted December 2, 2010 Posted December 2, 2010 ok you have any other solution for "auto update"?
PartyPooper Posted December 3, 2010 Author Posted December 3, 2010 Unfortunately no, I no longer needed it, however, it shouldn't be too hard to create one using the info contained in the Help File. You just need to decide if you want to use the INI file method (see INIRead/INIWrite) or file size method (see InetGetSize/InetGetInfo/_FTP_FileGetSize).
Jagu Posted July 8, 2011 Posted July 8, 2011 Thanks bro... where is the script? i don't see it for some reason O.o
briandoc Posted January 10, 2012 Posted January 10, 2012 It would be helpful if you edited the first post to say that you pulled this script and it's no longer available for download. I went through the whole post analyzing if this will work for me and read through all the issues that got worked on only to get to the end to see that the script has been removed. Even though you say the code is broken in the latest versions, would you mind posting it for archival sake so that someone might find it useful and update it? Looks like you initially put a lot of work into it... kind of sad to see it just die when it could help others.
JohnOne Posted January 10, 2012 Posted January 10, 2012 Or perhaps when you are looking at a thread 3 and a half years old, you should check to see if files exist first. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
t0nZ Posted January 13, 2012 Posted January 13, 2012 Ok, someone knows an UDF , or a another way for autoupdate ? ThanX.
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