bdenn Posted March 9, 2017 Share Posted March 9, 2017 Hello, I'm flying blind here and not sure how to accomplish this. I created a form thru Koda with, input1, input2, label1, & button1. For now I need to format input1, input2, and label1 as time. I want to be able to enter a timecode in input1 and input2 and press button1 and have input1 and input2 add together and display in label1. How do I go about this? Thanks! Bdenn. Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted March 9, 2017 Moderators Share Posted March 9, 2017 @bdenn how about posting your code, so we don't have to rewrite the whole thing? "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! Link to comment Share on other sites More sharing options...
bdenn Posted March 9, 2017 Author Share Posted March 9, 2017 I do not really have any code as of yet. I will post what I have. but after I figure out how to add two inputs together then I will make it work for the fill application. CODE: expandcollapse popup#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.14.2 Author: myName Script Function: Template AutoIt script. #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form=c:\vault\autoit\timecode calculator\timecode calculator form.kxf $Form1 = GUICreate("Timecode Calculator", 296, 537, 192, 124) $Input1 = GUICtrlCreateInput("23:35:00", 40, 45, 97, 21) $Input2 = GUICtrlCreateInput("Input1", 40, 72, 97, 21) $Input3 = GUICtrlCreateInput("Input1", 40, 98, 97, 21) $Input4 = GUICtrlCreateInput("Input1", 40, 125, 97, 21) $Input5 = GUICtrlCreateInput("Input1", 40, 151, 97, 21) $Input6 = GUICtrlCreateInput("Input1", 40, 178, 97, 21) $Input7 = GUICtrlCreateInput("Input1", 40, 204, 97, 21) $Input8 = GUICtrlCreateInput("Input1", 40, 231, 97, 21) $Input9 = GUICtrlCreateInput("Input1", 40, 257, 97, 21) $Input10 = GUICtrlCreateInput("Input1", 40, 284, 97, 21) $Input11 = GUICtrlCreateInput("Input1", 40, 310, 97, 21) $Input12 = GUICtrlCreateInput("Input1", 40, 337, 97, 21) $Input13 = GUICtrlCreateInput("Input1", 40, 363, 97, 21) $Input14 = GUICtrlCreateInput("Input1", 40, 390, 97, 21) $Input15 = GUICtrlCreateInput("Input1", 40, 416, 97, 21) $Input16 = GUICtrlCreateInput("Input1", 40, 443, 97, 21) $Button1 = GUICtrlCreateButton("Calculate", 40, 472, 161, 41) $Label1 = GUICtrlCreateLabel("HH:MM:SS", 147, 48, 58, 17) $Label2 = GUICtrlCreateLabel("HH:MM:SS", 147, 75, 58, 17) $Label3 = GUICtrlCreateLabel("HH:MM:SS", 147, 101, 58, 17) $Label4 = GUICtrlCreateLabel("HH:MM:SS", 147, 128, 58, 17) $Label5 = GUICtrlCreateLabel("HH:MM:SS", 147, 154, 58, 17) $Label6 = GUICtrlCreateLabel("HH:MM:SS", 147, 181, 58, 17) $Label7 = GUICtrlCreateLabel("HH:MM:SS", 147, 207, 58, 17) $Label8 = GUICtrlCreateLabel("HH:MM:SS", 147, 234, 58, 17) $Label9 = GUICtrlCreateLabel("HH:MM:SS", 147, 260, 58, 17) $Label10 = GUICtrlCreateLabel("HH:MM:SS", 147, 287, 58, 17) $Label11 = GUICtrlCreateLabel("HH:MM:SS", 147, 313, 58, 17) $Label12 = GUICtrlCreateLabel("HH:MM:SS", 147, 340, 58, 17) $Label13 = GUICtrlCreateLabel("HH:MM:SS", 147, 366, 58, 17) $Label14 = GUICtrlCreateLabel("HH:MM:SS", 147, 393, 58, 17) $Label15 = GUICtrlCreateLabel("HH:MM:SS", 147, 419, 58, 17) $Label16 = GUICtrlCreateLabel("HH:MM:SS", 147, 446, 58, 17) $Label17 = GUICtrlCreateLabel("TIMECODE CALCULATOR", 12, 8, 270, 29) GUICtrlSetFont(-1, 15, 800, 0, "MS Sans Serif") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### ; _DateAdd #include <Date.au3> #include <MsgBoxConstants.au3> While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $Button1 Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Link to comment Share on other sites More sharing options...
Subz Posted March 9, 2017 Share Posted March 9, 2017 (edited) Try something like this: expandcollapse popup#include <Date.au3> #include <GuiDateTimePicker.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> Local $hGUI = GUICreate("Timer", 320, 80) $hTimer01 = _GUICtrlDTP_Create($hGUI, 5, 15, 100, 21, $DTS_UPDOWN) _ConfigTimer($hTimer01, @HOUR, @MIN, @SEC) $hTimer02 = _GUICtrlDTP_Create($hGUI, 110, 15, 100, 21, $DTS_UPDOWN) _ConfigTimer($hTimer02) $hTimer03 = GUICtrlCreateLabel("00:00:00", 215, 15, 100, 21, BitOR($SS_CENTER, $SS_CENTERIMAGE)) $hCalculator = GUICtrlCreateButton("Calculate", 215, 40, 100, 30) GUISetState() While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE Exit Case $hCalculator _CalcTime($hTimer01, $hTimer02, $hTimer03) EndSwitch WEnd Func _CalcTime($hTime01, $hTime02, $hTime03) Local $aTime03[7] = [False, @YEAR, 1, 1] Local $aTime01 = _GUICtrlDTP_GetSystemTime($hTime01) Local $aTime02 = _GUICtrlDTP_GetSystemTime($hTime02) Local $iTime01 = _TimeToTicks($aTime01[3], $aTime01[4], $aTime01[5]) Local $iTime02 = _TimeToTicks($aTime02[3], $aTime02[4], $aTime02[5]) Local $iTime03 = $iTime01 + $iTime02 _TicksToTime($iTime03, $aTime03[4], $aTime03[5], $aTime03[6]) GUICtrlSetData($hTime03, StringFormat("%02i:%02i:%02i", $aTime03[4], $aTime03[5], $aTime03[6])) EndFunc Func _ConfigTimer(ByRef $hTime01, $iHour = 00, $iMin = 00, $iSec = 00) Local $aDefaultTime[7] = [False, @YEAR, 1, 1, $iHour, $iMin, $iSec] _GUICtrlDTP_SetFormat($hTime01, "HH:mm:ss") _GUICtrlDTP_SetSystemTime($hTime01, $aDefaultTime) EndFunc Edited March 9, 2017 by Subz Updated StringFormat thanks @Malkey Link to comment Share on other sites More sharing options...
bdenn Posted March 9, 2017 Author Share Posted March 9, 2017 Thank You Subz, That worked well. I will try and expand on that and see what happens. -Bdenn Link to comment Share on other sites More sharing options...
Malkey Posted March 9, 2017 Share Posted March 9, 2017 Another example. @Subz Note the use of a single StringFormat function in the message box. expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Array.au3> Local $nMsg, $aInput[18], $aTemp Local $sData, $iSec, $iMinCarry, $iMin, $iHrsCarry, $iHrs, $iDayCarry, $iDay $Form1 = GUICreate("Timecode Calculator", 296, 537, 192, 124) For $i = 0 To UBound($aInput) - 1 $aInput[$i] = GUICtrlCreateInput("", 40, 45 + $i * 23, 97, 21) GUICtrlCreateLabel("[Days ]HH:MM:SS", 147, 48 + $i * 23, 95, 17) Next ; Enter test data. GUICtrlSetData($aInput[0], "2 23:35:40") GUICtrlSetData($aInput[1], "03:35:30") $Button1 = GUICtrlCreateButton("Calculate", 40, 472, 161, 41) GUICtrlCreateLabel("TIMECODE CALCULATOR", 12, 8, 270, 29) GUICtrlSetFont(-1, 15, 800, 0, "MS Sans Serif") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $Button1 ; _DateAdd Local $aTime[4] For $i = 0 To UBound($aInput) - 1 $sData = GUICtrlRead($aInput[$i]) If $sData <> "" Then ;$aTemp = StringRegExp($sData, "(?:(\d*)\h)?(\d*):(\d*):(\d*)", 3); <- Alternative to StringSplit & _ArrayInsert below. $aTemp = StringSplit($sData, " :", 2) ; $STR_CHRSPLIT (0) + $STR_NOCOUNT (2) If UBound($aTemp) = 3 Then _ArrayInsert($aTemp, 0, 0) For $j = 0 To 3 $aTime[$j] += Int($aTemp[$j]) ; Add all days, all hours, all mins, and, all secs. Next EndIf Next $iSec = Mod($aTime[3], 60) $iMinCarry = Int($aTime[3] / 60) $iMin = Mod($aTime[2] + $iMinCarry, 60) $iHrsCarry = Int(($aTime[2] + $iMinCarry) / 60) $iHrs = Mod(($aTime[1] + $iHrsCarry), 24) $iDayCarry = Int(($aTime[1] + $iHrsCarry) / 24) $iDay = $aTime[0] + $iDayCarry MsgBox(0, "Sum = ", StringFormat("%i days %02i:%02i:%02i", $iDay, $iHrs, $iMin, $iSec)) Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd 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