tsue Posted December 24, 2009 Share Posted December 24, 2009 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 Link to comment Share on other sites More sharing options...
trancexx Posted December 24, 2009 Share Posted December 24, 2009 (edited) There is something I wanna ask youThere is something that I want to knowAnd to this question you have the answerSo 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:expandcollapse popup#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 December 24, 2009 by trancexx ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 24, 2009 Moderators Share Posted December 24, 2009 tsue. Have an early Xmas present: expandcollapse popup#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! M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
t0nZ Posted June 28, 2010 Share Posted June 28, 2010 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 and this is the code : expandcollapse popup#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. 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