themax90 Posted December 3, 2005 Posted December 3, 2005 Just use INetGet according to preset operations. Heres a small snippet. Not tested $DownloadDir is where you wish these files to be downloaded, must have trailing blackslash $IniFile is where the program will look for URLS $LogFile is where errors will be recorded $Max is the amount of files you wish to download according to the ini $DownloadTime is when you want the files to be updated $Track is a tracking variable Your ini should look like this [Files] 1=File1 2=File2 etc.... expandcollapse popup#NoTrayIcon Global $DownloadDir = "C:\" Global $IniFile = "Ini.ini" Global $LogFile = "Log.txt" Global $Track Global $Max = 1000 Global $DownloadTime = "6:00:00 AM" While 1 While Time() = $DownloadTime $Track = 1 For $Track = 1 To $Max Step 1 $URL = IniRead($IniFile, "Files", $Track, -1) Select Case $URL <> -1 $FileName = _ExtractName($URL) Select Case @Error <> -1 $Download = InetGet($URL, $DownloadDir & $FileName, 1, 0) If $Download = 0 Then FileWriteLine($LogFile, $URL & " failed to download at " & Time()) Case Else FileWrite($LogFile, "Errored downloading " & $URL & " at " & Time()) EndSelect Case Else FileWrite($LogFile, "Errored downloading " & $URL & " at " & Time()) EndSelect Next WEnd Sleep(100) WEnd ;=============================================================================== ; Function Name: _ExtractName() ; Description: Extracts a filename from a url or path for downloading/copying etc.... ; Sets @Error to -1 if error occurs, otherwise @Error = 0 ; Returns: ; %String% = Could Extract Filename (Success) ; -1 = No filename found (Failure) ; ; Author(s): Max Gardner <AutoIt Smith;king.of.all@comcast.net> ;=============================================================================== Func _ExtractName($String) Local $Path, $URL, $Filename, $FileCheck $Path = StringSplit($String, "\", 1) $URL = StringSplit($String, "/", 1) Select Case $Path[0] >= 2 ; Extract From Path SetError(0) $Filename = $Path[$Path[0]] $FileCheck = StringSplit($Filename, ".", 1) If $FileCheck[0] <= 1 Then SetError(-1) Return 0 EndIf SetError(0) Return $Filename Case $URL[0] >= 2 ; Extract From URL SetError(0) $Filename = $URL[$URL[0]] $FileCheck = StringSplit($Filename, ".", 1) If $FileCheck[0] <= 1 Then SetError(-1) Return 0 EndIf SetError(0) Return $Filename Case Else ; Filename Given SetError(0) Return $Path[1] EndSelect SetError(-1) Return -1 EndFunc ;==>_ExtractName ;=============================================================================== ; Function Name: Time() ; Description: Get Local Computer Time ; Returns: $Time ; ; Author(s): Max Gardner <AutoIt Smith;king.of.all@comcast.net> ;=============================================================================== Func Time() Local $Light = " AM", $Hour = @HOUR, $Minute = @MIN, $Sec = @SEC, $Time Select Case $Hour = 0 $Hour = 12 Case $Hour = 12 $Light = " PM" Case $Hour > 12 $Hour = (@HOUR) - 12 $Light = " PM" EndSelect $Time = $Hour & ":" & $Minute & ":" & $Sec & $Light Return $Time EndFunc ;==>Time I hope this helps. It should work for what you need and I hope you can learn from it!
Moderators SmOke_N Posted December 3, 2005 Moderators Posted December 3, 2005 Yea I was wondering when someone would post about @SW_HIDE until I saw about the third post where it was talked about downloading files.That is what INetGet() is for. Read the helpfile. It will download the file in the background. All of that is explained in the helpfile.Goodluck,JSHope that remark towards me, I read a bit further down than just the '3rd' post to the 12th acutally where it was said: thanks for your help. You took all my fun away. back to my original question. If the script is wrapped into a gui the user will not be able to see what is going on behind the scene.?.?Which is why I mentioned the @SW_HIDE.Anyway, if the end result was that Snaven was only looking for the download option and nothing else, then yes... It looks like most have given an example of how to achieve this. If he/she was looking at automating further past the download point, then maybe @SW_HIDE will help. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
ivan Posted December 3, 2005 Posted December 3, 2005 AutoIt Smith Cool! This really simplifies a process i did this week... a long story, but can´t wait to try! I was working on a similar udf coz i needed to write files on local computers and check for processes not existing before sending them via ftp to a server. I actually had to use 2 filenames for each process one containing the info with .log extention and the other an empty file with .txt extention. This was set so a remote computer can pick up the log file on the condition that the txt file existed which served me as a means to get the filename. Again, comes in really handy Think out of the boxGrabber: Yet another WinInfo tool_CSVLib (still alpha)Dynamic html in au3
themax90 Posted December 3, 2005 Posted December 3, 2005 No problem, wrote that in about 5 minutes using two of my own functions. Glad it could be of use
JSThePatriot Posted December 3, 2005 Posted December 3, 2005 Hope that remark towards me, I read a bit further down than just the '3rd' post to the 12th acutally where it was said: Which is why I mentioned the @SW_HIDE.Anyway, if the end result was that Snaven was only looking for the download option and nothing else, then yes... It looks like most have given an example of how to achieve this. If he/she was looking at automating further past the download point, then maybe @SW_HIDE will help.I have read the entire thread. I was saying that your talking about the @SW_HIDE was a good thing. I was suprised that no body mentioned it before . I guess that came out wrong hehe.JS AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)
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