AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

StopWatch

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
aCkRiTe
Guest





PostPosted: Sun Jul 16, 2006 6:53 pm    Post subject: StopWatch Reply with quote

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!



transparent view (desktop background color is gray)


tray menu view


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
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

Back to top
d-man -
Guest





PostPosted: Sun Jul 16, 2006 8:24 pm    Post subject: Reply with quote

hmm, nice presentation but you didn't put the script in u said worked Razz did u paste an older one in?
Back to top
aCkRiTe
Guest





PostPosted: Sun Jul 16, 2006 8:38 pm    Post subject: Reply with quote

Wow! If it aint ole` D-Man to bail me out yet once again! Very Happy Thanks D-Man I did excatly what you said, I posted one of the old scripts. Sorry about that. Here is the new code.
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

Back to top
lilljimpa



Joined: 18 Apr 2007
Posts: 72

PostPosted: Sun Sep 23, 2007 8:04 pm    Post subject: Reply with quote

i whold like to have just the same kind of function with countdown
Back to top
View user's profile Send private message Send e-mail MSN Messenger
aCkRiTe



Joined: 21 Jul 2006
Posts: 502

PostPosted: Sun Sep 23, 2007 8:31 pm    Post subject: Reply with quote

Take a look here http://www.autohotkey.com/forum/viewtopic.php?t=21375&highlight=countdown+timer
This might be what your looking for...
_________________

HTH...

Back to top
View user's profile Send private message
lilljimpa



Joined: 18 Apr 2007
Posts: 72

PostPosted: Sun Sep 23, 2007 9:07 pm    Post subject: Reply with quote

aCkRiTe wrote:
Take a look here http://www.autohotkey.com/forum/viewtopic.php?t=21375&highlight=countdown+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)
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group