Sign in to follow this  
Followers 0
Bert

time stamp written to a INI file

7 posts in this topic

I'm trying to figure out how to write a time stamp to a INI file. I'm looking to build a GUI with the ability to have about 20 timers in it. The catch is, I do not wish to use sleep statements to make each timer work. I would like it to work like this.

1. A GUI with a input field to track what they wish to time, like a ticket number.

2. To the right a start button to begin the timer

3. Farther to the right a button to reset the timer.

This layout would be so that one could track 20 different things at once. (20 input fields, 20 start, 20 stop)

When the person presses start, a timestamp is taken, and that is written to a key in a INI file. The GUI will check every second (using only one sleep statement to check all the timers) until a certain amount of time has passes, and a mgsbox will popup for the user.

The only trouble I'm having is how do I get the timestamp in the INI file. Any help would be welcomed.

Share this post


Link to post
Share on other sites



sounds similar to another persons script that we helped with a while back with multpile timers


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

#include <GUIConstants.au3>
#include <Date.au3>

Dim $Header_1 = "Computer"
Dim $Header_2 = "Phone"
Dim $Header_3 = "Office"
Dim $Name, $TotalTime, $Unit, $count
Dim $TimerActive_[50], $Label_[50], $TButton_[50], $SButton_[50], $Input_[50], $Label_[50]
Dim $Time_[50], $Timer_[50], $sTime_[50], $xk, $ck, $tk, $pk, $Left = 0, $Top = 20, $X, $Radx, $Rad_[11]

$Today_File = @MON & "-" & @MDAY & "-" & @YEAR & ".txt"
$Log = FileOpen($Today_File, 1)
FileWriteLine($Log, "Logfile started: " & _DateTimeFormat( _NowCalc(), 0) & @CRLF & @CRLF)
FileClose($Log)

$Toy_Logo = @TempDir & "\Toy2-logo.jpg"
FileInstall("C:\XPClean-web\Settings\XPClean-pics\Toy-box2-jpg.jpg", $Toy_Logo)
$Toy_Banner = @TempDir & "\Toy-banr.jpg"
FileInstall("C:\XPClean-web\Settings\XPClean-pics\Toy-box-jpg.jpg", $Toy_Banner)
$Logo_icon = @TempDir & "\Toy-Icon.ico"
FileInstall("C:\XPClean-web\Settings\XPClean-pics\Toy-box-Icon.ico", $Logo_icon)

Setup()

AdlibEnable("AllTimers", 500)

GUICreate("   Toy BOX  -  Multi-Station-Timer", (110 * $pk), 470)
GUISetIcon($Logo_icon)


;Top computer label
GUICtrlCreateLabel($Header_1 & "s", 0, 0, (110 * $pk), 20, $SS_CENTER, $WS_EX_STATICEDGE)
GUICtrlSetFont(-1, 12, 700)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x876B53)

;Middle phones label
GUICtrlCreateLabel($Header_2 & "s", 0, 220, (110 * $pk), 20, $SS_CENTER, $WS_EX_STATICEDGE)
GUICtrlSetFont(-1, 12, 700)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x876B53)

;Bottom PC label
GUICtrlCreateLabel($Header_3 & "s", 0, 340, (110 * $pk), 20, $SS_CENTER, $WS_EX_STATICEDGE)
GUICtrlSetFont(-1, 12, 700)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x876B53)

For $X = 1 To $pk
; row 1
    GUICtrlCreateLabel($Header_1 & " " & $X, $Left, $Top, 100, 20, $SS_CENTER)
    $Label_[$X] = GUICtrlCreateLabel("", $Left, $Top + 20, 100, 30, 0x1000)
    GUICtrlSetFont($Label_[$X], 16)
    GUICtrlSetData($Label_[$X], "00:00:00")
    $TButton_[$X] = GUICtrlCreateButton("Start", $Left, $Top + 50, 50, 20)
    $SButton_[$X] = GUICtrlCreateButton("Stop", $Left + 50, $Top + 50, 50, 20)
    $Input_[$X] = GUICtrlCreateInput("", $Left, $Top + 70, 100, 20, 0x1000)
