Jump to content

Recommended Posts

Posted

ok, I have here a timer script that I've written

CODE
ProgressOn("Progress", "Executing Code RED", "", 974, 862, 16)

Sleep(2*1000)

$Second = 0

$Min = 0

$Hour = 0

$Pro = 0

Do

ProgressSet($Pro , "", "Count is: "& $Hour &" Hours " & $min &" Mins " & $Second &" Secs")

GuiCtrlCreateProgress(60, 80, 150, 20)

If $Second = 59 Then $Second = -1

If $Second = -1 Then $Min = $Min + 1

If $Min = 60 Then $Min = -1

If $Min = -1 Then $Hour = $Hour + 1

If $Min = -1 Then $Min = $Min + 1

$Second = $Second + 1

$Pro = $Pro + 0.007

Sleep(991) ;timer runs faster the lower the number - closer to 1000 means the slower the count

Until Not ProcessExists("Clean Up.exe")

$file = FileOpen("Timer Length.log", 2)

FileWriteLine($file, "Time: " & $hour & " " & $min & " " & $Second)

FileClose($file)

now as you can see it will keep counting until the script known as cleanup.exe finishes it's work, this often takes around 3 hours

when it finishes it writes the time taken to timer length.log, now what I wanted to do was when next timer is run, it takes the numbers in the log as a starting point and begins to count down from them, so I can put "likely time remaining" in front of it, does anyone know of a script that let's you enter in a certain hour or mins then will count down from them?

Posted

Try with TimerInit()

Look it up in the help file, but I'll give you a smal example anyway

$Timer = TimerInit()

$Time = 5000 ;in miliseconds

While 1

If TimerDiff($Timer) > $Time Then MsgBox(0,"Timer!","End of timer!")

Wend

Not tested, but you get the idea

[center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center]

Posted

...keep counting until the script known as cleanup.exe finishes it's work, this often takes around 3 hours

when it finishes it writes the time taken to timer length.log, now what I wanted to do was when next timer is run, it takes the numbers in the log as a starting point and begins to count down from them, so I can put "likely time remaining" in front of it, does anyone know of a script that let's you enter in a certain hour or mins then will count down from them?

Use TimerInit() and TimerDiff() to get your times in ticks (milliseconds), and use the _TicksToTime() and _TimeToTicks() functions to convert H:M:S for easy save/retrieve in your file:
#include <GuiConstants.au3>
#include <StaticConstants.au3>
#include <Date.au3>

Global $fUpDown = False
Global $fRun = False
Global $iTimer = 0, $iTimerSav = 0

Global $hGUI = GUICreate("Test", 300, 240)
Global $ctrlLabel1 = GUICtrlCreateLabel("Time in ticks = N/A", 20, 20, 260, 20, $SS_CENTER)
Global $ctrlLabel2 = GUICtrlCreateLabel("Time = N/A", 20, 60, 260, 20, $SS_CENTER)
Global $ctrlLabel3 = GUICtrlCreateLabel("Counting mode:  N/A", 20, 100, 260, 20, $SS_CENTER)
Global $ctrlButtonstart = GUICtrlCreateButton("Start", 100, 140, 100, 30)
Global $CtrlButtonstop = GUICtrlCreateButton("Stop", 100, 190, 100, 30)
GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $ctrlButtonstart
            If $fRun Then ContinueLoop ; Already running
            $fUpDown = Not $fUpDown ; Toggle up/down
            If $fUpDown Then
                ControlSetText($hGUI, "", $ctrlLabel3, "Counting mode:  UP")
            Else
                ControlSetText($hGUI, "", $ctrlLabel3, "Counting mode:  DOWN")
            EndIf
            $fRun = True ; Set run flag
            $iTimer = TimerInit() ; init timer
        Case $CtrlButtonstop
            $fRun = False
            $iTimerSav = TimerDiff($iTimer) ; If counting up save timer
    EndSwitch
    If $fRun Then _Update()
WEnd

Func _Update()
    Local $iTimerDiff = TimerDiff($iTimer)
    If Not $fUpDown Then $iTimerDiff = $iTimerSav - $iTimerDiff ; Counting down
    Local $iTimerH, $iTimerM, $iTimerS, $sTimerSign = ""
    If $iTimerDiff < 0 Then $sTimerSign = "- "
    _TicksToTime(Abs($iTimerDiff), $iTimerH, $iTimerM, $iTimerS)
    ControlSetText($hGUI, "", $ctrlLabel1, "Time in ticks = " & $iTimerDiff)
    ControlSetText($hGUI, "", $ctrlLabel2, "Time  = " & $sTimerSign & $iTimerH  & ":" & $iTimerM & ":" & $iTimerS)
EndFunc   ;==>_Update

Cheers!

:D

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...