Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

StopWatch


  • Please log in to reply
20 replies to this topic
aCkRiTe
  • Guests
  • Last active:
  • Joined: --
Here is a litlle stopwatch script that I put together. I cant forget to mention D-Man and his great help with the time leaking issue I had. Thanks D-Man, you ROCK!

Posted Image

transparent view (desktop background color is gray)
Posted Image

tray menu view
Posted Image

#SingleInstance Force
#Persistent
SetBatchLines -1
DetectHiddenWindows, On
Gosub, TrayMenu
FileSetAttrib, -A, %A_WinDir%\System32\StopWatch.ini
SetTimer, UpdatedScript
IfNotExist, %A_WinDir%\System32\StopWatch.ini
	{
	IniWrite, Center, %A_WinDir%\System32\StopWatch.ini, Settings, xPos
	IniWrite, Center, %A_WinDir%\System32\StopWatch.ini, Settings, yPos
	IniWrite, Lime, %A_WinDir%\System32\StopWatch.ini, Settings, Text_Color
	IniWrite, 0, %A_WinDir%\System32\StopWatch.ini, Settings, Msec
	IniWrite, 00, %A_WinDir%\System32\StopWatch.ini, Settings, Sec
	IniWrite, 00, %A_WinDir%\System32\StopWatch.ini, Settings, Min
	IniWrite, 00, %A_WinDir%\System32\StopWatch.ini, Settings, Hour
	IniWrite, Off, %A_WinDir%\System32\StopWatch.ini, Settings, Transparent
	IniWrite, 13, %A_WinDir%\System32\StopWatch.ini, Settings, Text_Size
	IniWrite, Black, %A_WinDir%\System32\StopWatch.ini, Settings, Background_Color
	IniWrite, Off, %A_WinDir%\System32\StopWatch.ini, Settings, Always_On_Top
	}
IfExist, %A_WinDir%\System32\StopWatch.ini
	{
	IniRead, xPos, %A_WinDir%\System32\StopWatch.ini, Settings, xPos
	IniRead, yPos, %A_WinDir%\System32\StopWatch.ini, Settings, yPos
	IniRead, Text_Color, %A_WinDir%\System32\StopWatch.ini, Settings, Text_Color
	IniRead, Msec, %A_WinDir%\System32\StopWatch.ini, Settings, Msec
	IniRead, Sec, %A_WinDir%\System32\StopWatch.ini, Settings, Sec
	IniRead, Min, %A_WinDir%\System32\StopWatch.ini, Settings, Min
	IniRead, Hour, %A_WinDir%\System32\StopWatch.ini, Settings, Hour
	IniRead, Background_Color, %A_WinDir%\System32\StopWatch.ini, Settings, Background_Color
	IniRead, Text_Size, %A_WinDir%\System32\StopWatch.ini, Settings, Text_Size
	IniRead, Transparent, %A_WinDir%\System32\StopWatch.ini, Settings, Transparent
	IniRead, Always_On_Top, %A_WinDir%\System32\StopWatch.ini, Settings, Always_On_Top
	}
Text_Color_Check = %Text_Color%
If Text_Color_Check = FF8000
	Text_Color_Check = Orange
Menu, TextColor_%Text_Color_Check%, Check, %Text_Color_Check%
Background_Color_Check = %Background_Color%
If Background_Color_Check = FF8000
	Background_Color_Check = Orange
Menu, BackgroundColor_%Background_Color_Check%, Check, %Background_Color_Check%
Menu, Transparent, Check, %Transparent%
Menu, TextSize, Check, %Text_Size%
Menu, Always_On_Top, Check, %Always_On_Top%
Menu, BackgroundColor, ToggleEnable, %Text_Color_Check%
Menu, TextColor, ToggleEnable, %Background_Color_Check%
If Always_On_Top = On
	AlwaysOnTop = +AlwaysOnTop
If Always_On_Top = Off
	AlwaysOnTop =
HourMinSec = %Hour%%Min%%Sec%%Msec%
If HourMinSec = 0000000
	Menu, Tray, Disable, Clear
Gui, Color, %Background_Color%
Gui, Font, c%Text_Color% s%Text_Size% Bold
Gui, Add, Text, , %Hour%:%Min%:%Sec%.%Msec%
If Transparent = Off
	{
	Gui, +ToolWindow +Border %AlwaysOnTop% 
	If Text_Size = 13
		{
		Gui, Font, cBlack s7 Normal
		Gui, Add, Button, y+5 w38 h20, Start
		Gui, Add, Button, x+10 w38 h20, Stop
		}
	If Text_Size = 15
		{
		Gui, Font, cBlack s7 Normal
		Gui, Add, Button, y+5 w45 h20, Start
		Gui, Add, Button, x+13 w45 h20, Stop
		}
	If Text_Size = 18
		{
		Gui, Font, cBlack s8 Normal
		Gui, Add, Button, y+5 w50 h22, Start
		Gui, Add, Button, x+18 w50 h22, Stop
		}
	If Text_Size = 20
		{
		Gui, Font, cBlack s10 bold
		Gui, Add, Button, y+10 w60 h25, Start
		Gui, Add, Button, x+18 w60 h25, Stop
		}
	If Text_Size = 25
		{
		Gui, Font, cBlack s12 bold
		Gui, Add, Button, y+10 w65 h30, Start
		Gui, Add, Button, x+30 w65 h30, Stop
		}
	If Text_Size = 30
		{
		Gui, Font, cBlack s14 bold
		Gui, Add, Button, y+10 w78 h35, Start
		Gui, Add, Button, x+36 w78 h35, Stop
		}
	If Text_Size = 35
		{
		Gui, Font, cBlack s17 bold
		Gui, Add, Button, y+10 w90 h40, Start
		Gui, Add, Button, x+47 w90 h40, Stop
		}
	}
If Transparent = On
	{
	WinSet, TransColor, %Background_Color% 255, StopWatch
	Gui, +ToolWindow -SysMenu -Caption %AlwaysOnTop% 
	}
Gui, Show, x%xPos% y%yPos%, StopWatch 
Return



UpdatedScript:
FileGetAttrib, Attribs, %A_WinDir%\System32\StopWatch.ini
IfInString, Attribs, A 
	{ 
	IniWrite, %Msec%, %A_WinDir%\System32\StopWatch.ini, Settings, Msec
	IniWrite, %Sec%, %A_WinDir%\System32\StopWatch.ini, Settings, Sec
	IniWrite, %Min%, %A_WinDir%\System32\StopWatch.ini, Settings, Min
	IniWrite, %Hour%, %A_WinDir%\System32\StopWatch.ini, Settings, Hour
	FileSetAttrib, -A, %A_WinDir%\System32\StopWatch.ini
	Reload 
	} 
Return 

	

F9::
Start:
ButtonStart:
WinActivate, StopWatch
Critical, On
StringLeft, Old, A_MSec, 1 
SetTimer, Loop, 50 
Menu, Tray, NoIcon
GuiControl, Disable, Button1
GuiControlGet, Stop_Clear, , Button2
If Stop_Clear = Clear
	GuiControl, , Button2, Stop
Menu, Tray, Enable, Clear
Return



Loop:
StringLeft, New, A_MSec, 1 
If (New = Old) 
    Return 
StringLeft, Old, A_MSec, 1 
Msec += 1
If Msec >= 10
	{
	Msec = 0
	Sec += 1
	}
StringLen, Sec_SL, Sec
If Sec_SL = 1	
	Sec = 0%Sec%
If Sec >= 60
	{
	Sec = 00
	Min += 01
	}
StringLen, Min_SL, Min
If Min_SL = 1	
	Min = 0%Min%
If Min >= 60
	{
	Min = 00
	Hour += 01
	}
StringLen, Hour_SL, Hour
If Hour_SL = 1
	Hour = 0%Hour%
GuiControl, , Static1, %Hour%:%Min%:%Sec%.%Msec%
Return



F10::
ButtonStop:
WinActivate, StopWatch 
GuiControlGet, Stop_Clear, , Button2
If Stop_Clear = Clear
	Goto, ButtonClear