;MsgBox(0,$pk, $Radx & @CRLF & $count)
; row 2
    GUICtrlCreateLabel($Header_1 & " " & ($X + (($count + 1) * .25)), $Left, $Top + 100, 100, 20, $SS_CENTER)
    $Label_[ ($X + (($count + 1) * .25)) ] = GUICtrlCreateLabel("", $Left, $Top + 120, 100, 30, 0x1000)
    GUICtrlSetFont($Label_[ ($X + (($count + 1) * .25)) ], 16)
    GUICtrlSetData($Label_[ ($X + (($count + 1) * .25)) ], "00:00:00")
    $TButton_[ ($X + (($count + 1) * .25)) ] = GUICtrlCreateButton("Start", $Left, $Top + 150, 50, 20)
    $SButton_[ ($X + (($count + 1) * .25)) ] = GUICtrlCreateButton("Stop", $Left + 50, $Top + 150, 50, 20)
    $Input_[ ($X + (($count + 1) * .25)) ] = GUICtrlCreateInput("", $Left, $Top + 170, 100, 20, 0x1000)
    
; row 3
    GUICtrlCreateLabel($Header_2 & " " & $X, $Left, $Top + 220, 100, 20, $SS_CENTER)
    $Label_[ ($X + (($count + 1) * .5)) ] = GUICtrlCreateLabel("", $Left, $Top + 240, 100, 30, 0x1000)
    GUICtrlSetFont($Label_[ ($X + (($count + 1) * .5)) ], 16)
    GUICtrlSetData($Label_[ ($X + (($count + 1) * .5)) ], "00:00:00")
    $TButton_[ ($X + (($count + 1) * .5)) ] = GUICtrlCreateButton("Start", $Left, $Top + 270, 50, 20)
    $SButton_[ ($X + (($count + 1) * .5)) ] = GUICtrlCreateButton("Stop", $Left + 50, $Top + 270, 50, 20)
    $Input_[ ($X + (($count + 1) * .5)) ] = GUICtrlCreateInput("", $Left, $Top + 290, 100, 20, 0x1000)
    
; row 4
    
    If ($X + (($count + 1) * .75)) = ($count + 1) Then
        $Icon_1 = GUICtrlCreatePic($Toy_Banner, $Left, $Top + 360, 100, 50)
        GUICtrlSetState(-1, $GUI_DISABLE)
        ExitLoop
    EndIf
    GUICtrlCreateLabel($Header_3 & " " & $X, $Left, $Top + 340, 100, 20, $SS_CENTER)
    $Label_[ ($X + (($count + 1) * .75)) ] = GUICtrlCreateLabel("", $Left, $Top + 360, 100, 30, 0x1000)
    GUICtrlSetFont($Label_[ ($X + (($count + 1) * .75)) ], 16)
    GUICtrlSetData($Label_[ ($X + (($count + 1) * .75)) ], "00:00:00")
    $TButton_[ ($X + (($count + 1) * .75)) ] = GUICtrlCreateButton("Start", $Left, $Top + 390, 50, 20)
    $SButton_[ ($X + (($count + 1) * .75)) ] = GUICtrlCreateButton("Stop", $Left + 50, $Top + 390, 50, 20)
    $Input_[ ($X + (($count + 1) * .75)) ] = GUICtrlCreateInput("", $Left, $Top + 410, 100, 20, 0x1000)
    
    $Left = $Left + 110
Next

GUISetState()

