My AutoIt script should predict when a process will complete by saying The process will be complete at 3:18:24 PM
. But that is not happening. It takes these input values:
- Starting time
- Starting percentage
- Current time
- Current percentage
It displays:
"The extraction will be complete at 0".
I isolated the problem to _DateDiff()
. I thought the first parameter was n
for difference in minutes. But it returns 0
when I pass the next two parameters (date values spaced sixty minutes apart). Here's the code:
GUICreate("Completion Time Predictor", 300, 300)
;Here I enter the starting time and percentage
GUICtrlCreateLabel("Enter the start time:", 10, 10, 270, 29)
$StartTime = GUICtrlCreateDate("", 10, 40, 270, 21, $DTS_TIMEFORMAT)
GUICtrlCreateLabel("Enter the start percentage:", 10, 70, 270, 29)
Local $StartPercent = GUICtrlCreateInput("", 10, 100, 270, 21)
;Here I enter the current time and percentage
GUICtrlCreateLabel("Enter the current time:", 10, 130, 270, 29)
$CurrentTime = GUICtrlCreateDate("", 10, 160, 270, 21, $DTS_TIMEFORMAT)
GUICtrlCreateLabel("Enter the current percentage:", 10, 190, 270, 29)
Local $CurrentPercent = GUICtrlCreateInput("", 10, 220, 270, 21)
Local $CTRL_a = GUICtrlCreateButton("Calculate", 10, 260, 280, 21)
GUISetState()
Local $msg
Do
$msg = GUIGetMsg()
Select
Case $msg = $CTRL_a
$PercentChange = GUICtrlRead($CurrentPercent) - GUICtrlRead($StartPercent)
;This seems to be where everything is going wrong
$ChangePerMinute = $PercentChange / _DateDiff('n', GUICtrlRead($StartTime), GUICtrlRead($CurrentTime))
$MinutesRemaining = (100 - GUICtrlRead($CurrentPercent)) / $ChangePerMinute
$EndTime = _DateAdd('n', $MinutesRemaining, GUICtrlRead($CurrentTime))
MsgBox($MB_OK, "Predicted Completion Time:", "The extraction will be complete at " & $EndTime)
EndSelect
Until $msg = $GUI_EVENT_CLOSE
I have no idea what you are doing, but maybe this helps you finding the problem