michaelslamet Posted June 9, 2013 Share Posted June 9, 2013 Hi, I need to process some files, can be hundreads at a time. While processing those files, I plan to let the user know approx time remaining until processing finish, but I have no idea how to do that. I think something like: $start_time = _now() For $n = 1 to $number_of_files ; doing some processes here ; find out how long is the average time to process those files $approx_time_remaining = $average_time_process * ($number_of_files - $n) SplashTextOn("Please wait","Processing file number " & $n & @CRLF & "Approx time remaing: " & $approx_time_remaining ,300,50) Next Maybe using TimerInit() and calculate the diffferent using TimerDiff? Link to comment Share on other sites More sharing options...
water Posted June 9, 2013 Share Posted June 9, 2013 Wouldn't a counter (e.g. "n of m files copied") be enough because the time you use it needs is just an approximation? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
Moderators Solution Melba23 Posted June 9, 2013 Moderators Solution Share Posted June 9, 2013 michaelslamet, I would do it like this: $iCurr_Average= 0 $iPasses = Random(3, 10, 1) For $i = 1 To $iPasses ; Get a timestamp $iBegin = TimerInit() ; A random Sleep Sleep(Random(1000, 5000, 1)) ; How long was that $iThis_Time = Int(TimerDiff($iBegin)) ConsoleWrite("Pass " & $i & " time: " & $iThis_Time & @CRLF) ; Just for display ; Calculate new average If $i > 1 Then $iCurr_Average = Int((($iCurr_Average * $i - 1) + $iThis_Time) / ($i + 1)) Else $iCurr_Average = $iThis_Time EndIf ConsoleWrite("Calc average: " & $iCurr_Average & @CRLF) ; Just for display ; Calculate time remaining $iTime_Remaining = ($iPasses - $i) * $iCurr_Average ConsoleWrite("Remaining: " & $iTime_Remaining & @CRLF) Next All clear? M23 fede97 and michaelslamet 2 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
michaelslamet Posted June 9, 2013 Author Share Posted June 9, 2013 Hi Water, The files can be thousands and each file can take up to a minute, after the processing done, the user need to run it. He usually run it using scheduler, so I think if he know when will the process done, it will be much better even it's only a approx. Thanks Link to comment Share on other sites More sharing options...
michaelslamet Posted June 9, 2013 Author Share Posted June 9, 2013 Melba, Helps a lot like always Thanks! In the example, is the $iTime_Remaining in milliseconds? What if I want to display it using HH:MM:SS format? So it will said something like: "Remaining: 00:01:55" Link to comment Share on other sites More sharing options...
water Posted June 9, 2013 Share Posted June 9, 2013 As I have seen Melbas code perfectly solves the problem. The more files were copied the more accurate the calculation gets. So: Stick with Melbas solution. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 9, 2013 Moderators Share Posted June 9, 2013 michaelslamet, is the $iTime_Remaining in milliseconds?To the accuracy you require - yes. What if I want to display it using HH:MM:SS format?You do some maths to convert it! Or....You use the _TicksToTime function to do it - look in the Helpfile for details. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
michaelslamet Posted June 9, 2013 Author Share Posted June 9, 2013 Melba, _TicksToTime seems great for this, thanks! Thanks too, Water! Link to comment Share on other sites More sharing options...
water Posted June 9, 2013 Share Posted June 9, 2013 Thanks, but I didn't do much to help you solve the problem My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 9, 2013 Moderators Share Posted June 9, 2013 michaelslamet,Glad I could help. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
michaelslamet Posted June 9, 2013 Author Share Posted June 9, 2013 Water: every help, no matter how big or small, is a help Melba: you help newbie like me all the time Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 9, 2013 Moderators Share Posted June 9, 2013 michaelslamet,That is what the forum is all about. I hope that you will be able to help others soon. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
michaelslamet Posted June 9, 2013 Author Share Posted June 9, 2013 If you notice, I try to help in few thread, but it's hard to find threads that can be solved using my (very) low skill Link to comment Share on other sites More sharing options...
water Posted June 9, 2013 Share Posted June 9, 2013 The more you code the more you know the more you can help others. It's a "long and winding road" as one of my favorite bands would have sung. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
michaelslamet Posted June 9, 2013 Author Share Posted June 9, 2013 Water: yes, thank you for remind me I can see my AutoIT skill improve over time since I start using it few years ago 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