While 1
    $msg = GUIGetMsg()
    
    For $xk = 1 To $count
        If $msg = $TButton_[$xk] And GUICtrlRead($Input_[$xk]) > "" Then
            GUICtrlSetState($TButton_[$xk], $GUI_DISABLE)
            GUICtrlSetState($Input_[$xk], $GUI_DISABLE)
            $TimerActive_[$xk] = 1
            $Timer_[$xk] = TimerInit()
        ElseIf $msg = $TButton_[$xk] Then
            MsgBox(64, "User Error:  " & $xk, "Please Type in a User Name   ", 3)
        EndIf
        If $msg = $SButton_[$xk] And GUICtrlRead($SButton_[$xk]) = "Reset" Then
            GUICtrlSetData($Label_[$xk], "00:00:00")
            GUICtrlSetData($Input_[$xk], "")
            GUICtrlSetData($SButton_[$xk], "Stop")
            GUICtrlSetState($TButton_[$xk], $GUI_ENABLE)
            GUICtrlSetState($Input_[$xk], $GUI_ENABLE)
        EndIf
        If $msg = $SButton_[$xk] And GUICtrlRead($Input_[$xk]) > "" And GUICtrlRead($SButton_[$xk]) = "Stop" Then
            $TimerActive_[$xk] = 0
            GUICtrlSetData($SButton_[$xk], "Reset")
            
        ;
            GUICtrlSetColor($Label_[$xk], 0x000000)
            $Name = GUICtrlRead($Input_[$xk])
        ;
            If $xk <= (($count + 1) * .5) Then
                $Unit = $Header_1 & "  " & $xk
            EndIf
            If $xk > (($count + 1) * .5) And $xk <= (($count + 1) * .75) Then
                $Unit = $Header_2 & "   " & ($xk - (($count + 1) * .5))
            EndIf
            If $xk > (($count + 1) * .75) Then
                $Unit = $Header_3 & "   " & ($xk - (($count + 1) * .75))
            EndIf
            RecordStuff()
        EndIf
    Next
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd

Func AllTimers()
    Local $Secs, $Mins, $Hour
    For $ck = 1 To $count
        
        If $TimerActive_[$ck] Then
            _TicksToTime(Int(TimerDiff($Timer_[$ck])), $Hour, $Mins, $Secs)
            $Time_[$ck] = StringFormat("%02i:%02i:%02i", $Hour, $Mins, $Secs)
            If $sTime_[$ck] <> $Time_[$ck] Then GUICtrlSetData($Label_[$ck], $Time_[$ck])
            If $Mins > 29 Then GUICtrlSetColor($Label_[$ck], 0xff0000)
        EndIf
    Next
EndFunc  ;==>AllTimers

Func RecordStuff()
    $LogStuff = FileOpen($Today_File, 1)
    FileWriteLine($LogStuff, "Station: " & $Unit & @CRLF)
    FileWriteLine($LogStuff, "User name: " & (GUICtrlRead($Input_[$xk])) & @CRLF)
    FileWriteLine($LogStuff, "Total time: " & (GUICtrlRead($Label_[$xk])) & @CRLF & @CRLF)
    FileClose($LogStuff)
    
EndFunc  ;==>RecordStuff

Func Setup()
    $Set_win = GUICreate("   Toy BOX  -  Multi-Station-Timer", 350, 310)
    GUISetIcon($Logo_icon)
    $Icon_1 = GUICtrlCreatePic($Toy_Logo, 240, 10, 100, 250)
    GUICtrlSetState(-1, $GUI_DISABLE)
    GUICtrlCreateGroup("3 Group Names", 10, 10, 220, 135)
    $Head_1 = GUICtrlCreateInput($Header_1, 30, 40, 150, 20)
    $Head_2 = GUICtrlCreateInput($Header_2, 30, 75, 150, 20)
    $Head_3 = GUICtrlCreateInput($Header_3, 30, 110, 150, 20)
    GUICtrlCreateGroup("Number of Timers", 10, 155, 220, 150)
    $Note = GUICtrlCreateLabel("19 Total Timers", 30, 175, 150, 20, $SS_SUNKEN + $SS_CENTER)
    $Rad_[1] = GUICtrlCreateRadio("3", 40, 200, 30, 20)
    $Rad_[2] = GUICtrlCreateRadio("7", 40, 220, 30, 20)
    $Rad_[3] = GUICtrlCreateRadio("11", 40, 240, 30, 20)
    $Rad_[4] = GUICtrlCreateRadio("15", 40, 260, 30, 20)
    $Rad_[5] = GUICtrlCreateRadio("19", 40, 280, 30, 20)
    GUICtrlSetState(-1, $GUI_CHECKED)
    $Rad_[6] = GUICtrlCreateRadio("23", 140, 200, 30, 20)
    $Rad_[7] = GUICtrlCreateRadio("27", 140, 220, 30, 20)
    $Rad_[8] = GUICtrlCreateRadio("31", 140, 240, 30, 20)
    $Rad_[9] = GUICtrlCreateRadio("35", 140, 260, 30, 20)
    $Rad_[10] = GUICtrlCreateRadio("39", 140, 280, 30, 20)
    $Create = GUICtrlCreateButton("Create", 250, 270, 80, 30)
    
    GUISetState()
    
    While 1
        $msg2 = GUIGetMsg()
        If $msg2 = $Create Then
            $Header_1 = GUICtrlRead($Head_1)
            $Header_2 = GUICtrlRead($Head_2)
            $Header_3 = GUICtrlRead($Head_3)
            For $tk = 1 To 10
                If GUICtrlRead($Rad_[$tk]) = $GUI_CHECKED Then
                    $pk = $tk
                    $Radx = $tk * 2
                    $count = (($tk * 4) - 1)
                    ExitLoop
                EndIf
            Next
            ExitLoop
        EndIf
        For $t = 1 To 10
            If GUICtrlRead($Rad_[$t]) = $GUI_CHECKED Then
                GUICtrlSetData( $Note, (($t * 4) - 1) & " Total Timers")
                ExitLoop
            EndIf
        Next
        If $msg2 = $GUI_EVENT_CLOSE Then ExitLoop
        Sleep(70)
    WEnd
    
    GUIDelete($Set_win)