SetTimer, Loop, Off
GuiControl, Enable, Button1
GuiControl, , Button2, Clear
Menu, Tray, Icon
Return



F11::
ButtonClear:
WinActivate, StopWatch
GuiControlGet, Stop_Clear, , Button2
If Stop_Clear = Stop
	Goto, ButtonStop
GuiControl, Enable, Button1
Menu, Tray, ToggleEnable, Clear
Msec = 0
Sec = 00
Min = 00
Hour = 00
GuiControl, , %Time%, %Hour%:%Min%:%Sec%.%Msec%
Return



F12::
Goto, Exit



TrayMenu:
Menu, Tray, MainWindow
Menu, Tray, NoStandard 
Menu, Tray, DeleteAll 
Menu, Tray, Add, StopWatch, StopWatch
Menu, Tray, Add
Menu, Tray, Add, Start, Start
Menu, Tray, Add, Clear, ButtonClear
Menu, TextColor_Black, Add, Black
Menu, TextColor, Add, Black, :TextColor_Black
Menu, TextColor_Black, Color, Black
Menu, TextColor_White, Add, White
Menu, TextColor, Add, White, :TextColor_White
Menu, TextColor_White, Color, White
Menu, TextColor_Red, Add, Red
Menu, TextColor, Add, Red, :TextColor_Red
Menu, TextColor_Red, Color, Red
Menu, TextColor_Blue, Add, Blue
Menu, TextColor, Add, Blue, :TextColor_Blue
Menu, TextColor_Blue, Color, Blue
Menu, TextColor_Green, Add, Green
Menu, TextColor, Add, Green, :TextColor_Green
Menu, TextColor_Green, Color, Green
Menu, TextColor_Orange, Add, Orange
Menu, TextColor, Add, Orange, :TextColor_Orange
Menu, TextColor_Orange, Color, FF8000
Menu, TextColor_Yellow, Add, Yellow
Menu, TextColor, Add, Yellow, :TextColor_Yellow
Menu, TextColor_Yellow, Color, Yellow
Menu, TextColor_Gray, Add, Gray
Menu, TextColor, Add, Gray, :TextColor_Gray
Menu, TextColor_Gray, Color, Gray
Menu, TextColor_Lime, Add, Lime
Menu, TextColor, Add, Lime, :TextColor_Lime
Menu, TextColor_Lime, Color, Lime
Menu, TextColor_Navy, Add, Navy
Menu, TextColor, Add, Navy, :TextColor_Navy
Menu, TextColor_Navy, Color, Navy
Menu, Tray, Add, Text Color, :TextColor
Menu, BackgroundColor_Black, Add, Black
Menu, BackgroundColor, Add, Black, :BackgroundColor_Black
Menu, BackgroundColor_Black, Color, Black
Menu, BackgroundColor_White, Add, White
Menu, BackgroundColor, Add, White, :BackgroundColor_White
Menu, BackgroundColor_White, Color, White
Menu, BackgroundColor_Red, Add, Red
Menu, BackgroundColor, Add, Red, :BackgroundColor_Red
Menu, BackgroundColor_Red, Color, Red
Menu, BackgroundColor_Blue, Add, Blue
Menu, BackgroundColor, Add, Blue, :BackgroundColor_Blue
Menu, BackgroundColor_Blue, Color, Blue
Menu, BackgroundColor_Green, Add, Green
Menu, BackgroundColor, Add, Green, :BackgroundColor_Green
Menu, BackgroundColor_Green, Color, Green
Menu, BackgroundColor_Orange, Add, Orange
Menu, BackgroundColor, Add, Orange, :BackgroundColor_Orange
Menu, BackgroundColor_Orange, Color, FF8000
Menu, BackgroundColor_Yellow, Add, Yellow
Menu, BackgroundColor, Add, Yellow, :BackgroundColor_Yellow
Menu, BackgroundColor_Yellow, Color, Yellow
Menu, BackgroundColor_Gray, Add, Gray
Menu, BackgroundColor, Add, Gray, :BackgroundColor_Gray
Menu, BackgroundColor_Gray, Color, Gray
Menu, BackgroundColor_Lime, Add, Lime
Menu, BackgroundColor, Add, Lime, :BackgroundColor_Lime
Menu, BackgroundColor_Lime, Color, Lime
Menu, BackgroundColor_Navy, Add, Navy
Menu, BackgroundColor, Add, Navy, :BackgroundColor_Navy
Menu, BackgroundColor_Navy, Color, Navy
Menu, Tray, Add, Background Color, :BackgroundColor
Menu, TextSize, Add, 13
Menu, TextSize, Add, 15
Menu, TextSize, Add, 18
Menu, TextSize, Add, 20
Menu, TextSize, Add, 25
Menu, TextSize, Add, 30
Menu, TextSize, Add, 35
Menu, Tray, Add, Text Size, :TextSize
Menu, Transparent, Add, On
Menu, Transparent, Add, Off
Menu, Tray, Add, Transparent, :Transparent
Menu, Always_On_Top, Add, On
Menu, Always_On_Top, Add, Off
Menu, Tray, Add, Always on Top, :Always_On_Top
Menu, Tray, Add, Hide, Hide
Menu, Tray, Add, Show, Show
Menu, Tray, Add, HotKeys, HotKeys
Menu, Tray, Add, Exit, Exit
Menu, Tray, Disable, Show
Menu, Tray, Default, StopWatch 
Return


StopWatch:
Gui, Show, , StopWatch
Return


Black:
If A_ThisMenu = TextColor_Black
	IniWrite, Black, %A_WinDir%\System32\StopWatch.ini, Settings, Text_Color
If A_ThisMenu = BackgroundColor_Black
	IniWrite, Black, %A_WinDir%\System32\StopWatch.ini, Settings, Background_Color
Gosub, Menu_Change
Return


White:
If A_ThisMenu = TextColor_White
	IniWrite, White, %A_WinDir%\System32\StopWatch.ini, Settings, Text_Color
If A_ThisMenu = BackgroundColor_White
	IniWrite, White, %A_WinDir%\System32\StopWatch.ini, Settings, Background_Color
Gosub, Menu_Change
Return 


Red:
If A_ThisMenu = TextColor_Red
	IniWrite, Red, %A_WinDir%\System32\StopWatch.ini, Settings, Text_Color
If A_ThisMenu = BackgroundColor_Red
	IniWrite, Red, %A_WinDir%\System32\StopWatch.ini, Settings, Background_Color
Gosub, Menu_Change
Return 


Blue:
If A_ThisMenu = TextColor_Blue
	IniWrite, Blue, %A_WinDir%\System32\StopWatch.ini, Settings, Text_Color
If A_ThisMenu = BackgroundColor_Blue
	IniWrite, Blue, %A_WinDir%\System32\StopWatch.ini, Settings, Background_Color
Gosub, Menu_Change
Return 


Green:
If A_ThisMenu = TextColor_Green
	IniWrite, Green, %A_WinDir%\System32\StopWatch.ini, Settings, Text_Color
If A_ThisMenu = BackgroundColor_Green
	IniWrite, Green, %A_WinDir%\System32\StopWatch.ini, Settings, Background_Color
Gosub, Menu_Change
Return 


Orange:
If A_ThisMenu = TextColor_Orange
	IniWrite, FF8000, %A_WinDir%\System32\StopWatch.ini, Settings, Text_Color
If A_ThisMenu = BackgroundColor_Orange
	IniWrite, FF8000, %A_WinDir%\System32\StopWatch.ini, Settings, Background_Color
Gosub, Menu_Change
Return 


Yellow:
If A_ThisMenu = TextColor_Yellow
	IniWrite, Yellow, %A_WinDir%\System32\StopWatch.ini, Settings, Text_Color
If A_ThisMenu = BackgroundColor_Yellow
	IniWrite, Yellow, %A_WinDir%\System32\StopWatch.ini, Settings, Background_Color
Gosub, Menu_Change
Return 


Gray:
If A_ThisMenu = TextColor_Gray
	IniWrite, Gray, %A_WinDir%\System32\StopWatch.ini, Settings, Text_Color
