Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Simple countdown timer


  • Please log in to reply
26 replies to this topic
SilverFish
  • Members
  • 163 posts
  • Last active: May 16 2015 01:21 PM
  • Joined: 06 Dec 2010

For the life of me I can't get this!  Just want a SIMPLE countdown timer.  Idealy, an inputbox for just minutes to be put in.  A start button.  That's it!  To save space, the start button would change to the countdown timer.  A way to know it's done, preferably when the timer hits 0 to have that in red..  

 

I know this sounds like I'm asking someone to write the entire thing and hand it to me.  I'm willing to put time into this, just not sure where to start.



Leef_me
  • Moderators
  • 8510 posts
  • Last active: Sep 10 2015 05:50 AM
  • Joined: 08 Apr 2009

Have you searched the forum for existing threads with example scripts?

 

google this     site:autohotkey.com countdown



SilverFish
  • Members
  • 163 posts
  • Last active: May 16 2015 01:21 PM
  • Joined: 06 Dec 2010

I have.  I don't understand it and I want to make it VERY simple.  Picking apart the script becomes very hard. :/



girlgamer
  • Moderators
  • 3263 posts
  • Last active: Feb 01 2015 09:49 AM
  • Joined: 04 Jun 2010

here's where you start

  1. http://ahkscript.org/docs/Tutorial.htm
  2. http://ahkscript.org...ds/InputBox.htm
  3. http://ahkscript.org...ds/SetTimer.htm

or if you really need it right now (instant gratification) you can download one from here

http://download.cnet...4-75819602.html


The universe is a wondrous place! The faster you create unbreakable code, the faster the universe creates people that can break it. All scripting follows the rule Rule Of Twos -- 1) Good, 2) Fast 3) Cheap -- pick any Two.
I guarantee absolutely nothing about any code I provide except that it works in my machine. ●
MMO Fighter   KeyLooperDemo   Key Spammer   TinyClickRecorder  GGs Password Generator.ahk
For the newest version of AutoHotkey and some killer scripts go here.
Rock-on%20kitten.gif


flyingDman
  • Spam Officer
  • 2186 posts
  • Last active: Nov 07 2015 08:15 AM
  • Joined: 27 Feb 2009

I know that there are many countdown timers here, but... let's have one more :D !. Only 19 lines:

Progress, m1 b fs20 zh0 w200, Enter # of minutes
loop,2
	{
	Input x, L1,{enter}{esc},1,2,3,4,5,6,7,8,9,0
	if (ErrorLevel = "Match")
		Progress, m1 b fs70 fm12 zh10 w200, % tm .= x, Press Enter to accept
	else if (Errorlevel = "EndKey:enter")
		break
	else
		exitapp
	}
settimer,label,1000
label:
++y
Progress, % 100*(tm*60-y)/(tm*60), % tm-floor(y/60)-1, % y>tm*60 ? tm*60-y : ((z:=mod(tm*60-y,60))=0 ? 60 : z)
if (y = tm * 60)
	Progress, m1 b fs40 fm20 zh0 CTred w200, , done
esc::
exitapp

Marine Corps Gen. Joseph Dunford told senators at his Joint Chiefs of Staff confirmation hearing : “If you want to talk about a nation that could pose an existential threat to the United States, I'd have to point to Russia. And if you look at their behavior, it's nothing short of alarming.”


SilverFish
  • Members
  • 163 posts
  • Last active: May 16 2015 01:21 PM
  • Joined: 06 Dec 2010

Tried to upload a screenshot, but this site will not let me. :/

 

And here's the script:

Gui, 1:Add, Edit, x14 y240 w33 h20 number right ReadOnly
Gui, 1:Add, UpDown, vMinutes Range0-59 wrap, 1
Gui, 1:Add, Button, x50 y240 w35 h20 section, Start
Gui, 1:Add, Text, x14 y260, |
Gui, 1:Add, Progress, x16 y261 w99 h14s cGreen BackgroundWhite vMyProgress ;xs
;Gui, Add, Progress, w400 h20 vMyProgress xs
;Gui, 1:Add, Progress, w80 h10 cGreen BackgroundWhite Range1-500 vMyProgress
Gui, 1:Add, Text, x114 y260, |
 
Return
 
ButtonStart:
  Gui, Submit, NoHide
;  TotalSec := (Minutes*60+Seconds)
  StopTime := A_TickCount + (TotalSec*1000)
 
  Loop
    {
      Sleep 1000
      TimeLeft := (StopTime - A_TickCount)/1000
      ProgressBar := 100-(TimeLeft/TotalSec*100)
      Minutes := Floor(TimeLeft/60)
;      Seconds := Round(Mod(TimeLeft,60))
      If TimeLeft >= 0
        {
           GuiControl,, Edit1, %Minutes%    
;           GuiControl,, Edit2, %Seconds%
         }  
      GuiControl,, MyProgress, %ProgressBar%    
      If (A_TickCount >= Stoptime)
        {
           Break
        }
    }
Sleep 100
 SoundBeep,,300
Return
 
 
I half know what I'm doing...  Which is not much!  The issue is that I have to hit the button several times to get it to start and I expect a BEEP noise when it starts and stops and do not always get those.  I need this very minimalist! A start and reset button beside the 'start' button would be useful.  I'm afraid that guessing 100's of times might be the only way to get somewhere! :(  Any help would be great!


