Jump to content

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

AHK Stopwatch


  • Please log in to reply
6 replies to this topic
tally
  • Members
  • 6 posts
  • Last active: Aug 01 2008 09:59 PM
  • Joined: 06 Apr 2008
I never really mess with ahk that much anymore and I've been going through stuff on an old flash drive and found this. It's pretty simple, its not meant to be anything but that either.


;Stopwatch.ahk

#NoEnv
#singleinstance force

timerm := "00"
timers := "00"
stopped := "0"

Gui, Add, Text, x67 y22 w60 h20 vTText, %timerm%:%timers%
Gui, Add, Button, x2 y42 w80 h20 vPause, Pause
Gui, Add, Button, x82 y42 w80 h20 vReset, Reset
Gui, Show, h69 w165, Stopwatch
Settimer, Stopwatch, 1000
Return

Stopwatch:
timers += 1
if(timers > 59)
{
	timerm += 1
	timers := "0"
	GuiControl, , TText ,  %timerm%:%timers%
}
if(timers < 10)
{
	GuiControl, , TText ,  %timerm%:0%timers%
}
else
{
	GuiControl, , TText ,  %timerm%:%timers%
}
return

ButtonPause:
if(stopped = 0)
{
	Settimer, Stopwatch, off
	stopped = 1
}
else
{
	Settimer, Stopwatch, 999
	stopped = 0
}
return

ButtonReset:
timerm := "00"
timers := "00"
GuiControl, , TText ,  %timerm%:%timers%
return

GuiClose:
GuiEscape:
ExitApp
return


Hopefully someone can learn from it.

mtman1020
  • Members
  • 36 posts
  • Last active: May 28 2010 10:16 PM
  • Joined: 08 Aug 2008

I never really mess with ahk that much anymore and I've been going through stuff on an old flash drive and found this. It's pretty simple, its not meant to be anything but that either.

....Code ......

Hopefully someone can learn from it.


Thanks!! I really appreciate the script! I needed a simple stopwatch to keep track of how long I spend helping others at work because we have a new tracking program and we have to account for every minute of the day now :shock: anyway, I did a couple little modifications to give me exactly what I need... (basicly the time I started as well as the length of time spent)

;Stopwatch.ahk

#NoEnv
#singleinstance force

Run:
timerm := "00"
timers := "00"
stopped := "0"
StartTime := A_Hour . ":" . A_Min . ":" . A_Sec
StopTime := "00:00:00"

Gui, Add, Text, x40 y12 w160 h20 vStartTime, Start = %StartTime%
Gui, Add, Text, x40 y32 w160 h20 vTText, Duration = %timerm%:%timers%
Gui, Add, Text, x40 y52 w160 h20 vStopTime, Stop = %StopTime%
Gui, Add, Button, x5 y80 w40 h20 vPause, Pause
Gui, Add, Button, x55 y80 w40 h20 vReset, Reset
Gui, Add, Button, x105 y80 w40 h20 vStop, Stop
Gui, Add, Button, x155 y80 w40 h20 vStart, Start
Gui, Show, h100 w200, Stopwatch
Settimer, Stopwatch, 1000
Return

Stopwatch:
timers += 1
if(timers > 59)
{
   timerm += 1
   timers := "0"
   GuiControl, , TText , Duration = %timerm%:%timers%
}
if(timers < 10)
{
   GuiControl, , TText , Duration = %timerm%:%timers%
}
else
{
   GuiControl, , TText , Duration = %timerm%:%timers%
}
return

ButtonPause:
if(stopped = 0)
{
   Settimer, Stopwatch, off
   stopped = 1
}
else
{
   Settimer, Stopwatch, 999
   stopped = 0
}
return

ButtonReset:
timerm := "00"
timers := "00"
StartTime := A_Hour . ":" . A_Min . ":" . A_Sec
StopTime := "00:00:00"
GuiControl, , StartTime ,  Start = %StartTime%
GuiControl, , TText , Duration = %timerm%:%timers%
GuiControl, , StopTime ,  Stop = %StopTime%
return

