Jump to content

Search the Community

Showing results for tags 'timediff'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 1 result

  1. I am working on a larger script that will use some of the functions in the script below. In theory, it should work like a dream... but it isn't. run this, and what should happen is you get a label showing when the count started, along with a simple label that shows how long the count has been running, however after 60 seconds, the count just goes back to zero seconds and the minutes don't increment. I know I'm missing the obvious but I think I'm too tired to see it. If someone has a moment, give this a shot and let me know if you see where I messed up.. Let it run for over a minute to see what happens. #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Date.au3> $MuhGui = GUICreate("MuhTimer", 457, 182, 192, 124) $Start = GUICtrlCreateButton("Start", 16, 128, 75, 25) $Stop = GUICtrlCreateButton("Stop", 104, 128, 75, 25) $Reset = GUICtrlCreateButton("Reset", 192, 128, 75, 25) $timeStarted = GUICtrlCreateLabel("", 32, 16, 199, 17) $elapsedTime = GUICtrlCreateLabel(" ", 16, 56, 199, 41) Global $checkVar, $changedVar GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") _TimerInit() GUISetState(@SW_SHOW) $mode = 0 While 1 $checkVar = _TimerRunningDiff(0, $mode) If $checkVar <> $changedVar Then GUICtrlSetData($elapsedTime, _TimerRunningDiff(0, $mode)) $changedVar = $checkVar EndIf $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Start $Junkval = _TimerStart() GUICtrlSetData($timeStarted, "Timer started: " & $Junkval) Case $Stop _TimerStop() $JunkVal2 = _TimerDiff(0, 3) GUICtrlSetData($elapsedTime, $JunkVal2) Case $Reset MsgBox(0, "Debug", _TimerRunningDiff(0, 3)) ;$Junkval = 0 ;$Junkval2 = 0 ;_TimerStop() ;GUICtrlSetData($elapsedTime, "") ;GUICtrlSetData($timeStarted, "") EndSwitch WEnd Func _TimerStart($TimerID = 0) $TimeStart[$TimerID] = _NowCalc() Return $TimeStart[$TimerID] EndFunc ;==>_TimerStart Func _TimerStop($TimerID = 0) $TimeStop[$TimerID] = _NowCalc() Return _NowCalc() EndFunc ;==>_TimerStop Func _TimerInit() Global $TimeStart[1000] Global $TimeStartMsecs[1000] Global $TimeStop[1000] EndFunc ;==>_TimerInit Func _TimerDiff($TimerID = 0, $Style = 0) $Days = _DateDiff("D", $TimeStart[$TimerID], $TimeStop[$TimerID]) $TimeStart[$TimerID] = _DateAdd("D", $Days, $TimeStart[$TimerID]) $Hours = _DateDiff("h", $TimeStart[$TimerID], $TimeStop[$TimerID]) $TimeStart[$TimerID] = _DateAdd("h", $Hours, $TimeStart[$TimerID]) $Minutes = _DateDiff("n", $TimeStart[$TimerID], $TimeStop[$TimerID]) $TimeStart[$TimerID] = _DateAdd("n", $Minutes, $TimeStart[$TimerID]) $Seconds = _DateDiff("s", $TimeStart[$TimerID], $TimeStop[$TimerID]) Switch $Style Case 0 ; one line Return "Days: " & $Days & " " & "Hours: " & $Hours & " " & "Minutes: " & $Minutes & " " & "Seconds: " & $Seconds Case 1 ; Array Local $Rezult = [$Days, $Hours, $Minutes, $Seconds] Return $Rezult Case 2 ; one line small Return $Days & " days, " & $Hours & ":" & $Minutes & ":" & $Seconds Case 3 ; one line description gors as time increases $time = "" If $Days <> 0 Then $time &= "Days: " & $Days & " " If $Hours <> 0 Then $time &= "Hours: " & $Hours & " " If $Minutes <> 0 Then $time &= "Minutes: " & $Minutes & " " If $Seconds <> 0 Then $time &= "Seconds: " & $Seconds & " " Return $time EndSwitch EndFunc ;==>_TimerDiff Func _TimerRunningDiff($TimerID = 0, $Style = 0) $Days = _DateDiff("D", $TimeStart[$TimerID], _NowCalc()) $TimeStart[$TimerID] = _DateAdd("D", $Days, $TimeStart[$TimerID]) $Hours = _DateDiff("h", $TimeStart[$TimerID], _NowCalc()) $TimeStart[$TimerID] = _DateAdd("h", $Hours, $TimeStart[$TimerID]) $Minutes = _DateDiff("n", $TimeStart[$TimerID], _NowCalc()) $TimeStart[$TimerID] = _DateAdd("n", $Minutes, $TimeStart[$TimerID]) $Seconds = _DateDiff("s", $TimeStart[$TimerID], _NowCalc()) Switch $Style Case 0 ; one line Return "Days: " & $Days & " " & "Hours: " & $Hours & " " & "Minutes: " & $Minutes & " " & "Seconds: " & $Seconds Case 1 ; Array Local $Rezult = [$Days, $Hours, $Minutes, $Seconds] Return $Rezult Case 2 ; one line small Return $Days & " days, " & $Hours & ":" & $Minutes & ":" & $Seconds Case 3 ; one line description gors as time increases $time = "" If $Days <> 0 Then $time &= "Days: " & $Days & " " If $Hours <> 0 Then $time &= "Hours: " & $Hours & " " If $Minutes <> 0 Then $time &= "Minutes: " & $Minutes & " " If $Seconds <> 0 Then $time &= "Seconds: " & $Seconds & " " Return $time EndSwitch EndFunc ;==>_TimerRunningDiff Thanks in advance!!
×
×
  • Create New...