SilverFish
  • Members
  • 163 posts
  • Last active: May 16 2015 01:21 PM
  • Joined: 06 Dec 2010

http://i.imgur.com/oeue63s.png

 

This might work.



flyingDman
  • Spam Officer
  • 2186 posts
  • Last active: Nov 07 2015 08:15 AM
  • Joined: 27 Feb 2009

did you run my script?


Marine Corps Gen. Joseph Dunford told senators at his Joint Chiefs of Staff confirmation hearing : “If you want to talk about a nation that could pose an existential threat to the United States, I'd have to point to Russia. And if you look at their behavior, it's nothing short of alarming.”


SilverFish
  • Members
  • 163 posts
  • Last active: May 16 2015 01:21 PM
  • Joined: 06 Dec 2010

I did.  I'm trying to use a GUI I already have up all the time.  I'm trying to put this timer at the bottom and very clean/small.  Also, having a hard time reading/understanding the code.  What I have so far, I like.  Just trying to tweak it a little so it works flawlessly.



bruno
  • Members
  • 635 posts
  • Last active: Nov 04 2015 02:26 PM
  • Joined: 07 Mar 2011

 

I know that there are many countdown timers here, but... let's have one more :D !. Only 19 lines:

Progress, m1 b fs20 zh0 w200, Enter # of minutes
loop,2
	{
	Input x, L1,{enter}{esc},1,2,3,4,5,6,7,8,9,0
	if (ErrorLevel = "Match")
		Progress, m1 b fs70 fm12 zh10 w200, % tm .= x, Press Enter to accept
	else if (Errorlevel = "EndKey:enter")
		break
	else
		exitapp
	}
settimer,label,1000
label:
++y
Progress, % 100*(tm*60-y)/(tm*60), % tm-floor(y/60)-1, % y>tm*60 ? tm*60-y : ((z:=mod(tm*60-y,60))=0 ? 60 : z)
if (y = tm * 60)
	Progress, m1 b fs40 fm20 zh0 CTred w200, , done
esc::
exitapp

I tested and it works fine! Could you provide a "Count Up" version of this script where it counts up?



flyingDman
  • Spam Officer
  • 2186 posts
  • Last active: Nov 07 2015 08:15 AM
  • Joined: 27 Feb 2009

Added the ability to enter a MM:SS start time. If you press enter without entering a time, it will count up. Plays a sound when done counting down and then starts to count up (fixed this).  Pauses if you press press P.  Restarts if you press S. Counts up in red but only after a count down.

Progress, m1 b fs70 fm12 zh10 CTgreen w250, % "00:00", Enter start time
loop,4
    {
    Input x, L1,{esc}{enter},1,2,3,4,5,6,7,8,9,0
    w .= x , y := SubStr("000" w, -3)
    if (ErrorLevel = "Match")
        Progress, m1 b fs70 fm12 zh10 CTgreen w250, % SubStr(y,1,2) ":" SubStr(y,3,2), Enter to accept and start
    else if (Errorlevel = "EndKey:enter")
        break
    else
        exitapp
    }
startover:
t := 0, w := SubStr(y,1,2)*60 + SubStr(y,3,2)
settimer,label,1000
return
label:
++t
if (t < w)
    Progress, % 100*(w-t)/w, % SubStr("00" floor((w-t)/60),-1) ":" SubStr("00" mod(w-t,60),-1), count down
else if (t = w)
    {
    Progress, m1 b fs70 fm12 zh10 CTred w250, 0, Done!
    SoundPlay, *48
    }
else if (t > w)
    Progress, , % SubStr("0" floor((t-w)/60), -1) ":" SubStr("0" mod(t-w,60), -1), count up
p:: settimer,label,% (a:=!a) ? "off" : "on"
s:: goto startover
esc:: ExitApp

Marine Corps Gen. Joseph Dunford told senators at his Joint Chiefs of Staff confirmation hearing : “If you want to talk about a nation that could pose an existential threat to the United States, I'd have to point to Russia. And if you look at their behavior, it's nothing short of alarming.”


bruno
  • Members
  • 635 posts
  • Last active: Nov 04 2015 02:26 PM
  • Joined: 07 Mar 2011

Thanks, super nice! I always wanted a "count-up" counter.



SilverFish
  • Members
  • 163 posts
  • Last active: May 16 2015 01:21 PM
  • Joined: 06 Dec 2010

My issue is that I can't run this in the center of my screen.  I have several things running and need to move this around.  Ideally, the GUI I already have will contain this.



flyingDman
  • Spam Officer
  • 2186 posts
  • Last active: Nov 07 2015 08:15 AM
  • Joined: 27 Feb 2009

This can be customized in a number of ways: remove the b in the progress options and it will be dragable. Add a line like wdth := A_ScreenWidth - 350, hght := A_ScreenHeight - 250 and add X%wdth% Y%hght% to the progress options and it will show in the right hand corner.
 


Marine Corps Gen. Joseph Dunford told senators at his Joint Chiefs of Staff confirmation hearing : “If you want to talk about a nation that could pose an existential threat to the United States, I'd have to point to Russia. And if you look at their behavior, it's nothing short of alarming.”


ErrorOnLine1
  • Members
  • 230 posts
  • Last active: Oct 05 2015 02:46 PM
  • Joined: 25 Dec 2012

Great timer script, flyingDman. Thanks a lot.