Всем час добрый! На вход подаем данные начала и время записи. Нужно автоматически рассчитывать время окончания записи. Ниже, то что у меня получилось. Считает вроде верно, но понимаю, что намудрил, поэтому Прошу направить на пусть истинный или показать, как это сделать правильно.
Код:#include <GUIConstants.au3> #include <Date.au3> $AForm1_1 = GUICreate("Screen Recorder", 599, 50, 213, 276) $Group1 = GUICtrlCreateGroup("Начать запись", 2, 0, 108, 45) $nDayStartInput = GUICtrlCreateInput("", 9, 16, 30, 21) GUICtrlSetTip(-1, "День") $nHourStartInput = GUICtrlCreateInput("", 40, 16, 30, 21) GUICtrlSetTip(-1, "Часы") $nMinutStartInput = GUICtrlCreateInput("", 72, 16, 30, 21) GUICtrlSetTip(-1, "Минуты") GUICtrlCreateGroup("", -99, -99, 1, 1) $Group4 = GUICtrlCreateGroup("Время записи", 112, 0, 92, 45) $nHourRecord = GUICtrlCreateInput("", 126, 16, 30, 21) $nMinutrRecord = GUICtrlCreateInput("", 158, 16, 30, 21) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group2 = GUICtrlCreateGroup("Закончить запись", 206, 0, 108, 45) $nDayStopInput = GUICtrlCreateInput("", 213, 16, 30, 21) GUICtrlSetTip(-1, "День") $nHourStopInput = GUICtrlCreateInput("", 244, 16, 30, 21) GUICtrlSetTip(-1, "Часы") $nMinutStopInput = GUICtrlCreateInput("", 276, 16, 30, 21) GUICtrlSetTip(-1, "Минуты") GUICtrlCreateGroup("", -99, -99, 1, 1) $ButtonOk = GUICtrlCreateButton("OK", 526, 4, 67, 25) GUISetState(@SW_SHOW) While 1 Sleep (1000) $TimeOnPanele = GUICtrlCreateLabel( @HOUR & ' : '& @MIN & ' : '& @SEC , 532, 32, 68, 17) ; создаем обновляемый гуй с системным временем (нужно найти правильное решение) $nConvertDaysHoursMinutsStartInput = GUICtrlRead($nDayStartInput)*24*60 + GUICtrlRead($nHourStartInput) *60 + GUICtrlRead($nMinutStartInput) ;переводим все стартовые значения в минуты $nConvertHoursMinutsRecordInput = GUICtrlRead($nHourRecord)*60 + GUICtrlRead($nMinutrRecord) ; переводим все значения записи в минуты $nConvertSummAllMinuts = $nConvertDaysHoursMinutsStartInput + $nConvertHoursMinutsRecordInput ; суммируем все минуты старта и записи $nMinutStopSumm = Int(Mod($nConvertSummAllMinuts, 60)) ; получаем целое число - остаток от деления минуты $nHourStopSumm = Int(Mod($nConvertSummAllMinuts /60, 24)) ; получаем целое число часов - остаток от деления часов $nDayStopSumm = Int($nConvertSummAllMinuts /60 /24) ; получаем целое число - всего дней в минутах $nDayStopDiff = $nDayStopSumm - GUICtrlRead($nDayStartInput) ; разность дней = дни(итоговое) - дни(начальное) ; Находим реальную дату конца записи $sDateFormat = @YEAR &'/'& @MON &'/'& GUICtrlRead($nDayStartInput)&' 00:00:00' $sNextDate = _DateAdd("d", $nDayStopDiff, $sDateFormat) ; получаем дату в формате 0001/01/01 00:00:00 конца записи $sCutCellDate = StringMid($sNextDate, 9, 2) ; извлекаем календарное число конца записи из полученной даты ; Задаем конечные значения Дня, Часа, Минуты $nDayStopSummNew = GUICtrlSetData($nDayStopInput, $sCutCellDate) $nHourStopInputNew = GUICtrlSetData($nHourStopInput, $nHourStopSumm) $nMinutStopInputNew = GUICtrlSetData($nMinutStopInput, $nMinutStopSumm) $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $ButtonOk While 1 Sleep (1000) MsgBox(0,0,$nConvertSummAllMinuts &' = '& $nDayStopSumm &' дн '& $nHourStopSumm &' час '& $nMinutStopSumm &' мин'& @CRLF &'Уменьшаемое: '& $nDayStopSumm & @CRLF &'Вычитаемое: '& GUICtrlRead($nDayStartInput)& @CRLF &'Разность: '& $nDayStopDiff & @CRLF & 'Новая дата: '& $sNextDate & @CRLF &'Извлеченная дата: '& $sCutCellDate & @CRLF &'Фомат даты: '& $sDateFormat) WEnd EndSwitch WEnd