Bert Posted December 22, 2005 Share Posted December 22, 2005 I've spent some time researching on how to do this, but I don't know what to use as a search, so I will try to describe what I need to do. I designed a timer that just has a start and stop. I need to do the following: -every hour on the hour while it is running, a msgbox pops up with a reminder. I'm not sure on how to make it know how each hour goes by and keep a count while doing it. here is the code: expandcollapse popup#include <GUIConstants.au3> #include <Date.au3> Dim $Timer1Active = 0 Dim $Timer2Active = 0 AdlibEnable("AllTimers1", 500) GUICreate("MyGUI", 120, 120) $Button_1 = GUICtrlCreateButton("Start", 10, 50, 50, 20) $Button_2 = GUICtrlCreateButton("Stop", 60, 50, 50, 20) $Label_4 = GUICtrlCreateLabel("00:00:00", 10, 10, 100, 30, 0x00800000 + 0x0001) GUICtrlSetBkColor($Label_4, 0xFF0000) GUICtrlSetFont($Label_4, 16) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $Button_1 $Timer1Active = 1 $timer1 = TimerInit() GUICtrlSetBkColor($Label_4, 0x64C671) Case $msg = $Button_2 $Timer1Active = 0 GUICtrlSetData($Label_4, "00:00:00") GUICtrlSetBkColor($Label_4, 0xFF0000) Case $msg = $GUI_EVENT_CLOSE EndSelect If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd Func AllTimers1() Local $Secs, $Mins, $Hour, $Time1, $Time2, $sTime1 = $Time1, $sTime2 = $Time2 If $Timer1Active Then _TicksToTime(Int(TimerDiff($timer1)), $Hour, $Mins, $Secs) $Time1 = StringFormat("%02i:%02i:%02i", $Hour, $Mins, $Secs) If $sTime1 <> $Time1 Then ControlSetText("MyGUI", "", "Static1", $Time1) EndIf EndFunc ;==>AllTimers The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted December 22, 2005 Moderators Share Posted December 22, 2005 (edited) Dim $Timer = TimerInit() While 1 If TimerDiff($Timer) / 1000 / 60 / 60 >= 1 Then MsgBox(0, "Time", "Hour is up") $Timer = TimerInit() EndIf WEndEdit:I re-read your post, are you meaning the 'literal hour' - 12pm / 1pm / 2pm etc....?Edit2:If it is the above, maybe try something like:While 1 If $Hour - @HOUR = 0 And $Min - @MIN = 0 And $Sec - @Sec <= 10 Then Sleep($Sec - @SEC * 1000) ; do something and reset timer EndIf WEnd Edited December 22, 2005 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Bert Posted December 22, 2005 Author Share Posted December 22, 2005 I need it every 60 minutes from when the clock being started. The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted December 22, 2005 Moderators Share Posted December 22, 2005 Well either example does that vollyman. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
MrSpacely Posted December 22, 2005 Share Posted December 22, 2005 MsgBox(0, "Time", "Hour is up",10) make shure the box closes after a while otherwise the program will wait for user input (clicking ok button) Link to comment Share on other sites More sharing options...
seandisanti Posted December 22, 2005 Share Posted December 22, 2005 (edited) I've spent some time researching on how to do this, but I don't know what to use as a search, so I will try to describe what I need to do. I designed a timer that just has a start and stop. I need to do the following: -every hour on the hour while it is running, a msgbox pops up with a reminder. I'm not sure on how to make it know how each hour goes by and keep a count while doing it. here is the code: expandcollapse popup#include <GUIConstants.au3> #include <Date.au3> Dim $Timer1Active = 0 Dim $Timer2Active = 0 AdlibEnable("AllTimers1", 500) GUICreate("MyGUI", 120, 120) $Button_1 = GUICtrlCreateButton("Start", 10, 50, 50, 20) $Button_2 = GUICtrlCreateButton("Stop", 60, 50, 50, 20) $Label_4 = GUICtrlCreateLabel("00:00:00", 10, 10, 100, 30, 0x00800000 + 0x0001) GUICtrlSetBkColor($Label_4, 0xFF0000) GUICtrlSetFont($Label_4, 16) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $Button_1 $Timer1Active = 1 $timer1 = TimerInit() GUICtrlSetBkColor($Label_4, 0x64C671) Case $msg = $Button_2 $Timer1Active = 0 GUICtrlSetData($Label_4, "00:00:00") GUICtrlSetBkColor($Label_4, 0xFF0000) Case $msg = $GUI_EVENT_CLOSE EndSelect If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd Func AllTimers1() Local $Secs, $Mins, $Hour, $Time1, $Time2, $sTime1 = $Time1, $sTime2 = $Time2 If $Timer1Active Then _TicksToTime(Int(TimerDiff($timer1)), $Hour, $Mins, $Secs) $Time1 = StringFormat("%02i:%02i:%02i", $Hour, $Mins, $Secs) If $sTime1 <> $Time1 Then ControlSetText("MyGUI", "", "Static1", $Time1) EndIf EndFunc;==>AllTimersprobably the easiest way to do it, in my opinion, would be to create a variable that stores the old label text, then when the timer label is updated, compare the hour position. if it changes, display a message box. then you have your count, and your hourly message box. ***forgot english for a minute, fixed gramatical errors... screw capitalization.*** Edited December 22, 2005 by cameronsdad Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted December 22, 2005 Moderators Share Posted December 22, 2005 probably the easiest way to do it, in my opinion, would be to create a variable that stores the old label text, then when the timer label is updated, compare the hour position. if it changes, display a message box. then you have your count, and your hourly message box.***forgot english for a minute, fixed gramatical errors... screw capitalization.***Well I had never seen the _TicksToTime() UDF before this post (never paid much attention), and after about 20 seconds of reading it, It made perfect sense... In either case as you say, keeping the label updated is important if the program is going to run past the given hour.@Spacely - Yeh, I didn't put that in there as something to stay, I thought he would replace it with the code he wanted, I think it was a ControlSetText() command. I just didn't write it to fit his specific function, I thought he could at least do that with either example given to him. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Bert Posted December 22, 2005 Author Share Posted December 22, 2005 (edited) Well either example does that vollyman. I ran a 2 hour test, and the message only poped up on hour 1. $Label_4 = GUICtrlCreateLabel("00:00:00", 10, 10, 100, 30, 0x00800000 + 0x0001) GUICtrlSetBkColor($Label_4, 0xFF0000) GUICtrlSetFont($Label_4, 16) Dim $Timer = TimerInit() GUISetState() While 1 $msg = GUIGetMsg() If TimerDiff($Timer) / 1000 / 60 / 60 >= 1 Then MsgBox(0, "Reminder", "Check Voice", 10) $Timer = TimerInit() EndIf Select Case $msg = $Button_1 $Timer1Active = 1 $timer1 = TimerInit() GUICtrlSetBkColor($Label_4, 0x64C671) ;If TimerDiff($Timer) / 1000 / 60 / 60 >= 1 Then Case $msg = $Button_2 $Timer1Active = 0 GUICtrlSetData($Label_4, "00:00:00") GUICtrlSetBkColor($Label_4, 0xFF0000) Case $msg = $GUI_EVENT_CLOSE EndSelect If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd Func AllTimers1() Local $Secs, $Mins, $Hour, $Time1, $Time2, $sTime1 = $Time1, $sTime2 = $Time2 If $Timer1Active Then _TicksToTime(Int(TimerDiff($timer1)), $Hour, $Mins, $Secs) $Time1 = StringFormat("%02i:%02i:%02i", $Hour, $Mins, $Secs) If $sTime1 <> $Time1 Then ControlSetText("MyGUI", "", "Static1", $Time1) EndIf EndFunc ;==>AllTimers Edited December 22, 2005 by vollyman The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
Valuater Posted December 22, 2005 Share Posted December 22, 2005 (edited) maybe expandcollapse popup#include <GUIConstants.au3> #include <Date.au3> Dim $Timer1Active = 0 Dim $Timer2Active = 0 AdlibEnable("AllTimers1", 500) Dim $count = "01" GUICreate("MyGUI", 120, 120) $Button_1 = GUICtrlCreateButton("Start", 10, 50, 50, 20) $Button_2 = GUICtrlCreateButton("Stop", 60, 50, 50, 20) $Label_4 = GUICtrlCreateLabel("00:00:00", 10, 10, 100, 30, 0x00800000 + 0x0001) GUICtrlSetBkColor($Label_4, 0xFF0000) GUICtrlSetFont($Label_4, 16) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $Button_1 $Timer1Active = 1 $timer1 = TimerInit() GUICtrlSetBkColor($Label_4, 0x64C671) Case $msg = $Button_2 $Timer1Active = 0 GUICtrlSetData($Label_4, "00:00:00") GUICtrlSetBkColor($Label_4, 0xFF0000) Case $msg = $GUI_EVENT_CLOSE EndSelect If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd Func AllTimers1() Local $Secs, $Mins, $Hour, $Time1, $Time2, $sTime1 = $Time1, $sTime2 = $Time2 If $Timer1Active Then _TicksToTime(Int(TimerDiff($timer1)), $Hour, $Mins, $Secs) $Time1 = StringFormat("%02i:%02i:%02i", $Hour, $Mins, $Secs) If $sTime1 <> $Time1 Then ControlSetText("MyGUI", "", "Static1", $Time1) EndIf If StringLeft((GUICtrlRead($Label_4)), 2) = $count Then MsgBox(64, " Hour Message", " One Hour has Passed ", 10) $count = $count + "01" If $count < 10 then $count = "0" & $count EndIf EndFunc;==>AllTimers 8) Edited December 22, 2005 by Valuater Link to comment Share on other sites More sharing options...
Bert Posted December 22, 2005 Author Share Posted December 22, 2005 @Valuater: I think that is what I'm looking for. I'm testing it now. If I'm reading the code right, I should get a message box every hour the timer is running, and the msgbox will be displayed for 10 seconds. The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
Valuater Posted December 22, 2005 Share Posted December 22, 2005 (edited) yepper... 8) you could add this If StringLeft((GUICtrlRead($Label_4)), 2) = $count Then If $count = "01" Then MsgBox(64, " Hour Message", " One Hour has Passed ", 10) Else MsgBox(64, " Hour Message", $count & " Hours have Passed ", 10) EndIf $count = $count + "01" If $count < 10 then $count = "0" & $count EndIf this will give a "count" of how many hours have passed 8) Edited December 22, 2005 by Valuater Link to comment Share on other sites More sharing options...
Bert Posted December 22, 2005 Author Share Posted December 22, 2005 The message the client needed, believe it or not, is simply check the voice system they use for tickets. It has to be monitored by one person on the help desk, and the person changes from day to day. They asked me to write something that could be like a alarm clock that only did a popup every hour. I was going to put the code into a app I'm designing for them so it would be all in one program. Still, it is good code. Thank you! The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
Valuater Posted December 22, 2005 Share Posted December 22, 2005 (edited) Voice... did you say Voice... expandcollapse popup#include <GUIConstants.au3> #include <Date.au3> Dim $Timer1Active = 0 Dim $Timer2Active = 0 AdlibEnable("AllTimers1", 500) Dim $count = "01" GUICreate("MyGUI", 120, 120) $Button_1 = GUICtrlCreateButton("Start", 10, 50, 50, 20) $Button_2 = GUICtrlCreateButton("Stop", 60, 50, 50, 20) $Label_4 = GUICtrlCreateLabel("00:00:00", 10, 10, 100, 30, 0x00800000 + 0x0001) GUICtrlSetBkColor($Label_4, 0xFF0000) GUICtrlSetFont($Label_4, 16) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $Button_1 $Timer1Active = 1 $timer1 = TimerInit() GUICtrlSetBkColor($Label_4, 0x64C671) Case $msg = $Button_2 $Timer1Active = 0 GUICtrlSetData($Label_4, "00:00:00") GUICtrlSetBkColor($Label_4, 0xFF0000) Case $msg = $GUI_EVENT_CLOSE EndSelect If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd Func AllTimers1() Local $Secs, $Mins, $Hour, $Time1, $Time2, $sTime1 = $Time1, $sTime2 = $Time2 Dim $read1 = "One, Hour, Past, Start" Dim $read2 = int($count) & ", Hours, Past, Start" If $Timer1Active Then _TicksToTime(Int(TimerDiff($timer1)), $Hour, $Mins, $Secs) $Time1 = StringFormat("%02i:%02i:%02i", $Hour, $Mins, $Secs) If $sTime1 <> $Time1 Then ControlSetText("MyGUI", "", "Static1", $Time1) EndIf If StringLeft((GUICtrlRead($Label_4)), 2) = $count Then If $count = "01" Then _TalkOBJ($read1) MsgBox(64, " Hour Message", " One Hour has Passed ", 10) Else _TalkOBJ($read2) MsgBox(64, " Hour Message", $count & " Hours have Passed ", 10) EndIf $count = $count + "01" If $count < 10 then $count = "0" & $count EndIf EndFunc;==>AllTimers Func _TalkOBJ($s_text) Local $o_speech $o_speech = ObjCreate("SAPI.SpVoice") $o_speech.Speak ($s_text) $o_speech = "" EndFunc;==>_TalkOBJ lol 8) EDIT.... fixed Voice Edited December 22, 2005 by Valuater Link to comment Share on other sites More sharing options...
Bert Posted December 22, 2005 Author Share Posted December 22, 2005 okok....let me guess...this will talk to you????? I have to run it to test it, but......hehehheh <WEG> The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
Valuater Posted December 22, 2005 Share Posted December 22, 2005 (edited) okok....let me guess...this will talk to you????? I have to run it to test it, but......hehehheh <WEG> yepper.... 8)8)EDIT..... re-did the above post for the Voice8) Edited December 22, 2005 by Valuater Link to comment Share on other sites More sharing options...
Bert Posted December 23, 2005 Author Share Posted December 23, 2005 @Valuater: I just finished testing it. THIS IS WAY KEWL!!!! I owe you big! Thanks! The Vollatran project My blog: http://www.vollysinterestingshit.com/ 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