ButtonStop:
StopTime := A_Hour . ":" . A_Min . ":" . A_Sec
if(stopped = 0)
{
   Settimer, Stopwatch, off
   stopped = 1
}
else
{
   Settimer, Stopwatch, 999
   stopped = 0
}
GuiControl, , StartTime ,  Start = %StartTime%
GuiControl, , TText , Duration = %timerm%:%timers%
GuiControl, , StopTime ,  Stop = %StopTime%
return

ButtonStart:
Gui, Destroy
GoTo Run

GuiClose:
GuiEscape:
ExitApp
return


It works differently than I thought I would write it, but it works great and I had to do very little work to get what I needed.

Thanks again!

Pandatropolis
  • Members
  • 5 posts
  • Last active: Mar 29 2012 03:47 PM
  • Joined: 01 Mar 2012
I want to start off by saying i have self taught myself starting about 6 mos ago and this is my 3rd day on project about 16 hrs in..

You guys are freaking awesome! I was tasked with creating a timer for my company to track workers progress (they were not happy about that!) and had hit a fat wall because they wanted 6-10 independently operating timers and originally i was working with a timer that i found that was super complicated and could not get it to work right.

Then a light shined down as i was exploring new options and i saw this post.

From it i created:
#NoEnv
#singleinstance force
Settimer, Stopwatch, off

timerm := "00"
timers := "00"
stopped := "0"
timerm1 := "00"
timers1 := "00"
stopped1 := "0"
timerm2 := "00"
timers2 := "00"
stopped2 := "0"
timerm3 := "00"
timers3 := "00"
stopped3 := "0"
timerm4 := "00"
timers4 := "00"
stopped4 := "0"
timerm5 := "00"
timers5 := "00"
stopped5 := "0"

;StartTime := A_Hour . ":" . A_Min . ":" . A_Sec
;StopTime := "00:00:00"

Gui, Add, Text, x85 y5 w160 h20 vStartTime, Start = %StartTime%
Gui, Add, Text, x40 y52 w160 h20 vStopTime, Stop = %StopTime%
Gui, Add, Text, x155 y30 w60 h20 vTText, %timerm%:%timers%
Gui, Add, Text, x155 y70 w60 h20 vTText1, %timerm1%:%timers1%
Gui, Add, Text, x155 y110 w60 h20 vTText2, %timerm2%:%timers2%
Gui, Add, Text, x155 y150 w60 h20 vTText3, %timerm3%:%timers3%
Gui, Add, Text, x155 y190 w60 h20 vTText4, %timerm4%:%timers4%
Gui, Add, Text, x155 y230 w60 h20 vTText5, %timerm5%:%timers5%
;Gui, Add, Button, x2 y42 w80 h20 vPause, Pause
;Gui, Add, Button, x82 y42 w80 h20 vReset, Reset
Gui, Add, Button, x22 y20 w90 h30 gThe_Main_Gui_StopStart1 , &QC
Gui, Add, Button, x22 y60 w90 h30 gThe_Main_Gui_StopStart2 , &Sketch
Gui, Add, Button, x22 y100 w90 h30 gThe_Main_Gui_StopStart3 , &Tech
Gui, Add, Button, x22 y140 w90 h30 gThe_Main_Gui_StopStart4 , &Pokemon
Gui, Add, Button, x22 y180 w90 h30 gThe_Main_Gui_StopStart5 , &Intimate time
Gui, Add, Button, x22 y220 w90 h30 gThe_Main_Gui_StopStart6 , &Unicorn Dance
Gui, Add, Button, x22 y270 w90 h30 gThe_Main_Gui_Close, &Quit
gui, add, edit, w200 vMyEdit
Gui, Show, h400 w250, Stopwatch
Return


Stopwatch:
timers += 1
if(timers > 59)
{
   timerm += 1
   timers := "0"
   GuiControl, , TText ,  %timerm%:%timers%
}
if(timers < 10)
{
   GuiControl, , TText ,  %timerm%:0%timers%
}
else
{
   GuiControl, , TText ,  %timerm%:%timers%
}
return

Stopwatch1:
timers1 += 1
if(timers1 > 59)
{
   timerm1 += 1
   timers1 := "0"
   GuiControl, , TText1 ,  %timerm1%:%timers1%
}
if(timers < 10)
{
   GuiControl, , TText1 ,  %timerm1%:0%timers1%
}
else
{
   GuiControl, , TText1 ,  %timerm1%:%timers1%
}
return

