anony10 Posted September 15, 2011 Share Posted September 15, 2011 (edited) Hello!I want to make a shoutdown program.But when i try to do a count downer, it is counting in - (example: -1, -2, etc). So i need a little help, how to do it.Autoit just my hobby, so im so bad in it. #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Sleep time!", 173, 212, 192, 124) $Input1 = GUICtrlCreateInput("", 28, 40, 121, 21) $Label1 = GUICtrlCreateLabel("T i m e :", 67, 13, 51, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") $Label2 = GuiCtrlCreateLabel("asd", 80, 100, 51, 17) $Button1 = GUICtrlCreateButton("Go!", 51, 141, 75, 25, 0) $Button2 = GUICtrlCreateButton("Exit", 51, 172, 75, 25, 0) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $read = GuiCtrlRead ($Input1) $time = $read * 60000 Do $asd = GuiCtrlRead($label2) Sleep(1000) GuiCTrlSetData($label2, $asd -1) Until GuiCtrlRead($label2) = 0 Sleep($time) msgbox(0, "asd", "asd") Case $Button2 Exit EndSwitch WEnd edit typo Edited September 15, 2011 by anony10 Link to comment Share on other sites More sharing options...
somdcomputerguy Posted September 15, 2011 Share Posted September 15, 2011 (edited) Take a look at Time Machine #1. There's more in that thread, browse thru the whole thing, you might find something else useful. Edited September 15, 2011 by somdcomputerguy - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
anony10 Posted September 15, 2011 Author Share Posted September 15, 2011 Okay, thank you, but i didnt see anything useful.Okay theres some counters and itis good but i need count down.I cant do it, and i tryed to search on forum but nothing.. Link to comment Share on other sites More sharing options...
JoHanatCent Posted September 16, 2011 Share Posted September 16, 2011 Okay, thank you, but i didnt see anything useful.Okay theres some counters and itis good but i need count down.I cant do it, and i tryed to search on forum but nothing.. Try this: #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #region ### START Koda GUI section ### Form= $Form1 = GUICreate("Sleep time!", 173, 212, 192, 124) $Input1 = GUICtrlCreateInput("", 28, 40, 121, 21) $Label1 = GUICtrlCreateLabel("T i m e :", 67, 13, 51, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") $Label2 = GUICtrlCreateLabel("asd", 80, 100, 51, 17) $Button1 = GUICtrlCreateButton("Go!", 51, 141, 75, 25, 0) $Button2 = GUICtrlCreateButton("Exit", 51, 172, 75, 25, 0) GUISetState(@SW_SHOW) #endregion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $read = GUICtrlRead($Input1) $time = $read * 60000 GUICtrlSetData($Label2, $read);<<< ========== Add this? Do $asd = GUICtrlRead($Label2) Sleep(1000) GUICtrlSetData($Label2, $asd - 1) Until GUICtrlRead($Label2) = 0 Sleep($time);<<<< ======== Do you want to sleep this long? MsgBox(0, "asd", "asd") Case $Button2 Exit EndSwitch WEnd Link to comment Share on other sites More sharing options...
anony10 Posted September 16, 2011 Author Share Posted September 16, 2011 Hm, it is good, but in input i write the minutes.and this is count like seconds.But thank you, i try to modifie it to minutes. Link to comment Share on other sites More sharing options...
UEZ Posted September 16, 2011 Share Posted September 16, 2011 Maybe this helps you: Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
anony10 Posted September 17, 2011 Author Share Posted September 17, 2011 Thank you, it is much better...But i need just a little help with this script! expandcollapse popup#NoTrayIcon #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Opt('MustDeclareVars', 1) #Region ### START Koda GUI section ### Form= Global $msg Global $hGUI = GUICreate("Sleep time!", 173, 235, 192, 124) Global $Input1 = GUICtrlCreateInput("Minutes", 28, 40, 121, 21) Global $Label1 = GUICtrlCreateLabel("T i m e :", 67, 13, 51, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") Global $Label2 = GuiCtrlCreateLabel("Countdown", 49, 100, 90, 32) Global $Label3 = GuiCtrlCreateLabel("The time is " & @HOUR & ":" & @MIN, 49, 120, 90, 32) Global $Button1 = GUICtrlCreateButton("Go!", 51, 141, 75, 25, 0) Global $Button2 = GUICtrlCreateButton("Exit", 51, 172, 75, 25, 0) Global $Button3 = GuiCtrlCreateButton("Abort", 51, 201, 75, 25, 0) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Do $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $Button1 $inputread = GuiCtrlRead ($Input1) Global $countdown = $inputread ;minutes for countdown Global $seconds = $inputread * 60 ;convert to seconds Countdown() AdlibRegister("Countdown", 1000) EndSwitch Until False AdlibUnRegister("Countdown") Exit Func Countdown() Local $sec, $min, $hr $sec = Mod($seconds, 60) $min = Mod($seconds / 60, 60) $hr = Floor($seconds / 60 ^ 2) GUICtrlSetData($label2, StringFormat("%02i:%02i:%02i", $hr, $min, $sec)) If $seconds <= 0 Then AdlibUnRegister("Countdown") MsgBox(0, "Information", "Countdown reached 00:00:00") Exit EndIf $seconds -= 1 EndFunc Why under case $button1 $inputread doesnt work? Link to comment Share on other sites More sharing options...
JohnOne Posted September 17, 2011 Share Posted September 17, 2011 Because you have the option for must declare variables set, and you have not declared $inputread. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
anony10 Posted September 17, 2011 Author Share Posted September 17, 2011 And how can declare $inputread? Sorry im so newbie in it. Link to comment Share on other sites More sharing options...
UEZ Posted September 17, 2011 Share Posted September 17, 2011 Try this: expandcollapse popup#NoTrayIcon #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Opt('MustDeclareVars', 1) #Region ### START Koda GUI section ### Form= Global $msg, $inputread, $countdown, $seconds Global $hGUI = GUICreate("Sleep time!", 173, 235, 192, 124) Global $Input1 = GUICtrlCreateInput("Minutes", 28, 40, 121, 21) Global $Label1 = GUICtrlCreateLabel("T i m e :", 67, 13, 51, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") Global $Label2 = GuiCtrlCreateLabel("Countdown", 49, 100, 90, 32) Global $Label3 = GuiCtrlCreateLabel("The time is " & @HOUR & ":" & @MIN, 49, 120, 90, 32) Global $Button1 = GUICtrlCreateButton("Go!", 51, 141, 75, 25, 0) Global $Button2 = GUICtrlCreateButton("Exit", 51, 172, 75, 25, 0) Global $Button3 = GuiCtrlCreateButton("Abort", 51, 201, 75, 25, 0) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Do $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE AdlibUnRegister("Countdown") Exit Case $Button1 $inputread = GuiCtrlRead ($Input1) $countdown = $inputread ;minutes for countdown $seconds = $inputread * 60 ;convert to seconds Countdown() AdlibRegister("Countdown", 1000) EndSwitch Until False Func Countdown() Local $sec, $min, $hr $sec = Mod($seconds, 60) $min = Mod($seconds / 60, 60) $hr = Floor($seconds / 60 ^ 2) GUICtrlSetData($label2, StringFormat("%02i:%02i:%02i", $hr, $min, $sec)) If $seconds <= 0 Then AdlibUnRegister("Countdown") MsgBox(0, "Information", "Countdown reached 00:00:00") Exit EndIf $seconds -= 1 EndFunc Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
anony10 Posted September 17, 2011 Author Share Posted September 17, 2011 Omg, dude! You are awesome, thx thx! 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