Sign in to follow this  
Followers 0
tsue

chronometer, alarm clock

4 posts in this topic

hello im having trouble with my program, im tring to make a chronometer that displays sec min and hour to run once the first button is activated, and to be restarted everytime the button 1 is pressed, anothe issue is once im in a loop i cant exit it with the button 2 or clicking the x in the form

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=
$timer = 0
$Form1 = GUICreate("Form1", 194, 121, 461, 210)
$Button1 = GUICtrlCreateButton("Start", 16, 32, 75, 25, 0)
$OFF = GUICtrlCreateLabel("OFF", 80, 72, 24, 17)
$Button2 = GUICtrlCreateButton("Exit", 104, 32, 75, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Button1
            
            AdlibEnable("_beep", 289800) ; every 4:50 min start function _beep () 
            $OFF = GUICtrlCreateLabel($timer + 1, 80, 72, 24, 17)
                        $timer = $timer + 1
        Case $Button2
            Exit
    EndSwitch
WEnd


Func _beep ()    
        Beep(500,500)

EndFunc

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

There is something I wanna ask you

There is something that I want to know

And to this question you have the answer

So tell me what I want to know...

The other night I danced to that music. It was so hot!

A night to remember. ;)

edit:

I see Melba replied with some code (below me) but still here's more:

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=
$timer = 0
$Form1 = GUICreate("Form1", 194, 121, 461, 210)
$Button1 = GUICtrlCreateButton("Start", 16, 32, 75, 25, 0)
$OFF = GUICtrlCreateLabel("OFF", 80, 72, 24, 17)
$Button2 = GUICtrlCreateButton("Exit", 104, 32, 75, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

Global $hTimeLabel = GUICtrlCreateLabel("", 65, 72, 100, 20)
Global $hTimer
Global $iTime
Global $iSwitch

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $Button2
            Exit
        Case $Button1
            $hTimer = TimerInit()
            $iTime = 0
            GUICtrlSetData($hTimeLabel, StringFormat("%02i min %02i sec", 0, 0))
    EndSwitch

    If Mod(Floor(TimerDiff($hTimer) / (1000 / 2)), 2) Then
        If $iSwitch Then
            GUICtrlSetData($hTimeLabel, StringFormat("%02i min %02i sec", Floor($iTime / 60), Mod($iTime, 60)))
            $iTime += 1
            $iSwitch = 0
        EndIf
    Else
        If Not $iSwitch Then
            $iSwitch = 1
        EndIf
    EndIf

WEnd
Edited by trancexx

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

tsue.

Have an early Xmas present: ;)

#include <GUIConstants.au3>
#include <StaticConstants.au3>

$hAlarm = GUICreate("Form1", 194, 121, 461, 210)
$hStart_Button = GUICtrlCreateButton("Start", 16, 32, 75, 25, 0)
$hLabel = GUICtrlCreateLabel("OFF", 80, 72, 24, 17, $SS_CENTER)
$hExit_Button = GUICtrlCreateButton("Exit", 104, 32, 75, 25, 0)
GUISetState(@SW_SHOW)

$fRunning = False
$iCurrSec = 0
$iMin = 0
$iSec = 0

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $hExit_Button
            Exit
        Case $hStart_Button
            If $fRunning = False Then $fRunning = True
            GUICtrlSetData($hStart_Button, "Restart")
            $iBegin = TimerInit()
    EndSwitch

    If $fRunning Then
        $iDiff = Int(TimerDiff($iBegin) / 1000)
        $iMin = Int($iDiff / 60)
        $iSec = $iDiff - ($iMin * 60)
        If $iSec <> $iCurrSec Then
            GUICtrlSetData($hLabel, $iMin & ":" & StringFormat("%02i", $iSec))
            $iCurrSec = $iSec
        EndIf
    EndIf

    If $iMin = 5 And $iSec = 50 Then
        Beep(500, 500)
        $fRunning = False
        GUICtrlSetData($hStart_Button, "Start")
        GUICtrlSetData($hLabel, "OFF")
    EndIf

WEnd

But no comments - so you have to work out how it functions! :evil:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Days ago I had to run some benchmarks to determine the best way to code a specific task in one of my scripts.

The only problem my script starts and stops several processes, and I want to know exaclaty the duration of one process.

So I take the "Xmas present" and I reworked it a little for start - stop the chronometer if a particolar process is started - stopped.

You can see the attached screenshoot

post-43241-12777277548698_thumb.jpg

and this is the code :

#include <GUIConstants.au3>
#include <StaticConstants.au3>

$hAlarm = GUICreate("Chrono Process", 194, 221, 461, 110)
$hStart_Button = GUICtrlCreateButton("Start", 16, 32, 75, 25, 0)
$hLabel = GUICtrlCreateLabel(" _OFF_ ", 80, 72, 34, 47, $SS_CENTER)
$hStop_Button = GUICtrlCreateButton("Stop", 104, 32, 75, 25, 0)
$hExit_Button = GUICtrlCreateButton("Exit", 60, 180, 75, 25, 0)

GUICtrlCreateLabel("Process to Monitor" & @CRLF, 5, 110, 180, 18)
GUICtrlSetBkColor(-1, 0x0FFF0)
$processo = GUICtrlCreateInput("", 5, 130, 180, 20)
GUISetState(@SW_SHOW)

$fRunning = False
$iCurrSec = 0
$iMin = 0
$iSec = 0

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $hExit_Button
            Exit
        Case $hStart_Button
            If $fRunning = False Then $fRunning = True
            GUICtrlSetData($hStart_Button, "ReStart")
            $iBegin = TimerInit()
        Case $hStop_Button
            If $fRunning = True Then $fRunning = False
            GUICtrlSetData($hStart_Button, "Start")

    EndSwitch

    If $fRunning Then
        $iDiff = Int(TimerDiff($iBegin) / 1000)
        $iMin = Int($iDiff / 60)
        $iSec = $iDiff - ($iMin * 60)
        If $iSec <> $iCurrSec Then
            GUICtrlSetData($hLabel, $iMin & ":" & StringFormat("%02i", $iSec))
            $iCurrSec = $iSec
        EndIf
    EndIf

    $procctrl = GUICtrlRead($processo)
    If $procctrl <> "" Then
        If ProcessExists($procctrl) and $fRunning = False Then
            $fRunning = True
            GUICtrlSetData($hStart_Button, "ReStart")
            $iBegin = TimerInit()
        EndIf
        If Not ProcessExists($procctrl) and $fRunning = True Then
            $fRunning = False
            GUICtrlSetData($hStart_Button, "Start")
        EndIf
    EndIf

    Sleep(10)
WEnd

Other ideas are multi process monitoring and database (sqllite ) timings records.

Greetz.

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