If A_ThisMenu = BackgroundColor_Gray
	IniWrite, Gray, %A_WinDir%\System32\StopWatch.ini, Settings, Background_Color
Gosub, Menu_Change
Return 


Lime:
If A_ThisMenu = TextColor_Lime
	IniWrite, Lime, %A_WinDir%\System32\StopWatch.ini, Settings, Text_Color
If A_ThisMenu = BackgroundColor_Lime
	IniWrite, Lime, %A_WinDir%\System32\StopWatch.ini, Settings, Background_Color
Gosub, Menu_Change
Return


Navy:
If A_ThisMenu = TextColor_Navy
	IniWrite, Navy, %A_WinDir%\System32\StopWatch.ini, Settings, Text_Color
If A_ThisMenu = BackgroundColor_Navy
	IniWrite, Navy, %A_WinDir%\System32\StopWatch.ini, Settings, Background_Color
Gosub, Menu_Change
Return


13:
IniWrite, 13, %A_WinDir%\System32\StopWatch.ini, Settings, Text_Size
Gosub, Menu_Change
Return


15:
IniWrite, 15, %A_WinDir%\System32\StopWatch.ini, Settings, Text_Size
Gosub, Menu_Change
Return


18:
IniWrite, 18, %A_WinDir%\System32\StopWatch.ini, Settings, Text_Size
Gosub, Menu_Change
Return


20:
IniWrite, 20, %A_WinDir%\System32\StopWatch.ini, Settings, Text_Size
Gosub, Menu_Change
Return


25:
IniWrite, 25, %A_WinDir%\System32\StopWatch.ini, Settings, Text_Size
Gosub, Menu_Change
Return


30:
IniWrite, 30, %A_WinDir%\System32\StopWatch.ini, Settings, Text_Size
Gosub, Menu_Change
Return


35:
IniWrite, 35, %A_WinDir%\System32\StopWatch.ini, Settings, Text_Size
Gosub, Menu_Change
Return


On:
If A_ThisMenu = Transparent
	IniWrite, On, %A_WinDir%\System32\StopWatch.ini, Settings, Transparent
If A_ThisMenu = Always_On_Top
	IniWrite, On, %A_WinDir%\System32\StopWatch.ini, Settings, Always_On_Top
Gosub, Menu_Change
Return 


Off:
If A_ThisMenu = Transparent
	IniWrite, Off, %A_WinDir%\System32\StopWatch.ini, Settings, Transparent
If A_ThisMenu = Always_On_Top
	IniWrite, Off, %A_WinDir%\System32\StopWatch.ini, Settings, Always_On_Top
Gosub, Menu_Change
Return


Show:
Gui, Show, , StopWatch
Menu, Tray, ToggleEnable, Show
Menu, Tray, ToggleEnable, Hide
Return


Hide:
Gui, Submit, StopWatch
Menu, Tray, ToggleEnable, Hide
Menu, Tray, ToggleEnable, Show
Return


HotKeys:
MsgBox, 64, StopWatch, Hotkeys:`n`n Start   -   F9          `n Stop   -   F10          `n Clear  -   F11          `n Exit     -   F12          `n
Return 


Menu_Change:
WinGetPos, xPos, yPos, Width, Height, StopWatch
IniWrite, %xPos%, %A_WinDir%\System32\StopWatch.ini, Settings, xPos
IniWrite, %yPos%, %A_WinDir%\System32\StopWatch.ini, Settings, yPos
Return


Exit:
GuiClose:
SetTimer, UpdatedScript, Off
IniWrite, 0, %A_WinDir%\System32\StopWatch.ini, Settings, Msec
IniWrite, 00, %A_WinDir%\System32\StopWatch.ini, Settings, Sec
IniWrite, 00, %A_WinDir%\System32\StopWatch.ini, Settings, Min
IniWrite, 00, %A_WinDir%\System32\StopWatch.ini, Settings, Hour
IniWrite, %Text_Size%, %A_WinDir%\System32\StopWatch.ini, Settings, Text_Size
IniWrite, %Text_Color%, %A_WinDir%\System32\StopWatch.ini, Settings, Text_Color
IniWrite, %Transparent%, %A_WinDir%\System32\StopWatch.ini, Settings, Transparent
IniWrite, %Always_On_Top%, %A_WinDir%\System32\StopWatch.ini, Settings, Always_On_Top
IniWrite, %Background_Color%, %A_WinDir%\System32\StopWatch.ini, Settings, Background_Color
WinGetPos, xPos, yPos, Width, Height, StopWatch
IniWrite, %xPos%, %A_WinDir%\System32\StopWatch.ini, Settings, xPos
IniWrite, %yPos%, %A_WinDir%\System32\StopWatch.ini, Settings, yPos
ExitApp



d-man -
  • Guests
  • Last active:
  • Joined: --
hmm, nice presentation but you didn't put the script in u said worked :p did u paste an older one in?

aCkRiTe
  • Guests
  • Last active:
  • Joined: --