EndFunc  ;==>Setup

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Nice Program, but it is somewhat above my skill level. It is close to what I want, but it has some things I rather not have, and I like to keep it simple.

How would one simply get a time stamp sent to a key in a INI file? I still rather take this approach, fo I will have this script working with a larger program that uses a INI.

Share this post


Link to post
Share on other sites

I used what all of you showed me and came up with this:

#include <GUIConstants.au3>
#include <Date.au3>
AutoItSetOption ("TrayIconDebug", 1)

Dim $Header_1 = "Ticket"
Dim $Name, $TotalTime, $Unit, $count = 20 
Dim $TimerActive_[50], $Label_[50], $TButton_[50], $SButton_[50], $Input_[50], $Label_[50]
Dim $Time_[50], $Timer_[50], $sTime_[50], $xk, $ck, $Left = 0, $Top = 20, $X

AdlibEnable("AllTimers", 500)

GUICreate("   T(egg) Timer", 540, 475)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlSetCursor(-1, 0)

;label
GUICtrlCreateLabel($Header_1 & "s", 0, 0, 540, 20, $SS_CENTER, $WS_EX_STATICEDGE)
GUICtrlSetFont(-1, 12, 700)
;GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x00ff00)
GUICtrlCreateLabel("This tool is NOT to be used for tracking of LOS or warning of SLA.", 205, 430, 130,40,$SS_CENTER)

For $X = 1 To 5
; row 1
    GUICtrlCreateLabel($Header_1 & " " & $X, $Left, $Top, 100, 20, $SS_CENTER)
    $Label_[$X] = GUICtrlCreateLabel("", $Left, $Top + 20, 100, 30, 0x1000)
    GUICtrlSetFont($Label_[$X], 16)
    GUICtrlSetData($Label_[$X], "00:00:00")
    $TButton_[$X] = GUICtrlCreateButton("Start", $Left, $Top + 50, 50, 20)
    $SButton_[$X] = GUICtrlCreateButton("Stop", $Left + 50, $Top + 50, 50, 20)
    $Input_[$X] = GUICtrlCreateInput("", $Left, $Top + 70, 100, 20, 0x1000)
    
; row 2
    GUICtrlCreateLabel($Header_1 & " " & $X + 5, $Left, $Top + 100, 100, 20, $SS_CENTER)
    $Label_[$X + 5] = GUICtrlCreateLabel("", $Left, $Top + 120, 100, 30, 0x1000)
    GUICtrlSetFont($Label_[$X + 5], 16)
    GUICtrlSetData($Label_[$X + 5], "00:00:00")
    $TButton_[$X + 5] = GUICtrlCreateButton("Start", $Left, $Top + 150, 50, 20)
    $SButton_[$X + 5] = GUICtrlCreateButton("Stop", $Left + 50, $Top + 150, 50, 20)
    $Input_[$X + 5] = GUICtrlCreateInput("", $Left, $Top + 170, 100, 20, 0x1000)
    
