MyEarth Posted June 17, 2014 Posted June 17, 2014 (edited) Hello guys I have a commandline software that create report based on the characteristics of the pc Example create 10 files .htm in a folder called "Report" Now this commandline don't have any stdout-stderr so i can't check nothing. I have think to create a progress bar based on the file count of the folder, like: At start folder "Report" has 0 file? Save that value in a $var --> Run(mysoftware.exe) ProgressBar --> Creating 1 of 10 .htm... ( 10 % ) Compare $var with the file count, folder "Report" has now +1 file? ProgressBar --> Creating 2 of 10 .htm... ( 20 % ) etc. ovb in real-temp until 10 of 10 and 100% Except Run(mysoftware.exe) i don't have any idea how to accomplish this (post an empty GUI with a progress bar and a label is useless) some suggestion? Many Thanks Edited June 17, 2014 by MyEarth
Moderators JLogan3o13 Posted June 17, 2014 Moderators Posted June 17, 2014 (edited) Hi, MyEarth. Have you looked at the help file? The example for ProgressOn does almost exactly what you are seeking to do, using a for loop. It would be trivial to modify it for your needs: For $i = 1 to 10 ProgressSet($i, $i & "%") ;Code to process file Next ProgressSet(100, "Done", "Complete") Edited June 17, 2014 by JLogan3o13 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
MyEarth Posted June 17, 2014 Author Posted June 17, 2014 Wait, i know how to create a ProgressBar ( i prefer GUICtrlCreateProgress+GUICtrlSetData ) but the problem is how to increase the progress count based on the commandline, i have think to check the file count but i don't know what is the proper way.
Moderators JLogan3o13 Posted June 17, 2014 Moderators Posted June 17, 2014 (edited) Just to clarify, you run this report and it generates 10 files in this directory, correct? Are there any other files in the directory? Edit: Something like this, perhaps: #include <File.au3> ProgressOn("Progress Meter", "Increments every second", "0%") For $i = 1 To 10 FileWrite(@DesktopDir & "\Test\" & $i & ".txt", "Test") ;create a new file in the directory, this is what your command line software is doing $aArray = _FileListToArray(@DesktopDir & "\Test", "*", 1) Sleep(1000) ProgressSet($i * 10, $i * 10 & "%") Next ProgressSet(100, "Done", "Complete") Sleep(5000) ProgressOff() Edited June 17, 2014 by JLogan3o13 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
MyEarth Posted June 17, 2014 Author Posted June 17, 2014 you run this report and it generates 10 files in this directory, correct? --> Yes, can be 10 or more but depend by me, i'm always know how many report it create Are there any other files in the directory? --> Is possible. I'll check the script
MyEarth Posted June 17, 2014 Author Posted June 17, 2014 (edited) I have resolved partially Local $MyPath = @ScriptDir & "\Report" Local $nReport = 145 Local $MySoft = Run("MySoftware.exe") Do $iCurrentCount = _TotalFileNumber($MyPath) GUICtrlSetData($Label, $iCurrentCount & " of " & $nReport & ")") GUICtrlSetData($ProgressBar, $iCurrentCount * $nReport) ;ERROR HERE! Until $iCurrentCount = $iStartingCount + $nReport Func _TotalFileNumber($sPath) Local $sSearch = FileFindFirstFile($sPath & "\*.*"), $iCount = 0 If $sSearch = -1 Then Return $iCount While 1 Local $sFile = FileFindNextFile($sSearch) If @error Then ExitLoop $iCount += 1 WEnd FileClose($sSearch) Return $iCount EndFunc ;==>_TotalFileNumber About the $Label, every work fine ( it flickering but i can resolve later, it's not a problem ) but about the progress bar, i don't know how to make the correct math If the file are 10, $iCurrentCount * $nReport is correct but if the file are 145? Or 765? Thanks Edited June 17, 2014 by MyEarth
Solution BrewManNH Posted June 17, 2014 Solution Posted June 17, 2014 (Current File #/Total Files)*100 = Percentage If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
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