dcjohnston Posted November 3, 2009 Share Posted November 3, 2009 I have a file that is being downloaded from another source, but I want to place in the system tray the status of the size of the file being downloaded. For Example: A 200 mb file called setup.exe starts to copy into c:\tempdir I would like an auto it script to monitor the C:\TEMPDIR directory for the setup.exe file and report its download status into the system tray. Link to comment Share on other sites More sharing options...
EndFunc Posted November 3, 2009 Share Posted November 3, 2009 (edited) I have a file that is being downloaded from another source, but I want to place in the system tray the status of the size of the file being downloaded. For Example: A 200 mb file called setup.exe starts to copy into c:\tempdir I would like an auto it script to monitor the C:\TEMPDIR directory for the setup.exe file and report its download status into the system tray. I would start with FileGetSize ( "filename" ) and report it back to the system tray perhaps with an icon and a tool tip using TraySetToolTip ( [text] ). Do you have any code? Tried anything yet? Edited November 3, 2009 by EndFunc EndFuncAutoIt is the shiznit. I love it. Link to comment Share on other sites More sharing options...
dcjohnston Posted November 3, 2009 Author Share Posted November 3, 2009 (edited) Yea, I tried using FileGetSize but when you copy the file, explorer reports the files full file size not an increasing size as it copies. InetGet allows you to trap the bytes as the file downloads. When you copy in explorer you cant trap the increasing file size. For Example if setup.exe is 20mb, and you copy it into c:\tempdir, as soon as it starts copying, explorer shows its file size as 20mb. I was hoping there was some way to capture the actual file size and display it like I do with inetget. Edited November 3, 2009 by dcjohnston Link to comment Share on other sites More sharing options...
EndFunc Posted November 3, 2009 Share Posted November 3, 2009 Yea, I tried using FileGetSize but when you copy the file, explorer reports the files full file size not an increasing size as it copies. InetGet allows you to trap the bytes as the file downloads. When you copy in explorer you cant trap the increasing file size.For Example if setup.exe is 20mb, and you copy it into c:\tempdir, as soon as it starts copying, explorer shows its file size as 20mb.I was hoping there was some way to capture the actual file size and display it like I do with inetget.Ah I see. Well maybe it might be more accurate using _WinAPI_GetFileSizeEx. EndFuncAutoIt is the shiznit. I love it. Link to comment Share on other sites More sharing options...
dcjohnston Posted November 4, 2009 Author Share Posted November 4, 2009 (edited) Ah I see. Well maybe it might be more accurate using _WinAPI_GetFileSizeEx. Hey, Thanks, it does not seem to work using the code below. The first message box returns a 0 regardless of the file. #Include <WinAPI.au3> Global $sFile, $hFile $sfile = _WinAPI_GetFileSizeEx ("C:\Program Files\Altiris\Altiris Agent\Software Delivery\{CB3DAC5C-4ED1-4E06-9CF3-69D414A4D114}\cache\setupold.exe");===========================Change MsgBox(4096, "", "This is the file size: " & $sfile & "", 10) While $sfile <> "1" MsgBox(4096, "", "This is the file size:" & $sfile & "", 10) $MB = Round($sfile/1048576,2) TrayTip("Downloading Your PowerPoint Training Video... Please Wait...", "" & $MB & " of 986 mb downloaded.", 10, 16);===========================Change Sleep(250) Wend Edited November 4, 2009 by dcjohnston Link to comment Share on other sites More sharing options...
Litoy Posted November 11, 2015 Share Posted November 11, 2015 (edited) I know it's kind of nekro posting, but I have encountered similar error: FileGetSize() only returns size value when file is not updating.For example: I concatenate some files via cat.exe from UnixUtils, but FileGetSize() always return 0 before the process is completed (then it returns full file size). Managed to solve it using CMD launch:for %I in (C:\file.txt) do @echo %~zIAutoIT example of using it:Local $sFilePath = "C:\Temp\MergedFile.arc" Local $iFinalSize = Int(4723620727, 2) Local $iSize = Int(0, 2) ConsoleWrite('Checking file ' & $sFilePath & @CRLF) While $iSize < $iFinalSize $iSize = Int(StringReplace(_RunAndGetSTD('for %I in (' & $sFilePath & ') do @echo %~zI'), @CRLF, ''), 2) ConsoleWrite('Size: ' & $iSize & ' bytes' & @CRLF) Sleep(2000) WEnd ; This function runs CMD in hidden window and gets its stdout Func _RunAndGetSTD(Const $sCMD) Local $sTMP = '' Local $sSTD = '' Local Const $iPID = Run(@ComSpec & ' /c ' & $sCMD, '', @SW_HIDE, 8) While 1 $sTMP = StdoutRead($iPID, False, False) If @error Then ExitLoop Else $sSTD &= $sTMP Sleep(250) EndIf WEnd Return $sSTD EndFunc ;==>_RunAndGetSTD Edited November 11, 2015 by Litoy 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