Stopwatch2:
timers2 += 1
if(timers2 > 59)
{
   timerm2 += 1
   timers2 := "0"
   GuiControl, , TText2 ,  %timerm2%:%timers2%
}
if(timers < 10)
{
   GuiControl, , TText2 ,  %timerm%:0%timers2%
}
else
{
   GuiControl, , TText2 ,  %timerm%:%timers2%
}
return

Stopwatch3:
timers3 += 1
if(timers3 > 59)
{
   timerm3 += 1
   timers3 := "0"
   GuiControl, , TText3 ,  %timerm3%:%timers3%
}
if(timers < 10)
{
   GuiControl, , TText3 ,  %timerm3%:0%timers3%
}
else
{
   GuiControl, , TText3 ,  %timerm3%:%timers3%
}
return

Stopwatch4:
timers4 += 1
if(timers4 > 59)
{
   timerm4 += 1
   timers4 := "0"
   GuiControl, , TText4 ,  %timerm4%:%timers4%
}
if(timers < 10)
{
   GuiControl, , TText4 ,  %timerm4%:0%timers4%
}
else
{
   GuiControl, , TText4 ,  %timerm4%:%timers4%
}
return

Stopwatch5:
timers5 += 1
if(timers5 > 59)
{
   timerm5 += 1
   timers5 := "0"
   GuiControl, , TText5 ,  %timerm5%:%timers5%
}
if(timers < 10)
{
   GuiControl, , TText5 ,  %timerm5%:0%timers5%
}
else
{
   GuiControl, , TText5 ,  %timerm5%:%timers5%
}
return

The_Main_Gui_StopStart1:
if(stopped = 0)
{
   Settimer, Stopwatch, off
   stopped = 1
}
else
{
   Settimer, Stopwatch, 999
   stopped = 0
}
return

The_Main_Gui_StopStart2:
if(stopped = 0)
{
   Settimer, Stopwatch1, off
   stopped = 1
}
else
{
   Settimer, Stopwatch1, 999
   stopped = 0
}
return

The_Main_Gui_StopStart3:
if(stopped = 0)
{
   Settimer, Stopwatch2, off
   stopped = 1
}
else
{
   Settimer, Stopwatch2, 999
   stopped = 0
}
return

The_Main_Gui_StopStart4:
if(stopped = 0)
{
   Settimer, Stopwatch3, off
   stopped = 1
}
else
{
   Settimer, Stopwatch3, 999
   stopped = 0
}
return

The_Main_Gui_StopStart5:
if(stopped = 0)
{
   Settimer, Stopwatch4, off
   stopped = 1
}
else
{
   Settimer, Stopwatch4, 999
   stopped = 0
}
return

The_Main_Gui_StopStart6:
if(stopped = 0)
{
   Settimer, Stopwatch5, off
   stopped = 1
}
else
{
   Settimer, Stopwatch5, 999
   stopped = 0
}
return

The_Main_Gui_Close:
Exitapp


ButtonPause:
if(stopped = 0)
{
   Settimer, Stopwatch, off
   stopped = 1
}
else
{
   Settimer, Stopwatch, 999
   stopped = 0
}
return

ButtonReset:
timerm := "00"
timers := "00"
GuiControl, , TText ,  %timerm%:%timers%
return

GuiClose:
GuiEscape:
ExitApp
return

and was able to wow my bosses thanks a lot now to add the file append feature.

THANKS AGAIN

martinmoldrup
  • Members
  • 3 posts
  • Last active: Dec 09 2014 05:08 PM
  • Joined: 22 Apr 2014

Hey. Thanks. But why do you set the timer to 999 milliseconds when reactivating it after pause?

 

Settimer, StopwatchPause, 999



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

I want to start off by saying i have self taught myself starting about 6 mos ago and this is my 3rd day on project about 16 hrs in..

You guys are freaking awesome! I was tasked with creating a timer for my company to track workers progress (they were not happy about that!) and had hit a fat wall because they wanted 6-10 independently operating timers and originally i was working with a timer that i found that was super complicated and could not get it to work right.

Then a light shined down as i was exploring new options and i saw this post.

From it i created:

#NoEnv
#singleinstance force
Settimer, Stopwatch, off