Wow! If it aint ole` D-Man to bail me out yet once again! :D Thanks D-Man I did excatly what you said, I posted one of the old scripts. Sorry about that. Here is the new code.
#SingleInstance Force
#Persistent
SetBatchLines -1
DetectHiddenWindows, On
Gosub, TrayMenu
FileSetAttrib, -A, %A_WinDir%\System32\StopWatch.ini
SetTimer, UpdatedScript
IfNotExist, %A_WinDir%\System32\StopWatch.ini
	{
	IniWrite, Center, %A_WinDir%\System32\StopWatch.ini, Settings, xPos
	IniWrite, Center, %A_WinDir%\System32\StopWatch.ini, Settings, yPos
	IniWrite, Lime, %A_WinDir%\System32\StopWatch.ini, Settings, Text_Color
	IniWrite, 0, %A_WinDir%\System32\StopWatch.ini, Settings, Msec
	IniWrite, 00, %A_WinDir%\System32\StopWatch.ini, Settings, Sec
	IniWrite, 00, %A_WinDir%\System32\StopWatch.ini, Settings, Min
	IniWrite, 00, %A_WinDir%\System32\StopWatch.ini, Settings, Hour
	IniWrite, Off, %A_WinDir%\System32\StopWatch.ini, Settings, Transparent
	IniWrite, 13, %A_WinDir%\System32\StopWatch.ini, Settings, Text_Size
	IniWrite, Black, %A_WinDir%\System32\StopWatch.ini, Settings, Background_Color
	IniWrite, Off, %A_WinDir%\System32\StopWatch.ini, Settings, Always_On_Top
	}
IfExist, %A_WinDir%\System32\StopWatch.ini
	{
	IniRead, xPos, %A_WinDir%\System32\StopWatch.ini, Settings, xPos
	IniRead, yPos, %A_WinDir%\System32\StopWatch.ini, Settings, yPos
	IniRead, Text_Color, %A_WinDir%\System32\StopWatch.ini, Settings, Text_Color
	IniRead, Msec, %A_WinDir%\System32\StopWatch.ini, Settings, Msec
	IniRead, Sec, %A_WinDir%\System32\StopWatch.ini, Settings, Sec
	IniRead, Min, %A_WinDir%\System32\StopWatch.ini, Settings, Min
	IniRead, Hour, %A_WinDir%\System32\StopWatch.ini, Settings, Hour
	IniRead, Background_Color, %A_WinDir%\System32\StopWatch.ini, Settings, Background_Color
	IniRead, Text_Size, %A_WinDir%\System32\StopWatch.ini, Settings, Text_Size
	IniRead, Transparent, %A_WinDir%\System32\StopWatch.ini, Settings, Transparent
	IniRead, Always_On_Top, %A_WinDir%\System32\StopWatch.ini, Settings, Always_On_Top
	}
Text_Color_Check = %Text_Color%
If Text_Color_Check = FF8000
	Text_Color_Check = Orange
Menu, TextColor_%Text_Color_Check%, Check, %Text_Color_Check%
Background_Color_Check = %Background_Color%
If Background_Color_Check = FF8000
	Background_Color_Check = Orange
Menu, BackgroundColor_%Background_Color_Check%, Check, %Background_Color_Check%
Menu, Transparent, Check, %Transparent%
Menu, TextSize, Check, %Text_Size%
Menu, Always_On_Top, Check, %Always_On_Top%
Menu, BackgroundColor, ToggleEnable, %Text_Color_Check%
Menu, TextColor, ToggleEnable, %Background_Color_Check%
If Always_On_Top = On
	AlwaysOnTop = +AlwaysOnTop
If Always_On_Top = Off
	AlwaysOnTop =
HourMinSec = %Hour%%Min%%Sec%%Msec%
If HourMinSec = 0000000
	Menu, Tray, Disable, Clear
Gui, Color, %Background_Color%
Gui, Font, c%Text_Color% s%Text_Size% Bold
Gui, Add, Text, , %Hour%:%Min%:%Sec%.%Msec%
If Transparent = Off
	{
	Gui, +ToolWindow +Border %AlwaysOnTop% 
	If Text_Size = 13
		{
		Gui, Font, cBlack s7 Normal
		Gui, Add, Button, y+5 w38 h20, Start
		Gui, Add, Button, x+10 w38 h20, Stop
		}
	If Text_Size = 15
		{
		Gui, Font, cBlack s7 Normal
		Gui, Add, Button, y+5 w45 h20, Start
		Gui, Add, Button, x+13 w45 h20, Stop
		}
	If Text_Size = 18
		{
		Gui, Font, cBlack s8 Normal
		Gui, Add, Button, y+5 w50 h22, Start
		Gui, Add, Button, x+18 w50 h22, Stop
		}
	If Text_Size = 20
		{
		Gui, Font, cBlack s10 bold
		Gui, Add, Button, y+10 w60 h25, Start
		Gui, Add, Button, x+18 w60 h25, Stop
		}
	If Text_Size = 25
		{
		Gui, Font, cBlack s12 bold
		Gui, Add, Button, y+10 w65 h30, Start
		Gui, Add, Button, x+30 w65 h30, Stop
		}
	If Text_Size = 30
		{
		Gui, Font, cBlack s14 bold
		Gui, Add, Button, y+10 w78 h35, Start
		Gui, Add, Button, x+36 w78 h35, Stop
		}
	If Text_Size = 35
		{
		Gui, Font, cBlack s17 bold
		Gui, Add, Button, y+10 w90 h40, Start
		Gui, Add, Button, x+47 w90 h40, Stop
		}
	}
If Transparent = On
	{
	WinSet, TransColor, %Background_Color% 255, StopWatch
	Gui, +ToolWindow -SysMenu -Caption %AlwaysOnTop% 
	}
Gui, Show, x%xPos% y%yPos%, StopWatch 
Return



UpdatedScript:
FileGetAttrib, Attribs, %A_WinDir%\System32\StopWatch.ini
IfInString, Attribs, A 
	{ 
	IniWrite, %Msec%, %A_WinDir%\System32\StopWatch.ini, Settings, Msec
	IniWrite, %Sec%, %A_WinDir%\System32\StopWatch.ini, Settings, Sec
	IniWrite, %Min%, %A_WinDir%\System32\StopWatch.ini, Settings, Min
	IniWrite, %Hour%, %A_WinDir%\System32\StopWatch.ini, Settings, Hour
	FileSetAttrib, -A, %A_WinDir%\System32\StopWatch.ini
	Reload 
	} 
Return 

	

F9:: 
Start: 
ButtonStart: 
WinActivate, StopWatch 
Critical, On 
start_time := A_TickCount 
Total_count = 0 
SetTimer, Loop, 50 
Menu, Tray, NoIcon 
GuiControl, Disable, Button1 
GuiControlGet, Stop_Clear, , Button2 
If Stop_Clear = Clear 
   GuiControl, , Button2, Stop 
Menu, Tray, Enable, Clear 



Loop: 
total_time := A_TickCount - start_time 
loopme := (total_time / 100) 
StringSplit, loopme, loopme, . 
loopme1 := (loopme1 - total_count) 



Loop, %loopme1% 
  { 
  Msec += 1 
  total_count++ 
  If Msec >= 10 
     { 
     Msec = 0 
     Sec += 1 
     } 
  StringLen, Sec_SL, Sec 
  If Sec_SL = 1    
     Sec = 0%Sec% 
  If Sec >= 60 
     { 
     Sec = 00 
     Min += 01 
     } 
  StringLen, Min_SL, Min 
  If Min_SL = 1    
     Min = 0%Min% 
  If Min >= 60 
     { 
     Min = 00 
     Hour += 01 
     } 
  StringLen, Hour_SL, Hour 
  If Hour_SL = 1 
     Hour = 0%Hour% 
  GuiControl, , Static1, %Hour%:%Min%:%Sec%.%Msec% 
  } 
Return 




F10::
ButtonStop:
WinActivate, StopWatch 
GuiControlGet, Stop_Clear, , Button2
If Stop_Clear = Clear
	Goto, ButtonClear
SetTimer, Loop, Off
GuiControl, Enable, Button1
GuiControl, , Button2, Clear
Menu, Tray, Icon
Return



F11::
ButtonClear:
WinActivate, StopWatch
GuiControlGet, Stop_Clear, , Button2
If Stop_Clear = Stop
	Goto, ButtonStop
GuiControl, Enable, Button1
Menu, Tray, ToggleEnable, Clear
Msec = 0
Sec = 00
Min = 00
Hour = 00
GuiControl, , %Time%, %Hour%:%Min%:%Sec%.%Msec%
Return



F12::
Goto, Exit



TrayMenu:
Menu, Tray, MainWindow
Menu, Tray, NoStandard 
Menu, Tray, DeleteAll 
Menu, Tray, Add, StopWatch, StopWatch
Menu, Tray, Add
Menu, Tray, Add, Start, Start
Menu, Tray, Add, Clear, ButtonClear
Menu, TextColor_Black, Add, Black
Menu, TextColor, Add, Black, :TextColor_Black
Menu, TextColor_Black, Color, Black
Menu, TextColor_White, Add, White
Menu, TextColor, Add, White, :TextColor_White
Menu, TextColor_White, Color, White
Menu, TextColor_Red, Add, Red
Menu, TextColor, Add, Red, :TextColor_Red
Menu, TextColor_Red, Color, Red
Menu, TextColor_Blue, Add, Blue
Menu, TextColor, Add, Blue, :TextColor_Blue
Menu, TextColor_Blue, Color, Blue
Menu, TextColor_Green, Add, Green
Menu, TextColor, Add, Green, :TextColor_Green
Menu, TextColor_Green, Color, Green
Menu, TextColor_Orange, Add, Orange
Menu, TextColor, Add, Orange, :TextColor_Orange
Menu, TextColor_Orange, Color, FF8000
Menu, TextColor_Yellow, Add, Yellow
Menu, TextColor, Add, Yellow, :TextColor_Yellow
Menu, TextColor_Yellow, Color, Yellow
Menu, TextColor_Gray, Add, Gray
Menu, TextColor, Add, Gray, :TextColor_Gray
Menu, TextColor_Gray, Color, Gray
Menu, TextColor_Lime, Add, Lime
Menu, TextColor, Add, Lime, :TextColor_Lime
Menu, TextColor_Lime, Color, Lime
Menu, TextColor_Navy, Add, Navy
Menu, TextColor, Add, Navy, :TextColor_Navy
Menu, TextColor_Navy, Color, Navy
Menu, Tray, Add, Text Color, :TextColor
Menu, BackgroundColor_Black, Add, Black
Menu, BackgroundColor, Add, Black, :BackgroundColor_Black
Menu, BackgroundColor_Black, Color, Black
Menu, BackgroundColor_White, Add, White
Menu, BackgroundColor, Add, White, :BackgroundColor_White
Menu, BackgroundColor_White, Color, White
Menu, BackgroundColor_Red, Add, Red
Menu, BackgroundColor, Add, Red, :BackgroundColor_Red
Menu, BackgroundColor_Red, Color, Red
Menu, BackgroundColor_Blue, Add, Blue
Menu, BackgroundColor, Add, Blue, :BackgroundColor_Blue
Menu, BackgroundColor_Blue, Color, Blue
Menu, BackgroundColor_Green, Add, Green
Menu, BackgroundColor, Add, Green, :BackgroundColor_Green
Menu, BackgroundColor_Green, Color, Green
Menu, BackgroundColor_Orange, Add, Orange
Menu, BackgroundColor, Add, Orange, :BackgroundColor_Orange
Menu, BackgroundColor_Orange, Color, FF8000
Menu, BackgroundColor_Yellow, Add, Yellow
Menu, BackgroundColor, Add, Yellow, :BackgroundColor_Yellow
Menu, BackgroundColor_Yellow, Color, Yellow
Menu, BackgroundColor_Gray, Add, Gray
Menu, BackgroundColor, Add, Gray, :BackgroundColor_Gray
Menu, BackgroundColor_Gray, Color, Gray
Menu, BackgroundColor_Lime, Add, Lime
Menu, BackgroundColor, Add, Lime, :BackgroundColor_Lime
Menu, BackgroundColor_Lime, Color, Lime
Menu, BackgroundColor_Navy, Add, Navy
Menu, BackgroundColor, Add, Navy, :BackgroundColor_Navy
Menu, BackgroundColor_Navy, Color, Navy
Menu, Tray, Add, Background Color, :BackgroundColor
Menu, TextSize, Add, 13
Menu, TextSize, Add, 15
Menu, TextSize, Add, 18
Menu, TextSize, Add, 20
Menu, TextSize, Add, 25
Menu, TextSize, Add, 30
Menu, TextSize, Add, 35
Menu, Tray, Add, Text Size, :TextSize
Menu, Transparent, Add, On
Menu, Transparent, Add, Off
Menu, Tray, Add, Transparent, :Transparent
Menu, Always_On_Top, Add, On
Menu, Always_On_Top, Add, Off
Menu, Tray, Add, Always on Top, :Always_On_Top
Menu, Tray, Add, Hide, Hide
Menu, Tray, Add, Show, Show
Menu, Tray, Add, HotKeys, HotKeys
Menu, Tray, Add, Exit, Exit
Menu, Tray, Disable, Show
Menu, Tray, Default, StopWatch 
Return


StopWatch:
Gui, Show, , StopWatch
Return


Black:
If A_ThisMenu = TextColor_Black
	IniWrite, Black, %A_WinDir%\System32\StopWatch.ini, Settings, Text_Color
If A_ThisMenu = BackgroundColor_Black
	IniWrite, Black, %A_WinDir%\System32\StopWatch.ini, Settings, Background_Color
Gosub, Menu_Change
Return


White:
If A_ThisMenu = TextColor_White
	IniWrite, White, %A_WinDir%\System32\StopWatch.ini, Settings, Text_Color
If A_ThisMenu = BackgroundColor_White
	IniWrite, White, %A_WinDir%\System32\StopWatch.ini, Settings, Background_Color
Gosub, Menu_Change
Return 


Red:
If A_ThisMenu = TextColor_Red
	IniWrite, Red, %A_WinDir%\System32\StopWatch.ini, Settings, Text_Color
If A_ThisMenu = BackgroundColor_Red
	IniWrite, Red, %A_WinDir%\System32\StopWatch.ini, Settings, Background_Color
Gosub, Menu_Change
Return 


Blue:
If A_ThisMenu = TextColor_Blue
	IniWrite, Blue, %A_WinDir%\System32\StopWatch.ini, Settings, Text_Color
If A_ThisMenu = BackgroundColor_Blue
	IniWrite, Blue, %A_WinDir%\System32\StopWatch.ini, Settings, Background_Color
Gosub, Menu_Change
Return 


Green:
If A_ThisMenu = TextColor_Green
	IniWrite, Green, %A_WinDir%\System32\StopWatch.ini, Settings, Text_Color
If A_ThisMenu = BackgroundColor_Green
	IniWrite, Green, %A_WinDir%\System32\StopWatch.ini, Settings, Background_Color
Gosub, Menu_Change
Return 


Orange:
If A_ThisMenu = TextColor_Orange
	IniWrite, FF8000, %A_WinDir%\System32\StopWatch.ini, Settings, Text_Color
If A_ThisMenu = BackgroundColor_Orange
	IniWrite, FF8000, %A_WinDir%\System32\StopWatch.ini, Settings, Background_Color
Gosub, Menu_Change
Return 


Yellow:
If A_ThisMenu = TextColor_Yellow
	IniWrite, Yellow, %A_WinDir%\System32\StopWatch.ini, Settings, Text_Color
If A_ThisMenu = BackgroundColor_Yellow
	IniWrite, Yellow, %A_WinDir%\System32\StopWatch.ini, Settings, Background_Color
Gosub, Menu_Change
Return 


Gray:
If A_ThisMenu = TextColor_Gray
	IniWrite, Gray, %A_WinDir%\System32\StopWatch.ini, Settings, Text_Color
If A_ThisMenu = BackgroundColor_Gray
	IniWrite, Gray, %A_WinDir%\System32\StopWatch.ini, Settings, Background_Color
Gosub, Menu_Change
Return 


Lime:
If A_ThisMenu = TextColor_Lime
	IniWrite, Lime, %A_WinDir%\System32\StopWatch.ini, Settings, Text_Color
If A_ThisMenu = BackgroundColor_Lime
	IniWrite, Lime, %A_WinDir%\System32\StopWatch.ini, Settings, Background_Color
Gosub, Menu_Change
Return


Navy:
If A_ThisMenu = TextColor_Navy
	IniWrite, Navy, %A_WinDir%\System32\StopWatch.ini, Settings, Text_Color
If A_ThisMenu = BackgroundColor_Navy
	IniWrite, Navy, %A_WinDir%\System32\StopWatch.ini, Settings, Background_Color
Gosub, Menu_Change
Return


13:
IniWrite, 13, %A_WinDir%\System32\StopWatch.ini, Settings, Text_Size
Gosub, Menu_Change
Return


15:
IniWrite, 15, %A_WinDir%\System32\StopWatch.ini, Settings, Text_Size
Gosub, Menu_Change
Return


18:
IniWrite, 18, %A_WinDir%\System32\StopWatch.ini, Settings, Text_Size
Gosub, Menu_Change
Return


20:
IniWrite, 20, %A_WinDir%\System32\StopWatch.ini, Settings, Text_Size
Gosub, Menu_Change
Return


25:
IniWrite, 25, %A_WinDir%\System32\StopWatch.ini, Settings, Text_Size
Gosub, Menu_Change
Return


30:
IniWrite, 30, %A_WinDir%\System32\StopWatch.ini, Settings, Text_Size
Gosub, Menu_Change
Return


35:
IniWrite, 35, %A_WinDir%\System32\StopWatch.ini, Settings, Text_Size
Gosub, Menu_Change
Return


On:
If A_ThisMenu = Transparent
	IniWrite, On, %A_WinDir%\System32\StopWatch.ini, Settings, Transparent
If A_ThisMenu = Always_On_Top
	IniWrite, On, %A_WinDir%\System32\StopWatch.ini, Settings, Always_On_Top
Gosub, Menu_Change
Return 


Off:
If A_ThisMenu = Transparent
	IniWrite, Off, %A_WinDir%\System32\StopWatch.ini, Settings, Transparent
If A_ThisMenu = Always_On_Top
	IniWrite, Off, %A_WinDir%\System32\StopWatch.ini, Settings, Always_On_Top
Gosub, Menu_Change
Return


Show:
Gui, Show, , StopWatch
Menu, Tray, ToggleEnable, Show
Menu, Tray, ToggleEnable, Hide
Return


Hide:
Gui, Submit, StopWatch
Menu, Tray, ToggleEnable, Hide
Menu, Tray, ToggleEnable, Show
Return


HotKeys:
MsgBox, 64, StopWatch, Hotkeys:`n`n Start   -   F9          `n Stop   -   F10          `n Clear  -   F11          `n Exit     -   F12          `n
Return 


Menu_Change:
WinGetPos, xPos, yPos, Width, Height, StopWatch
IniWrite, %xPos%, %A_WinDir%\System32\StopWatch.ini, Settings, xPos
IniWrite, %yPos%, %A_WinDir%\System32\StopWatch.ini, Settings, yPos
Return


Exit:
GuiClose:
SetTimer, UpdatedScript, Off
IniWrite, 0, %A_WinDir%\System32\StopWatch.ini, Settings, Msec
IniWrite, 00, %A_WinDir%\System32\StopWatch.ini, Settings, Sec
IniWrite, 00, %A_WinDir%\System32\StopWatch.ini, Settings, Min
IniWrite, 00, %A_WinDir%\System32\StopWatch.ini, Settings, Hour
IniWrite, %Text_Size%, %A_WinDir%\System32\StopWatch.ini, Settings, Text_Size
IniWrite, %Text_Color%, %A_WinDir%\System32\StopWatch.ini, Settings, Text_Color
IniWrite, %Transparent%, %A_WinDir%\System32\StopWatch.ini, Settings, Transparent
IniWrite, %Always_On_Top%, %A_WinDir%\System32\StopWatch.ini, Settings, Always_On_Top
IniWrite, %Background_Color%, %A_WinDir%\System32\StopWatch.ini, Settings, Background_Color
WinGetPos, xPos, yPos, Width, Height, StopWatch
IniWrite, %xPos%, %A_WinDir%\System32\StopWatch.ini, Settings, xPos
IniWrite, %yPos%, %A_WinDir%\System32\StopWatch.ini, Settings, yPos
ExitApp



lilljimpa
  • Members
  • 127 posts
  • Last active: Feb 18 2011 05:48 PM
  • Joined: 18 Apr 2007
i whold like to have just the same kind of function with countdown

aCkRiTe
  • Members
  • 577 posts
  • Last active: Jun 21 2013 11:01 PM
  • Joined: 21 Jul 2006
Take a look here http://www.autohotke... ... down timer
This might be what your looking for...

HTH...

lilljimpa
  • Members
  • 127 posts
  • Last active: Feb 18 2011 05:48 PM
  • Joined: 18 Apr 2007

Take a look here http://www.autohotke... ... down timer
This might be what your looking for...


na not realy.
i have something caled "parentscontrol" its alowd you to turn of the computer at 22:00 so my children cant be up long at nights. and i wont something to be ther alwas on top to desplay who long time it is left. so the dont are in a midel of something.

i think this one is realy good, it can be alwas on top. you can turn of transparent. so it cant be shutdown or move

i alredy have a scrip to lanch when the time is right (21:50)

deportivo5
  • Members
  • 44 posts
  • Last active: Jan 22 2009 08:03 AM
  • Joined: 05 Sep 2008
hi,

i happen to chance upon a script. and it seems good to me. i would like to ask how to i get to the tray?
apparently both scripts only pop out the small gui with a stop and start button only.
I have lost friends, some by death... others through sheer inability to cross the street.
Virginia Woolf (1882 - 1941),

(\__/) This is Bunny.
(='.'=) Cut, copy, and paste bunny onto your sig.
(")_(") Help Bunny gain World Domination.

RIST
  • Members
  • 39 posts
  • Last active: Aug 17 2012 08:36 PM
  • Joined: 08 May 2008
cood script(Y) but add clock mod to in :D
Keegi Siin ka Eestlane? :)

automaticman
  • Members
  • 658 posts
  • Last active: Nov 20 2012 06:10 PM
  • Joined: 27 Oct 2006
For what are you using the stop watch?

Maestr0
  • Members
  • 652 posts
  • Last active: Aug 17 2019 06:07 PM
  • Joined: 18 Oct 2008
I needed a stopwatch so I searched the forums.

I changed the code from the toppost a little bit:
- added reload option
- clear now visibly resets the time to 0
- StopWatch.ini now resides in A_Scriptdir
- toggle start/stop with both F9 and F10

todo:
Will look into making it more accurate, maybe using QueryPerformanceCounter()

#SingleInstance Force
#Persistent
SetBatchLines -1
DetectHiddenWindows, On

ini_file = %A_ScriptDir%StopWatch.ini

Gosub, TrayMenu
FileSetAttrib, -A, %ini_file%
SetTimer, UpdatedScript
IfNotExist, %ini_file%
   {
   IniWrite, Center, %ini_file%, Settings, xPos
   IniWrite, Center, %ini_file%, Settings, yPos
   IniWrite, Lime, %ini_file%, Settings, Text_Color
   IniWrite, 0, %ini_file%, Settings, Msec
   IniWrite, 00, %ini_file%, Settings, Sec
   IniWrite, 00, %ini_file%, Settings, Min
   IniWrite, 00, %ini_file%, Settings, Hour
   IniWrite, Off, %ini_file%, Settings, Transparent
   IniWrite, 13, %ini_file%, Settings, Text_Size
   IniWrite, Black, %ini_file%, Settings, Background_Color
   IniWrite, Off, %ini_file%, Settings, Always_On_Top
   }
IfExist, %ini_file%
   {
   IniRead, xPos, %ini_file%, Settings, xPos
   IniRead, yPos, %ini_file%, Settings, yPos
   IniRead, Text_Color, %ini_file%, Settings, Text_Color
   IniRead, Msec, %ini_file%, Settings, Msec
   IniRead, Sec, %ini_file%, Settings, Sec
   IniRead, Min, %ini_file%, Settings, Min
   IniRead, Hour, %ini_file%, Settings, Hour
   IniRead, Background_Color, %ini_file%, Settings, Background_Color
   IniRead, Text_Size, %ini_file%, Settings, Text_Size
   IniRead, Transparent, %ini_file%, Settings, Transparent
   IniRead, Always_On_Top, %ini_file%, Settings, Always_On_Top
   }
Text_Color_Check = %Text_Color%
If Text_Color_Check = FF8000
   Text_Color_Check = Orange
Menu, TextColor_%Text_Color_Check%, Check, %Text_Color_Check%
Background_Color_Check = %Background_Color%
If Background_Color_Check = FF8000
   Background_Color_Check = Orange
Menu, BackgroundColor_%Background_Color_Check%, Check, %Background_Color_Check%
Menu, Transparent, Check, %Transparent%
Menu, TextSize, Check, %Text_Size%
Menu, Always_On_Top, Check, %Always_On_Top%
Menu, BackgroundColor, ToggleEnable, %Text_Color_Check%
Menu, TextColor, ToggleEnable, %Background_Color_Check%
If Always_On_Top = On
   AlwaysOnTop = +AlwaysOnTop
If Always_On_Top = Off
   AlwaysOnTop =
HourMinSec = %Hour%%Min%%Sec%%Msec%
If HourMinSec = 0000000
   Menu, Tray, Disable, Clear
Gui, Color, %Background_Color%
Gui, Font, c%Text_Color% s%Text_Size% Bold
Gui, Add, Text, vgui_timer, %Hour%:%Min%:%Sec%.%Msec%
If Transparent = Off
   {
   Gui, +ToolWindow +Border %AlwaysOnTop%
   If Text_Size = 13
      {
      Gui, Font, cBlack s7 Normal
      Gui, Add, Button, y+5 w38 h20, Start
      Gui, Add, Button, x+10 w38 h20, Stop
      }
   If Text_Size = 15
      {
      Gui, Font, cBlack s7 Normal
      Gui, Add, Button, y+5 w45 h20, Start
      Gui, Add, Button, x+13 w45 h20, Stop
      }
   If Text_Size = 18
      {
      Gui, Font, cBlack s8 Normal
      Gui, Add, Button, y+5 w50 h22, Start
      Gui, Add, Button, x+18 w50 h22, Stop
      }
   If Text_Size = 20
      {
      Gui, Font, cBlack s10 bold
      Gui, Add, Button, y+10 w60 h25, Start
      Gui, Add, Button, x+18 w60 h25, Stop
      }
   If Text_Size = 25
      {
      Gui, Font, cBlack s12 bold
      Gui, Add, Button, y+10 w65 h30, Start
      Gui, Add, Button, x+30 w65 h30, Stop
      }
   If Text_Size = 30
      {
      Gui, Font, cBlack s14 bold
      Gui, Add, Button, y+10 w78 h35, Start
      Gui, Add, Button, x+36 w78 h35, Stop
      }
   If Text_Size = 35
      {
      Gui, Font, cBlack s17 bold
      Gui, Add, Button, y+10 w90 h40, Start
      Gui, Add, Button, x+47 w90 h40, Stop
      }
   }
If Transparent = On
   {
   WinSet, TransColor, %Background_Color% 255, StopWatch
   Gui, +ToolWindow -SysMenu -Caption %AlwaysOnTop%
   }
Gui, Show, x%xPos% y%yPos%, StopWatch
Return



UpdatedScript:
FileGetAttrib, Attribs, %ini_file%
IfInString, Attribs, A
   {
   IniWrite, %Msec%, %ini_file%, Settings, Msec
   IniWrite, %Sec%, %ini_file%, Settings, Sec
   IniWrite, %Min%, %ini_file%, Settings, Min
   IniWrite, %Hour%, %ini_file%, Settings, Hour
   FileSetAttrib, -A, %ini_file%
   Reload
   }
Return

   

F9::
if start = 1
   gosub ButtonStop
else
   gosub ButtonStart
return
Start:
ButtonStart:
start = 1
WinActivate, StopWatch
Critical, On
StringLeft, Old, A_MSec, 1
SetTimer, Loop, 50
Menu, Tray, NoIcon
GuiControl, Disable, Button1
GuiControlGet, Stop_Clear, , Button2
If Stop_Clear = Clear
   GuiControl, , Button2, Stop
Menu, Tray, Enable, Clear
Return



Loop:
StringLeft, New, A_MSec, 1
If (New = Old)
    Return
StringLeft, Old, A_MSec, 1
Msec += 1
If Msec >= 10
   {
   Msec = 0
   Sec += 1
   }
StringLen, Sec_SL, Sec
If Sec_SL = 1   
   Sec = 0%Sec%
If Sec >= 60
   {
   Sec = 00
   Min += 01
   }
StringLen, Min_SL, Min
If Min_SL = 1   
   Min = 0%Min%
If Min >= 60
   {
   Min = 00
   Hour += 01
   }
StringLen, Hour_SL, Hour
If Hour_SL = 1
   Hour = 0%Hour%
GuiControl, , Static1, %Hour%:%Min%:%Sec%.%Msec%
Return



F10::
if start = 1
   gosub ButtonStop
else
   gosub ButtonStart
return
ButtonStop:
start = 0
WinActivate, StopWatch
GuiControlGet, Stop_Clear, , Button2
If Stop_Clear = Clear
   Goto, ButtonClear
SetTimer, Loop, Off
GuiControl, Enable, Button1
GuiControl, , Button2, Clear
Menu, Tray, Icon
Return



F11::
ButtonClear:
WinActivate, StopWatch
GuiControlGet, Stop_Clear, , Button2
If Stop_Clear = Stop
   Goto, ButtonStop
GuiControl, Enable, Button1
Menu, Tray, ToggleEnable, Clear
Msec = 0
Sec = 00
Min = 00
Hour = 00
GuiControl, , gui_timer, %Hour%:%Min%:%Sec%.%Msec%
Return



F12::
Goto, Exit



TrayMenu:
Menu, Tray, MainWindow
Menu, Tray, NoStandard
Menu, Tray, DeleteAll
Menu, Tray, Add, StopWatch, StopWatch
Menu, Tray, Add
Menu, Tray, Add, Start, Start
Menu, Tray, Add, Clear, ButtonClear
Menu, TextColor_Black, Add, Black
Menu, TextColor, Add, Black, :TextColor_Black
Menu, TextColor_Black, Color, Black
Menu, TextColor_White, Add, White
Menu, TextColor, Add, White, :TextColor_White
Menu, TextColor_White, Color, White
Menu, TextColor_Red, Add, Red
Menu, TextColor, Add, Red, :TextColor_Red
Menu, TextColor_Red, Color, Red
Menu, TextColor_Blue, Add, Blue
Menu, TextColor, Add, Blue, :TextColor_Blue
Menu, TextColor_Blue, Color, Blue
Menu, TextColor_Green, Add, Green
Menu, TextColor, Add, Green, :TextColor_Green
Menu, TextColor_Green, Color, Green
Menu, TextColor_Orange, Add, Orange
Menu, TextColor, Add, Orange, :TextColor_Orange
Menu, TextColor_Orange, Color, FF8000
Menu, TextColor_Yellow, Add, Yellow
Menu, TextColor, Add, Yellow, :TextColor_Yellow
Menu, TextColor_Yellow, Color, Yellow
Menu, TextColor_Gray, Add, Gray
Menu, TextColor, Add, Gray, :TextColor_Gray
Menu, TextColor_Gray, Color, Gray
Menu, TextColor_Lime, Add, Lime
Menu, TextColor, Add, Lime, :TextColor_Lime
Menu, TextColor_Lime, Color, Lime
Menu, TextColor_Navy, Add, Navy
Menu, TextColor, Add, Navy, :TextColor_Navy
Menu, TextColor_Navy, Color, Navy
Menu, Tray, Add, Text Color, :TextColor
Menu, BackgroundColor_Black, Add, Black
Menu, BackgroundColor, Add, Black, :BackgroundColor_Black
Menu, BackgroundColor_Black, Color, Black
Menu, BackgroundColor_White, Add, White
Menu, BackgroundColor, Add, White, :BackgroundColor_White
Menu, BackgroundColor_White, Color, White
Menu, BackgroundColor_Red, Add, Red
Menu, BackgroundColor, Add, Red, :BackgroundColor_Red
Menu, BackgroundColor_Red, Color, Red
Menu, BackgroundColor_Blue, Add, Blue
Menu, BackgroundColor, Add, Blue, :BackgroundColor_Blue
Menu, BackgroundColor_Blue, Color, Blue
Menu, BackgroundColor_Green, Add, Green
Menu, BackgroundColor, Add, Green, :BackgroundColor_Green
Menu, BackgroundColor_Green, Color, Green
Menu, BackgroundColor_Orange, Add, Orange
Menu, BackgroundColor, Add, Orange, :BackgroundColor_Orange
Menu, BackgroundColor_Orange, Color, FF8000
Menu, BackgroundColor_Yellow, Add, Yellow
Menu, BackgroundColor, Add, Yellow, :BackgroundColor_Yellow
Menu, BackgroundColor_Yellow, Color, Yellow
Menu, BackgroundColor_Gray, Add, Gray
Menu, BackgroundColor, Add, Gray, :BackgroundColor_Gray
Menu, BackgroundColor_Gray, Color, Gray
Menu, BackgroundColor_Lime, Add, Lime
Menu, BackgroundColor, Add, Lime, :BackgroundColor_Lime
Menu, BackgroundColor_Lime, Color, Lime
Menu, BackgroundColor_Navy, Add, Navy
Menu, BackgroundColor, Add, Navy, :BackgroundColor_Navy
Menu, BackgroundColor_Navy, Color, Navy
Menu, Tray, Add, Background Color, :BackgroundColor
Menu, TextSize, Add, 13
Menu, TextSize, Add, 15
Menu, TextSize, Add, 18
Menu, TextSize, Add, 20
Menu, TextSize, Add, 25
Menu, TextSize, Add, 30
Menu, TextSize, Add, 35
Menu, Tray, Add, Text Size, :TextSize
Menu, Transparent, Add, On
Menu, Transparent, Add, Off
Menu, Tray, Add, Transparent, :Transparent
Menu, Always_On_Top, Add, On
Menu, Always_On_Top, Add, Off
Menu, Tray, Add, Always on Top, :Always_On_Top
Menu, Tray, Add, Hide, Hide
Menu, Tray, Add, Show, Show
Menu, Tray, Add, HotKeys, HotKeys
Menu, Tray, Add, Reload, Reload
Menu, Tray, Add, Exit, Exit
Menu, Tray, Disable, Show
Menu, Tray, Default, StopWatch
Return


StopWatch:
Gui, Show, , StopWatch
Return


Black:
If A_ThisMenu = TextColor_Black
   IniWrite, Black, %ini_file%, Settings, Text_Color
If A_ThisMenu = BackgroundColor_Black
   IniWrite, Black, %ini_file%, Settings, Background_Color
Gosub, Menu_Change
Return


White:
If A_ThisMenu = TextColor_White
   IniWrite, White, %ini_file%, Settings, Text_Color
If A_ThisMenu = BackgroundColor_White
   IniWrite, White, %ini_file%, Settings, Background_Color
Gosub, Menu_Change
Return


Red:
If A_ThisMenu = TextColor_Red
   IniWrite, Red, %ini_file%, Settings, Text_Color
If A_ThisMenu = BackgroundColor_Red
   IniWrite, Red, %ini_file%, Settings, Background_Color
Gosub, Menu_Change
Return


Blue:
If A_ThisMenu = TextColor_Blue
   IniWrite, Blue, %ini_file%, Settings, Text_Color
If A_ThisMenu = BackgroundColor_Blue
   IniWrite, Blue, %ini_file%, Settings, Background_Color
Gosub, Menu_Change
Return


Green:
If A_ThisMenu = TextColor_Green
   IniWrite, Green, %ini_file%, Settings, Text_Color
If A_ThisMenu = BackgroundColor_Green
   IniWrite, Green, %ini_file%, Settings, Background_Color
Gosub, Menu_Change
Return


Orange:
If A_ThisMenu = TextColor_Orange
   IniWrite, FF8000, %ini_file%, Settings, Text_Color
If A_ThisMenu = BackgroundColor_Orange
   IniWrite, FF8000, %ini_file%, Settings, Background_Color
Gosub, Menu_Change
Return


Yellow:
If A_ThisMenu = TextColor_Yellow
   IniWrite, Yellow, %ini_file%, Settings, Text_Color
If A_ThisMenu = BackgroundColor_Yellow
   IniWrite, Yellow, %ini_file%, Settings, Background_Color
Gosub, Menu_Change
Return


Gray:
If A_ThisMenu = TextColor_Gray
   IniWrite, Gray, %ini_file%, Settings, Text_Color
If A_ThisMenu = BackgroundColor_Gray
   IniWrite, Gray, %ini_file%, Settings, Background_Color
Gosub, Menu_Change
Return


Lime:
If A_ThisMenu = TextColor_Lime
   IniWrite, Lime, %ini_file%, Settings, Text_Color
If A_ThisMenu = BackgroundColor_Lime
   IniWrite, Lime, %ini_file%, Settings, Background_Color
Gosub, Menu_Change
Return


Navy:
If A_ThisMenu = TextColor_Navy
   IniWrite, Navy, %ini_file%, Settings, Text_Color
If A_ThisMenu = BackgroundColor_Navy
   IniWrite, Navy, %ini_file%, Settings, Background_Color
Gosub, Menu_Change
Return


13:
IniWrite, 13, %ini_file%, Settings, Text_Size
Gosub, Menu_Change
Return


15:
IniWrite, 15, %ini_file%, Settings, Text_Size
Gosub, Menu_Change
Return


18:
IniWrite, 18, %ini_file%, Settings, Text_Size
Gosub, Menu_Change
Return


20:
IniWrite, 20, %ini_file%, Settings, Text_Size
Gosub, Menu_Change
Return


25:
IniWrite, 25, %ini_file%, Settings, Text_Size
Gosub, Menu_Change
Return


30:
IniWrite, 30, %ini_file%, Settings, Text_Size
Gosub, Menu_Change
Return


35:
IniWrite, 35, %ini_file%, Settings, Text_Size
Gosub, Menu_Change
Return


On:
If A_ThisMenu = Transparent
   IniWrite, On, %ini_file%, Settings, Transparent
If A_ThisMenu = Always_On_Top
   IniWrite, On, %ini_file%, Settings, Always_On_Top
Gosub, Menu_Change
Return


Off:
If A_ThisMenu = Transparent
   IniWrite, Off, %ini_file%, Settings, Transparent
If A_ThisMenu = Always_On_Top
   IniWrite, Off, %ini_file%, Settings, Always_On_Top
Gosub, Menu_Change
Return


Show:
Gui, Show, , StopWatch
Menu, Tray, ToggleEnable, Show
Menu, Tray, ToggleEnable, Hide
Return


Hide:
Gui, Submit, StopWatch
Menu, Tray, ToggleEnable, Hide
Menu, Tray, ToggleEnable, Show
Return


HotKeys:
MsgBox, 64, StopWatch, Hotkeys:`n`n Start   -   F9          `n Stop   -   F10          `n Clear  -   F11          `n Exit     -   F12          `n
Return


Menu_Change:
WinGetPos, xPos, yPos, Width, Height, StopWatch
IniWrite, %xPos%, %ini_file%, Settings, xPos
IniWrite, %yPos%, %ini_file%, Settings, yPos
Return


Exit:
GuiClose:
SetTimer, UpdatedScript, Off
IniWrite, 0, %ini_file%, Settings, Msec
IniWrite, 00, %ini_file%, Settings, Sec
IniWrite, 00, %ini_file%, Settings, Min
IniWrite, 00, %ini_file%, Settings, Hour
IniWrite, %Text_Size%, %ini_file%, Settings, Text_Size
IniWrite, %Text_Color%, %ini_file%, Settings, Text_Color
IniWrite, %Transparent%, %ini_file%, Settings, Transparent
IniWrite, %Always_On_Top%, %ini_file%, Settings, Always_On_Top
IniWrite, %Background_Color%, %ini_file%, Settings, Background_Color
WinGetPos, xPos, yPos, Width, Height, StopWatch
IniWrite, %xPos%, %ini_file%, Settings, xPos
IniWrite, %yPos%, %ini_file%, Settings, yPos
ExitApp

Reload:
reload

Thanks go to Bruno for troubleshooting my changes of the script.

Chicken Pie 4 Tea
  • Members
  • 379 posts
  • Last active: Dec 12 2014 06:46 PM
  • Joined: 18 Aug 2009
thanks for the update Maestro !
"Choose your parents wisely"

Maestr0
  • Members
  • 652 posts
  • Last active: Aug 17 2019 06:07 PM
  • Joined: 18 Oct 2008

thanks for the update Maestro !

You mean to tell me my changes actually work!? wow, go figure :D

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

thanks for the update Maestro !

You mean to tell me my changes actually work!? wow, go figure :D

I am glad I discovered this script! It will have its use, no doubt. I added this to my other timer-related tools. :lol: However, while the original code works great, the new (changed) one breaks on my XP as follows:

Error: Menu does not exist. The current thread will exit.
---> Menu, BackgroundColor_%Background_Color_Check%, Check, %Background_Color_Check%

Maestr0
  • Members
  • 652 posts
  • Last active: Aug 17 2019 06:07 PM
  • Joined: 18 Oct 2008

thanks for the update Maestro !

You mean to tell me my changes actually work!? wow, go figure :D

I am glad I discovered this script! It will have its use, no doubt. I added this to my other timer-related tools. :lol: However, while the original code works great, the new (changed) one breaks on my XP as follows:

Error: Menu does not exist. The current thread will exit.
---> Menu, BackgroundColor_%Background_Color_Check%, Check, %Background_Color_Check%


That is peculiar. That code did not change with my update, nor do I get that error.
What version of AutoHotkey are you using?
How are you running this script? Do you get the problem every single time you run it?

bruno
  • Members
  • 635 posts
  • Last active: Nov 04 2015 02:26 PM
  • Joined: 07 Mar 2011
Sorry, when I mentioned I was running the original code, I meant the code at the very top of the page (by aCkRiTe). I am running AHK Basic not _L.