stefionesco Posted December 18, 2011 Posted December 18, 2011 There is some way to make A + B = C when A, B, and C is in time format? I mean... 0:14 + 1:24 = 1:38 Something like that... Excel can do this but I can't figure out who to do it in Autoit.
Developers Jos Posted December 18, 2011 Developers Posted December 18, 2011 Look at the _dateAdd() UDF in the helpfile. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Moderators Melba23 Posted December 18, 2011 Moderators Posted December 18, 2011 stefionesco, There is no native function - but this little function should work: $sTime_1 = "0:14" $sTime_2 = "1:24" $sSum = _TimeAdd($sTime_1, $sTime_2) MsgBox(0, "Sum", $sSum) Func _TimeAdd($sTime_1, $sTime_2) $aTime_1 = StringSplit($sTime_1, ":") $aTime_2 = StringSplit($sTime_2, ":") $iMinutes = Mod($aTime_1[2] + $aTime_2[2], 60) $iHours = $aTime_1[1] + $aTime_2[1] + Int(($aTime_1[2] + $aTime_2[2]) / 60) Return $iHours & ":" & $iMinutes EndFunc Please ask if you have any questions. 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
stefionesco Posted December 18, 2011 Author Posted December 18, 2011 Yes... Something like that. I'll try now to put it where I need. Respect Stef Ionesco
stefionesco Posted December 18, 2011 Author Posted December 18, 2011 I want to do something like this #include <GUIConstantsEx.au3> #include <Date.au3> Dim $msg, $calculate, $out Global $time1, $time2, $time_result GUICreate("Time operation", 270, 150) GUISetState(@SW_SHOW) $time1 = GUICtrlCreateInput("", 10, 40, 50, 20) GUICtrlCreateLabel("+", 80, 40, 20, 20) $time2 = GUICtrlCreateInput("",110, 40, 50, 20) GUICtrlCreateLabel("=", 180, 40, 20, 20) $time_result = GUICtrlCreateInput("", 200, 40, 50, 20) $calculate = GUICtrlCreateButton("Calculate", 50, 80, 100, 25, 0) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $calculate $out = $time1 + $time2 GUICtrlSetData ($time_result, $out) EndSelect WEnd But it didn't work. The result is always 8. Can somebody explain me why?
Developers Jos Posted December 18, 2011 Developers Posted December 18, 2011 You need to use guictrlread() to get the values from the controls. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Moderators Melba23 Posted December 18, 2011 Moderators Posted December 18, 2011 (edited) stefionesco,You need to use GUICtrlRead - at the moment you are just adding the ControlIDs of the 2 inputs. Take a look at this:#include <guiconstantsex.au3> #include <date.au3> Global $msg, $calculate, $out ; Do not use Dim Global $time1, $time2, $time_result GUICreate("Time operation", 270, 150) $time1 = GUICtrlCreateInput("", 10, 40, 50, 20) GUICtrlCreateLabel("+", 80, 40, 20, 20) $time2 = GUICtrlCreateInput("", 110, 40, 50, 20) GUICtrlCreateLabel("=", 180, 40, 20, 20) $time_result = GUICtrlCreateInput("", 200, 40, 50, 20) $calculate = GUICtrlCreateButton("Calculate", 50, 80, 100, 25, 0) GUISetState(@SW_SHOW) ; Add this after creating the controls While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $calculate ; You need the Case $msg = here $out = GUICtrlRead($time1) + GUICtrlRead($time2) GUICtrlSetData($time_result, $out) EndSelect WEndAll clear? M23Edit: Took 2 minutes for the "New reply" alert to show up - I would not have bothered otherwise! Edited December 18, 2011 by Melba23 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
stefionesco Posted December 18, 2011 Author Posted December 18, 2011 Thanks a lot. I'm new and I'm learning. Please have patience. Thanks again for all the tips. Respect Stef Ionesco
Moderators Melba23 Posted December 18, 2011 Moderators Posted December 18, 2011 stefionesco,I'm new and I'm learning.Please have patience.We all were at one time - and we will. 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
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