timerm := "00"
timers := "00"
stopped := "0"
timerm1 := "00"
timers1 := "00"
stopped1 := "0"
timerm2 := "00"
timers2 := "00"
stopped2 := "0"
timerm3 := "00"
timers3 := "00"
stopped3 := "0"
timerm4 := "00"
timers4 := "00"
stopped4 := "0"
timerm5 := "00"
timers5 := "00"
stopped5 := "0"

;StartTime := A_Hour . ":" . A_Min . ":" . A_Sec
;StopTime := "00:00:00"

Gui, Add, Text, x85 y5 w160 h20 vStartTime, Start = %StartTime%
Gui, Add, Text, x40 y52 w160 h20 vStopTime, Stop = %StopTime%
Gui, Add, Text, x155 y30 w60 h20 vTText, %timerm%:%timers%
Gui, Add, Text, x155 y70 w60 h20 vTText1, %timerm1%:%timers1%
Gui, Add, Text, x155 y110 w60 h20 vTText2, %timerm2%:%timers2%
Gui, Add, Text, x155 y150 w60 h20 vTText3, %timerm3%:%timers3%
Gui, Add, Text, x155 y190 w60 h20 vTText4, %timerm4%:%timers4%
Gui, Add, Text, x155 y230 w60 h20 vTText5, %timerm5%:%timers5%
;Gui, Add, Button, x2 y42 w80 h20 vPause, Pause
;Gui, Add, Button, x82 y42 w80 h20 vReset, Reset
Gui, Add, Button, x22 y20 w90 h30 gThe_Main_Gui_StopStart1 , &QC
Gui, Add, Button, x22 y60 w90 h30 gThe_Main_Gui_StopStart2 , &Sketch
Gui, Add, Button, x22 y100 w90 h30 gThe_Main_Gui_StopStart3 , &Tech
Gui, Add, Button, x22 y140 w90 h30 gThe_Main_Gui_StopStart4 , &Pokemon
Gui, Add, Button, x22 y180 w90 h30 gThe_Main_Gui_StopStart5 , &Intimate time
Gui, Add, Button, x22 y220 w90 h30 gThe_Main_Gui_StopStart6 , &Unicorn Dance
Gui, Add, Button, x22 y270 w90 h30 gThe_Main_Gui_Close, &Quit
gui, add, edit, w200 vMyEdit
Gui, Show, h400 w250, Stopwatch
Return


Stopwatch:
timers += 1
if(timers > 59)
{
   timerm += 1
   timers := "0"
   GuiControl, , TText ,  %timerm%:%timers%
}
if(timers < 10)
{
   GuiControl, , TText ,  %timerm%:0%timers%
}
else
{
   GuiControl, , TText ,  %timerm%:%timers%
}
return

Stopwatch1:
timers1 += 1
if(timers1 > 59)
{
   timerm1 += 1
   timers1 := "0"
   GuiControl, , TText1 ,  %timerm1%:%timers1%
}
if(timers < 10)
{
   GuiControl, , TText1 ,  %timerm1%:0%timers1%
}
else
{
   GuiControl, , TText1 ,  %timerm1%:%timers1%
}
return

Stopwatch2:
timers2 += 1
if(timers2 > 59)
{
   timerm2 += 1
   timers2 := "0"
   GuiControl, , TText2 ,  %timerm2%:%timers2%
}
if(timers < 10)
{
   GuiControl, , TText2 ,  %timerm%:0%timers2%
}
else
{
   GuiControl, , TText2 ,  %timerm%:%timers2%
}
return

Stopwatch3:
timers3 += 1
if(timers3 > 59)
{
   timerm3 += 1
   timers3 := "0"
   GuiControl, , TText3 ,  %timerm3%:%timers3%
}
if(timers < 10)
{
   GuiControl, , TText3 ,  %timerm3%:0%timers3%
}
else
{
   GuiControl, , TText3 ,  %timerm3%:%timers3%
}
return

Stopwatch4:
timers4 += 1
if(timers4 > 59)
{
   timerm4 += 1
   timers4 := "0"
   GuiControl, , TText4 ,  %timerm4%:%timers4%
}
if(timers < 10)
{
   GuiControl, , TText4 ,  %timerm4%:0%timers4%
}
else
{
   GuiControl, , TText4 ,  %timerm4%:%timers4%
}
return

