Lord Zion Posted December 8, 2005 Posted December 8, 2005 Hi guys, Im trying to make a simple GUI timer, where you can insert the number of seconds and at the end of the countdown it plays a sound. Ive searched the forums and found a lot of examples using timediff and timeinit and a few not using them. Thats how i built the code, but im missing something... Can you help me out plz ? expandcollapse popupDim $timer #include <GUIConstants.au3> GUICreate("", 180, 120) GUISetState(@SW_SHOW) ;####################################################################### GUICtrlCreateLabel("Timer", 10, 15, 40) $timer = GUICtrlCreateInput("", 45, 10, 40, 20, $ES_NUMBER) GUICtrlCreateLabel("seconds", 90, 15, 90) ;####################################################################### $ok = GUICtrlCreateButton("Ok", 40, 50, 60, 20) While 1 $event = GUIGetMsg() Select Case $event = $ok $t = Int(GUICtrlRead($timer)) ExitLoop Case $event = $GUI_EVENT_CLOSE Exit ExitLoop EndSelect WEnd GUIDelete() While 1 Sleep(50) WEnd Func timer() While 1 Sleep($t * 1000) If $t = 0 Then SoundPlay("C:\Windows\media\tada.wav") EndIf WEnd EndFunc Thx again guys !
poisonkiller Posted December 8, 2005 Posted December 8, 2005 I tested 5 min and changed a lot of your code: #include <GUIConstants.au3> GUICreate("", 180, 120) ;####################################################################### GUICtrlCreateLabel("Timer", 10, 15, 40) $timer = GUICtrlCreateInput("", 45, 10, 40, 20, $ES_NUMBER) GUICtrlCreateLabel("seconds", 90, 15, 90) ;####################################################################### $ok = GUICtrlCreateButton("Ok", 40, 50, 60, 20) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $ok Do $time = GUICtrlRead($timer) - 1 Sleep(1000) GUICtrlSetData($timer, $time) Until $time = 0 SoundPlay("C:\Windows\media\tada.wav") Case $msg = $GUI_EVENT_CLOSE Exit ExitLoop EndSelect WEnd This works on me.
Lord Zion Posted December 8, 2005 Author Posted December 8, 2005 Thx a lot man, that answer my question very nicely !
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