; row 3
    GUICtrlCreateLabel($Header_1 & " " & $X + 10, $Left, $Top + 200, 100, 20, $SS_CENTER)
    $Label_[$X + 10] = GUICtrlCreateLabel("", $Left, $Top + 220, 100, 30, 0x1000)
    GUICtrlSetFont($Label_[$X + 10], 16)
    GUICtrlSetData($Label_[$X + 10], "00:00:00")
    $TButton_[$X + 10] = GUICtrlCreateButton("Start", $Left, $Top + 250, 50, 20)
    $SButton_[$X + 10] = GUICtrlCreateButton("Stop", $Left + 50, $Top + 250, 50, 20)
    $Input_[$X + 10] = GUICtrlCreateInput("", $Left, $Top + 270, 100, 20, 0x1000)
    
; row 4
    GUICtrlCreateLabel($Header_1 & " " & $X + 15, $Left, $Top + 300, 100, 20, $SS_CENTER)
    $Label_[$X + 15] = GUICtrlCreateLabel("", $Left, $Top + 320, 100, 30, 0x1000)
    GUICtrlSetFont($Label_[$X + 15], 16)
    GUICtrlSetData($Label_[$X + 15], "00:00:00")
    $TButton_[$X + 15] = GUICtrlCreateButton("Start", $Left, $Top + 350, 50, 20)
    $SButton_[$X + 15] = GUICtrlCreateButton("Stop", $Left + 50, $Top + 350, 50, 20)
    $Input_[$X + 15] = GUICtrlCreateInput("", $Left, $Top + 370, 100, 20, 0x1000)
    
    $Left = $Left + 110
Next

GUISetState()

While 1
    $msg = GUIGetMsg()
    
    For $xk = 1 To $count
        If $msg = $TButton_[$xk] And GUICtrlRead($Input_[$xk]) > "" Then
            GUICtrlSetState($TButton_[$xk], $GUI_DISABLE)
            GUICtrlSetState($Input_[$xk], $GUI_DISABLE)
            $TimerActive_[$xk] = 1
            $Timer_[$xk] = TimerInit()
        ElseIf $msg = $TButton_[$xk] Then
            MsgBox(64, "User Error", "Please Type in a Ticket Number   ", 3)
        EndIf
        If $msg = $SButton_[$xk] And GUICtrlRead($SButton_[$xk]) = "Reset" Then
            GUICtrlSetData($Label_[$xk], "00:00:00")
            GUICtrlSetData($Input_[$xk], "")
            GUICtrlSetData($SButton_[$xk], "Stop")
        EndIf
        If $msg = $SButton_[$xk] And GUICtrlRead($Input_[$xk]) > "" And GUICtrlRead($SButton_[$xk]) = "Stop" Then
            $TimerActive_[$xk] = 0
            GUICtrlSetData($SButton_[$xk], "Reset")
            GUICtrlSetState($TButton_[$xk], $GUI_ENABLE)
            GUICtrlSetState($Input_[$xk], $GUI_ENABLE)
       ;
            GUICtrlSetColor($Label_[$xk], 0x000000)
            $Name = GUICtrlRead($Input_[$xk])
       ;
            If $xk < 20 Then
                $Unit = $Header_1 & "  " & $xk
            EndIf

        EndIf
        
        If $xk = 20 Then ExitLoop    
    Next
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd

Func AllTimers()
    Local $Secs, $Mins, $Hour
    For $ck = 1 To $count
        
        If $TimerActive_[$ck] Then
            _TicksToTime(Int(TimerDiff($Timer_[$ck])), $Hour, $Mins, $Secs)
            $Time_[$ck] = StringFormat("%02i:%02i:%02i", $Hour, $Mins, $Secs)
            If $sTime_[$ck] <> $Time_[$ck] Then GUICtrlSetData($Label_[$ck], $Time_[$ck])
            If $Mins > 1 Then GUICtrlSetColor($Label_[$ck], 0xff0000)
        EndIf
    Next
EndFunc ;==>AllTimers

I still need to do some work, but it looks promising. THANKS! :P

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0