CHronologist Posted July 13, 2008 Share Posted July 13, 2008 (edited) This is just an small all purpose, down counter, in the left field you enter the hours an in the right the minutes and the progressbar will show you the status till the programmed time is over. expandcollapse popup#include <GUIConstants.au3> GUICreate("Clock", 210, 100) $OK_Btn = GUICtrlCreateButton("Start", 10, 10, 70, 25) $std = GUICtrlCreateInput ("Hours", 90, 10, 50, 25) $min = GUICtrlCreateInput ("Min", 150, 10, 50, 25) GuiCtrlCreateLabel(":", 142, 14, 5, 25) $lab = GUICtrlCreateLabel("Time left: ", 10, 50, 200, 20) $progressbar1 = GUICtrlCreateProgress (10,70,190,20) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE GUIDelete() Exit Case $msg = $OK_Btn if GUICtrlRead($OK_Btn) = "Start" Then $time = (StringIsDigit(GUICtrlRead($std)) Or StringIsFloat(GUICtrlRead($std)))* GUICtrlRead($std) * 3600 $time += (StringIsDigit(GUICtrlRead($min)) Or StringIsFloat(GUICtrlRead($min))) * GUICtrlRead($min) * 60 GUICtrlSetData ($OK_Btn,"Stop") $begin = TimerInit() While Int(TimerDiff($begin)/1000) <= $time $Diffhour = Int($time/3600 - TimerDiff($begin)/3600000) $Diffmin = Int(Mod($time/60 - TimerDiff($begin)/60000, 60)) $Diffsek = Int(Mod($time - TimerDiff($begin)/1000, 60)) GUICtrlSetData($lab, "Time Left: " & $Diffhour & " h " & $DiffMin & " min " & $Diffsek & " sec ") GUICtrlSetData($progressbar1, (Int(TimerDiff($begin)/1000)/$time)*100) if Int(TimerDiff($begin)/1000) = $time then GUICtrlSetData($progressbar1, 100) SoundPlay(@WindowsDir & "\Media\Tada.wav", 1) GUICtrlSetData($progressbar1, 0) GUICtrlSetData ($OK_Btn,"Start") ContinueCase EndIf if GUIGetMsg() = $OK_Btn then GUICtrlSetData($progressbar1, 0) GUICtrlSetData ($OK_Btn,"Start") ContinueCase EndIf Sleep(10) WEnd ElseIf GUICtrlRead($OK_Btn) = "Stop" Then GUICtrlSetData ($OK_Btn,"Start") EndIf Case @error EndSelect WEnd If you have any suggestion please tell me. For example, for some reason I had to add this "Case @error" as some kind as dummy case so that the "Continue Case" finds another case to proceed. In a previous version I diddn't need this to work, if you know why or have any other ideas just say, I'm eager to learn new tricks ;P In any other case just enjoy the programm if you find use for it. Edited July 17, 2008 by CHronologist Link to comment Share on other sites More sharing options...
JustinMeyer Posted July 13, 2008 Share Posted July 13, 2008 Cool, I like it. I think it would be nice to see the actual countdown... hours, minutes, and seconds. But it is still handy as is. Link to comment Share on other sites More sharing options...
CHronologist Posted July 14, 2008 Author Share Posted July 14, 2008 (edited) Thanks for the reply. You are right a visible countdown would be more practical, but I decided against it, because this is not intended to be a stopwatch, but a timer that reminds you of something you have to do after a certain time while you do other things. So the program normally runs in background and for this purpose a visible countdown would have meant more work than needed and the progressbar looks more nice^^ You are free to add this function, I would be interested in seeing how you do it. Edited July 14, 2008 by CHronologist Link to comment Share on other sites More sharing options...
gseller Posted July 17, 2008 Share Posted July 17, 2008 Nice!! Here is my input on your cool countdown timer... muttley expandcollapse popup#include <GUIConstants.au3> GUICreate("Quick Timer", 210, 115) $OK_Btn = GUICtrlCreateButton("Start", 10, 25, 70, 25) $std = GUICtrlCreateInput ( "", 90, 25, 50, 25) $hidde = GUICtrlCreateInput("", 150, 25, 50, 25) GuiCtrlCreateLabel("Hours", 90, 10, 50, 15) GuiCtrlCreateLabel("Minutes", 150, 10, 70, 15) GuiCtrlCreateLabel(":", 142, 29, 5, 25) $progressbar1 = GUICtrlCreateProgress (10,85,190,20) $Minutes = GUICtrlCreateCombo("Minutes 0", 110, 55, 80, 25) ;added zero to keep from erroring out. GUICtrlSetData(-1, "1 Minutes|3 Minutes|5 Minutes|10 Minutes|15 Minutes|20 Minutes|25 Minutes|30 Minutes|45 Minutes|50 Minutes|59 Minutes") $Hours = GUICtrlCreateCombo("Hours 0", 10, 55, 65, 25) ;added zero to keep from erroring out. GUICtrlSetData(-1, "1 Hour|2 Hours|3 Hours|4 Hours|5 Hours|6 Hours|7 Hours|8 Hours|9 Hours") GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE GUIDelete() Exit Case $msg = $OK_Btn if GUICtrlRead($OK_Btn) = "Start" Then $asminuteResult = StringRegExp(GUICtrlRead($Minutes), '([\+-]*\d+\.*\d*)', 1) GUICtrlSetData ($hidde, $asminuteResult[0]) $ashourResult = StringRegExp(GUICtrlRead($Hours), '([\+-]*\d+\.*\d*)', 1) GUICtrlSetData ($std, $ashourResult[0]) $time = GUICtrlRead($std)*3600+GUICtrlRead($hidde)*60 GUICtrlSetData ($OK_Btn,"Stop") $begin = TimerInit() While Int(TimerDiff($begin)/1000) <= $time GUICtrlSetData($progressbar1, (Int(TimerDiff($begin)/1000)/$time)*100) if Int(TimerDiff($begin)/1000) = $time then GUICtrlSetData($progressbar1, 100) SoundPlay(@WindowsDir & "\Media\Tada.wav", 1) GUICtrlSetData($progressbar1, 0) GUICtrlSetData ($OK_Btn,"Start") ContinueCase EndIf if GUIGetMsg() = $OK_Btn then GUICtrlSetData($progressbar1, 0) GUICtrlSetData ($OK_Btn,"Start") ContinueCase EndIf WEnd ElseIf GUICtrlRead($OK_Btn) = "Stop" Then GUICtrlSetData ($OK_Btn,"Start") EndIf Case @error EndSelect WEnd Link to comment Share on other sites More sharing options...
CHronologist Posted July 17, 2008 Author Share Posted July 17, 2008 (edited) nice done @gesller, makes it better to handle without losing the compact style I wanted to produce. Thanks The only problem you might solve is, that now the programm doesn't seem to accept entries from the input field. Edited July 17, 2008 by CHronologist Link to comment Share on other sites More sharing options...
CHronologist Posted July 17, 2008 Author Share Posted July 17, 2008 Edit: added the visible countdown timer Link to comment Share on other sites More sharing options...
gseller Posted July 17, 2008 Share Posted July 17, 2008 (edited) I like the visible countdown timer, I have to figure out what is up with my dropdows.. LOL muttley edit: typo Edited July 17, 2008 by gesller Link to comment Share on other sites More sharing options...
gseller Posted July 18, 2008 Share Posted July 18, 2008 Ok, Here it is.. I fixed the trouble above with not letting you add numbers into the inputs and added your function with the visible countdown. expandcollapse popup#include <GUIConstants.au3> GUICreate("Quick Timer", 210, 130) $OK_Btn = GUICtrlCreateButton("Start", 10, 10, 70, 25) $std = GUICtrlCreateInput ( "", 90, 25, 50, 25) $hidde = GUICtrlCreateInput("", 150, 25, 50, 25) GuiCtrlCreateLabel("Hours", 90, 10, 50, 15) GuiCtrlCreateLabel("Minutes", 150, 10, 70, 15) GuiCtrlCreateLabel(":", 142, 29, 5, 25) $progressbar1 = GUICtrlCreateProgress (10,105,190,20) $lab = GUICtrlCreateLabel("Time left: ", 10, 90, 200, 15) $Clear = GUICtrlCreateButton("clear", 10, 35, 70, 25) $Minutes = GUICtrlCreateCombo("Minutes", 110, 65, 85, 25) ;added zero to keep from erroring out. GUICtrlSetData(-1, "1 Minutes|3 Minutes|5 Minutes|10 Minutes|15 Minutes|20 Minutes|25 Minutes|30 Minutes|45 Minutes|50 Minutes|59 Minutes") $Hours = GUICtrlCreateCombo("Hours", 10, 65, 85, 25) ;added zero to keep from erroring out. GUICtrlSetData(-1, "1 Hour|2 Hours|3 Hours|4 Hours|5 Hours|6 Hours|7 Hours|8 Hours|9 Hours") GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $Hours $ashourResult = StringRegExp(GUICtrlRead($Hours), '([\+-]*\d+\.*\d*)', 1) GUICtrlSetData ($std, $ashourResult[0]) Case $msg = $Minutes $asminuteResult = StringRegExp(GUICtrlRead($Minutes), '([\+-]*\d+\.*\d*)', 1) GUICtrlSetData ($hidde, $asminuteResult[0]) Case $msg = $GUI_EVENT_CLOSE GUIDelete() Exit Case $msg = $Clear _Clear_All() Case $msg = $OK_Btn if GUICtrlRead($OK_Btn) = "Start" Then $time = (StringIsDigit(GUICtrlRead($std)) Or StringIsFloat(GUICtrlRead($std)))* GUICtrlRead($std) * 3600 $time += (StringIsDigit(GUICtrlRead($hidde)) Or StringIsFloat(GUICtrlRead($hidde))) * GUICtrlRead($hidde) * 60 GUICtrlSetData ($OK_Btn,"Stop") $begin = TimerInit() While Int(TimerDiff($begin)/1000) <= $time $Diffhour = Int($time/3600 - TimerDiff($begin)/3600000) $Diffmin = Int(Mod($time/60 - TimerDiff($begin)/60000, 60)) $Diffsek = Int(Mod($time - TimerDiff($begin)/1000, 60)) GUICtrlSetData($lab, "Time Left: " & $Diffhour & " h " & $DiffMin & " min " & $Diffsek & " sec ") GUICtrlSetData($progressbar1, (Int(TimerDiff($begin)/1000)/$time)*100) if Int(TimerDiff($begin)/1000) = $time then GUICtrlSetData($progressbar1, 100) SoundPlay(@WindowsDir & "\Media\Tada.wav", 1) GUICtrlSetData($progressbar1, 0) GUICtrlSetData ($OK_Btn,"Start") ContinueCase EndIf if GUIGetMsg() = $OK_Btn then GUICtrlSetData($progressbar1, 0) GUICtrlSetData ($OK_Btn,"Start") ContinueCase EndIf Sleep(10) WEnd ElseIf GUICtrlRead($OK_Btn) = "Stop" Then GUICtrlSetData ($OK_Btn,"Start") EndIf Case @error EndSelect WEnd Func _Clear_All() GUICtrlSetData ($Hours, "Hours") GUICtrlSetData ($Minutes, "Minutes") GUICtrlSetData ($std, "") GUICtrlSetData ($hidde, "") EndFunc Link to comment Share on other sites More sharing options...
CHronologist Posted July 18, 2008 Author Share Posted July 18, 2008 Ah nice by checking the GUIMsg for a combo box event the progamm gets to know if the combo box was use and doesn't overwrite the input alway. Good work. Link to comment Share on other sites More sharing options...
JustinMeyer Posted July 19, 2008 Share Posted July 19, 2008 Edit: added the visible countdown timerI like it with the countdown timer, tells me exactly how much time I have left to meet my deadline. Cool script, thanks CHronologist! Link to comment Share on other sites More sharing options...
CHronologist Posted July 19, 2008 Author Share Posted July 19, 2008 *bows* thansk for positive feedback, trying to improve my scripting skill every day. Link to comment Share on other sites More sharing options...
Diko Posted January 30, 2009 Share Posted January 30, 2009 *bows* thansk for positive feedback, trying to improve my scripting skill every day.How about helping a newbie :-DPLS can you make a simple version that I can implement as a function in my own scrip /GAME BOT/ That would show only time passed since starting specific function in the script.I need a simple MSG/WINDOW/TRAY Status perhaps where I can see the progress. Thanks :-) Link to comment Share on other sites More sharing options...
Muaddib Posted February 5, 2009 Share Posted February 5, 2009 (edited) Ok, Here it is.. I fixed the trouble above with not letting you add numbers into the inputs and added your function with the visible countdown. expandcollapse popup#include <GUIConstants.au3> GUICreate("Quick Timer", 210, 130) $OK_Btn = GUICtrlCreateButton("Start", 10, 10, 70, 25) $std = GUICtrlCreateInput ( "", 90, 25, 50, 25) $hidde = GUICtrlCreateInput("", 150, 25, 50, 25) GuiCtrlCreateLabel("Hours", 90, 10, 50, 15) GuiCtrlCreateLabel("Minutes", 150, 10, 70, 15) GuiCtrlCreateLabel(":", 142, 29, 5, 25) $progressbar1 = GUICtrlCreateProgress (10,105,190,20) $lab = GUICtrlCreateLabel("Time left: ", 10, 90, 200, 15) $Clear = GUICtrlCreateButton("clear", 10, 35, 70, 25) $Minutes = GUICtrlCreateCombo("Minutes", 110, 65, 85, 25) ;added zero to keep from erroring out. GUICtrlSetData(-1, "1 Minutes|3 Minutes|5 Minutes|10 Minutes|15 Minutes|20 Minutes|25 Minutes|30 Minutes|45 Minutes|50 Minutes|59 Minutes") $Hours = GUICtrlCreateCombo("Hours", 10, 65, 85, 25) ;added zero to keep from erroring out. GUICtrlSetData(-1, "1 Hour|2 Hours|3 Hours|4 Hours|5 Hours|6 Hours|7 Hours|8 Hours|9 Hours") GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $Hours $ashourResult = StringRegExp(GUICtrlRead($Hours), '([\+-]*\d+\.*\d*)', 1) GUICtrlSetData ($std, $ashourResult[0]) Case $msg = $Minutes $asminuteResult = StringRegExp(GUICtrlRead($Minutes), '([\+-]*\d+\.*\d*)', 1) GUICtrlSetData ($hidde, $asminuteResult[0]) Case $msg = $GUI_EVENT_CLOSE GUIDelete() Exit Case $msg = $Clear _Clear_All() Case $msg = $OK_Btn if GUICtrlRead($OK_Btn) = "Start" Then $time = (StringIsDigit(GUICtrlRead($std)) Or StringIsFloat(GUICtrlRead($std)))* GUICtrlRead($std) * 3600 $time += (StringIsDigit(GUICtrlRead($hidde)) Or StringIsFloat(GUICtrlRead($hidde))) * GUICtrlRead($hidde) * 60 GUICtrlSetData ($OK_Btn,"Stop") $begin = TimerInit() While Int(TimerDiff($begin)/1000) <= $time $Diffhour = Int($time/3600 - TimerDiff($begin)/3600000) $Diffmin = Int(Mod($time/60 - TimerDiff($begin)/60000, 60)) $Diffsek = Int(Mod($time - TimerDiff($begin)/1000, 60)) GUICtrlSetData($lab, "Time Left: " & $Diffhour & " h " & $DiffMin & " min " & $Diffsek & " sec ") GUICtrlSetData($progressbar1, (Int(TimerDiff($begin)/1000)/$time)*100) if Int(TimerDiff($begin)/1000) = $time then GUICtrlSetData($progressbar1, 100) SoundPlay(@WindowsDir & "\Media\Tada.wav", 1) GUICtrlSetData($progressbar1, 0) GUICtrlSetData ($OK_Btn,"Start") ContinueCase EndIf if GUIGetMsg() = $OK_Btn then GUICtrlSetData($progressbar1, 0) GUICtrlSetData ($OK_Btn,"Start") ContinueCase EndIf Sleep(10) WEnd ElseIf GUICtrlRead($OK_Btn) = "Stop" Then GUICtrlSetData ($OK_Btn,"Start") EndIf Case @error EndSelect WEnd Func _Clear_All() GUICtrlSetData ($Hours, "Hours") GUICtrlSetData ($Minutes, "Minutes") GUICtrlSetData ($std, "") GUICtrlSetData ($hidde, "") EndFunc thx gesller it's a AutoIt great script Guys can anyone tell me what need to change to make... - when i press OK_Btn the timer will start and i don't finish untill i press Stop btn. constantly the time that I chose from Combo. thx for help! Edited February 5, 2009 by Muaddib Link to comment Share on other sites More sharing options...
Muaddib Posted February 5, 2009 Share Posted February 5, 2009 thx gesller it's a AutoIt great scriptGuys can anyone tell me what need to change to make...- when i press OK_Btn the timer will start and i don't finish untill i press Stop btn.constantly the time that I chose from Combo.thx for help!anyone? Link to comment Share on other sites More sharing options...
Muaddib Posted February 6, 2009 Share Posted February 6, 2009 so noone know what need to do, maybe some one tell me how to make eternity timer? Link to comment Share on other sites More sharing options...
Hentrinity Posted June 23, 2009 Share Posted June 23, 2009 can someone try adding a pause button or something? that would be helpful Link to comment Share on other sites More sharing options...
crashdemons Posted June 24, 2009 Share Posted June 24, 2009 Along with adding the previously-mentioned pause button, could you please add checking to see if the "Time Left" text actually changed before updating it. Currently the label flashes - besides, if the text didn't change, it's unnecessary to set it again. Eg: You could create a variable to hold the Last value and a variable to hold the New; Set the New value to the "Time Left" desired string, compare it with the Last, if it differs, update the GUI with the New value and set the Last equal to the current New value. Rinse, wash, repeat. My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.) Link to comment Share on other sites More sharing options...
egymma Posted July 4, 2009 Share Posted July 4, 2009 Nice work i needed that [center][/center]My Projects:-[list][*]Window Ender[*]Encryptor-Decryptor[/list] 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