Bert Posted October 2, 2006 Share Posted October 2, 2006 Does anyone have a example of a timer that starts from 00:00, but does NOT use an array? I've got Valuter's timer, but it is so array depended, I can't rip out what I need without pulling my hair out. The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
Valuater Posted October 2, 2006 Share Posted October 2, 2006 lol 8) Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted October 2, 2006 Moderators Share Posted October 2, 2006 Does anyone have a example of a timer that starts from 00:00, but does NOT use an array? I've got Valuter's timer, but it is so array depended, I can't rip out what I need without pulling my hair out.You could do your own time and use this UDF that I made to do the addition and or subtraction Sending it the macros @Hour/@Min/@Sec http://www.autoitscript.com/forum/index.ph...st&p=207691 Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Bert Posted October 2, 2006 Author Share Posted October 2, 2006 I've spent hours trying to find a example in the forum with no luck. For some reason this is just tearing me a new one in figuring this out. all I'm looking to do is click a button, and the timer starts from 00:00. I looked at what smoke pointed out, but to twist it to what I want is too confusing for me. I'm the first to say it, and I have no shame The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
Bert Posted October 2, 2006 Author Share Posted October 2, 2006 (edited) Man, I'm an I found it in the help file. Edited October 2, 2006 by vollyman The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted October 2, 2006 Moderators Share Posted October 2, 2006 I've spent hours trying to find a example in the forum with no luck. For some reason this is just tearing me a new one in figuring this out. all I'm looking to do is click a button, and the timer starts from 00:00. I looked at what smoke pointed out, but to twist it to what I want is too confusing for me. I'm the first to say it, and I have no shame Not quote sure how it was confusing with the explination and examples there:Dim $Time1 = @HOUR & ':' & @MIN & ':' & @SEC, $Time2 While 1 ToolTip('Timer Started:' & @CR & _ _StrAddSub($Time1, @HOUR & ':' & @MIN & ':' & @SEC, 0), 0, 0) Sleep(100) WEnd Func _StrAddSub($sTime1, $sTime2, $iAdd = 1, $sDelim = ':'); $iAdd = 1 Add, $iAdd = 0 Subtract Local $aSplit1 = StringSplit($sTime1, $sDelim), $iSubTotal = 0 Local $aSplit2 = StringSplit($sTime2, $sDelim) If $aSplit1[0] <> 3 Or $aSplit2[0] <> 3 Then Return SetError(0, 0, 0) Local $iTotal1 = ((Int($aSplit1[1]) * 3600) + (Int($aSplit1[2]) * 60) + (Int($aSplit1[3]))) Local $iTotal2 = ((Int($aSplit2[1]) * 3600) + (Int($aSplit2[2]) * 60) + (Int($aSplit2[3]))) If $iAdd Then $iSubTotal = $iTotal1 + $iTotal2 ElseIf $iTotal1 >= $iTotal2 Then $iSubTotal = $iTotal1 - $iTotal2 Else $iSubTotal = $iTotal2 - $iTotal1 EndIf Local $iHour = Int(($iSubTotal / 3600)) Local $iMin = Int(($iSubTotal - ($iHour * 3600)) / 60) Local $iSec = Int(($iSubTotal - $iHour * 3600) - ($iMin * 60)) Return StringFormat('%02d', $iHour) & $sDelim & StringFormat('%02d', $iMin) & $sDelim & StringFormat('%02d', $iSec) EndFunc Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Bert Posted October 2, 2006 Author Share Posted October 2, 2006 This was much simpler for me to understand and to make work for what I needed: #include <GUIConstants.au3> #include <Date.au3> opt("TrayIconDebug",1) Global $Secs, $Mins, $Hour, $Time ;Create GUI GUICreate("Timer",120, 50) GUICtrlCreateLabel("00:00:00", 10,10) GUISetState() ;Start timer $timer = TimerInit() AdlibEnable("Timer", 50) ; While 1 ;FileWriteLine("debug.log",@min & ":" & @sec & " ==> before") $msg = GUIGetMsg() ;FileWriteLine("debug.log",@min & ":" & @sec & " ==> after") Select Case $msg = $GUI_EVENT_CLOSE Exit EndSelect Wend ; Func Timer() _TicksToTime(Int(TimerDiff($timer)), $Hour, $Mins, $Secs ) Local $sTime = $Time ; save current time to be able to test and avoid flicker.. $Time = StringFormat("%02i:%02i:%02i", $Hour, $Mins, $Secs) If $sTime <> $Time Then ControlSetText("Timer", "", "Static1", $Time) EndFunc ;==>Timer The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted October 2, 2006 Moderators Share Posted October 2, 2006 (edited) This was much simpler for me to understand and to make work for what I needed: That's only because you didn't see the UDF for _TicksToTime Edit: Example (Imagine _StrAddSub() being in the Date.au3 and not seeing the UDF):expandcollapse popup#include <GUIConstants.au3> opt("TrayIconDebug",1) ;Create GUI GUICreate("Timer",120, 50) GUICtrlCreateLabel("00:00:00", 10,10) GUISetState() Global $Time1 = _TimerStartDiff();Lock current time to start timer AdlibEnable("Timer", 100) ; While 1 ;FileWriteLine("debug.log",@min & ":" & @sec & " ==> before") $msg = GUIGetMsg() ;FileWriteLine("debug.log",@min & ":" & @sec & " ==> after") Select Case $msg = $GUI_EVENT_CLOSE Exit EndSelect Wend ; Func Timer() Local $Time = _StrAddSub($Time1, _TimerStartDiff(), 0) ControlSetText("Timer", "", "Static1", $Time) Return EndFunc ;==>Timer Func _TimerStartDiff() Return @HOUR & ':' & @MIN & ':' & @SEC EndFunc Func _StrAddSub($sTime1, $sTime2, $iAdd = 1, $sDelim = ':'); $iAdd = 1 Add, $iAdd = 0 Subtract Local $aSplit1 = StringSplit($sTime1, $sDelim), $iSubTotal = 0 Local $aSplit2 = StringSplit($sTime2, $sDelim) If $aSplit1[0] <> 3 Or $aSplit2[0] <> 3 Then Return SetError(0, 0, 0) Local $iTotal1 = ((Int($aSplit1[1]) * 3600) + (Int($aSplit1[2]) * 60) + (Int($aSplit1[3]))) Local $iTotal2 = ((Int($aSplit2[1]) * 3600) + (Int($aSplit2[2]) * 60) + (Int($aSplit2[3]))) If $iAdd Then $iSubTotal = $iTotal1 + $iTotal2 ElseIf $iTotal1 >= $iTotal2 Then $iSubTotal = $iTotal1 - $iTotal2 Else $iSubTotal = $iTotal2 - $iTotal1 EndIf Local $iHour = Int(($iSubTotal / 3600)) Local $iMin = Int(($iSubTotal - ($iHour * 3600)) / 60) Local $iSec = Int(($iSubTotal - $iHour * 3600) - ($iMin * 60)) Return StringFormat('%02d', $iHour) & $sDelim & StringFormat('%02d', $iMin) & $sDelim & StringFormat('%02d', $iSec) EndFunc Edit: Added _TimerStartDiff() so you could see what it was doing a bit better (I hope). Edited October 2, 2006 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Bert Posted October 3, 2006 Author Share Posted October 3, 2006 I get it now. I neede the whole thing to see how it worked. The Vollatran project My blog: http://www.vollysinterestingshit.com/ 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