Stopwatch5:
timers5 += 1
if(timers5 > 59)
{
   timerm5 += 1
   timers5 := "0"
   GuiControl, , TText5 ,  %timerm5%:%timers5%
}
if(timers < 10)
{
   GuiControl, , TText5 ,  %timerm5%:0%timers5%
}
else
{
   GuiControl, , TText5 ,  %timerm5%:%timers5%
}
return

The_Main_Gui_StopStart1:
if(stopped = 0)
{
   Settimer, Stopwatch, off
   stopped = 1
}
else
{
   Settimer, Stopwatch, 999
   stopped = 0
}
return

The_Main_Gui_StopStart2:
if(stopped = 0)
{
   Settimer, Stopwatch1, off
   stopped = 1
}
else
{
   Settimer, Stopwatch1, 999
   stopped = 0
}
return

The_Main_Gui_StopStart3:
if(stopped = 0)
{
   Settimer, Stopwatch2, off
   stopped = 1
}
else
{
   Settimer, Stopwatch2, 999
   stopped = 0
}
return

The_Main_Gui_StopStart4:
if(stopped = 0)
{
   Settimer, Stopwatch3, off
   stopped = 1
}
else
{
   Settimer, Stopwatch3, 999
   stopped = 0
}
return

The_Main_Gui_StopStart5:
if(stopped = 0)
{
   Settimer, Stopwatch4, off
   stopped = 1
}
else
{
   Settimer, Stopwatch4, 999
   stopped = 0
}
return

The_Main_Gui_StopStart6:
if(stopped = 0)
{
   Settimer, Stopwatch5, off
   stopped = 1
}
else
{
   Settimer, Stopwatch5, 999
   stopped = 0
}
return

The_Main_Gui_Close:
Exitapp


ButtonPause:
if(stopped = 0)
{
   Settimer, Stopwatch, off
   stopped = 1
}
else
{
   Settimer, Stopwatch, 999
   stopped = 0
}
return

ButtonReset:
timerm := "00"
timers := "00"
GuiControl, , TText ,  %timerm%:%timers%
return

GuiClose:
GuiEscape:
ExitApp
return
and was able to wow my bosses thanks a lot now to add the file append feature.

THANKS AGAIN

 

4 some reason GUI is messed up on my puter and it don't work!



Xtra
  • Members
  • 954 posts
  • Last active: Jul 23 2016 09:04 PM
  • Joined: 29 Sep 2013

4 some reason GUI is messed up on my puter and it don't work!

 

Yep looks broken

 

The OP works.

 

I added

BackgroundTrans E0x20 

its flicker free now.

;Stopwatch.ahk

#NoEnv
#singleinstance force

timerm := "00"
timers := "00"
stopped := "0"

Gui, Add, Button, x2 y42 w80 h20 vPause, Pause
Gui, Add, Button, x82 y42 w80 h20 vReset, Reset
Gui, Add, Text, x67 y22 w60 h20 BackgroundTrans E0x20 vTText, %timerm%:%timers%
Gui, Show, h69 w165, Stopwatch
Settimer, Stopwatch, 1000
Return

Stopwatch:
timers += 1
if(timers > 59)
{
	timerm += 1
	timers := "0"
	GuiControl, , TText ,  %timerm%:%timers%
}
if(timers < 10)
{
	GuiControl, , TText ,  %timerm%:0%timers%
}
else
{
	GuiControl, , TText ,  %timerm%:%timers%
}
return

ButtonPause:
if(stopped = 0)
{
	Settimer, Stopwatch, off
	stopped = 1
}
else
{
	Settimer, Stopwatch, 999
	stopped = 0
}
return

ButtonReset:
timerm := "00"
timers := "00"
GuiControl, , TText ,  %timerm%:%timers%
return

GuiClose:
GuiEscape:
ExitApp
return


Guest10
  • Members
  • 1216 posts
  • Last active: Oct 30 2015 05:12 PM
  • Joined: 27 Oct 2012

I recommend:

http://www.autohotkey.com/forum/topic71384.html
http://www.autohotkey.com/board/topic/66380-multiple-countdown-timer-utility/