Code: Select all
#SingleInstance,Force
Menu, Tray, NoStandard
Menu, Tray, Add,Time,Time
Menu, Tray, Add,Reload,Restart
Menu, Tray, Add,Exit,Exit
Menu, Tray, Default,Time
Menu, Tray, Icon,shell32_16771.ico
Menu, Tray,Click, 1
OnExit,Reason
InputBox,Time,Timer,Set Time in Minutes
If ErrorLevel
ExitApp
IfInString,Time,`:
{
StringSplit,Time,Time,:
Time := ((Time1 * 60)*60 + (Time2 * 60) + Time3)*1000
}
Else
Time := (Time * 60 )* 1000
Loop
{
Start := A_TickCount
Sleep,% Time
TrayTip,,Time
SoundPlay,C:\Windows\Media\Windows Background.wav,wait
KeyWait,LButton,D
SoundPlay,C:\Windows\Media\Windows Background.wav,wait
If Time != 3600000
Time = 3600000
}
Time:
ms := Time - (A_TickCount - Start)
year := A_YYYY
year += Floor(ms / 1000), SECONDS
FormatTime, Remaining, %year%, HH:mm:ss
MsgBox,,Remaining Time,% " " Remaining,1
Return
Exit:
ExitApp
Reason:
If A_ExitReason Single
{
ms := Time - (A_TickCount - Start)
year := A_YYYY
year += Floor(ms / 1000), SECONDS
FormatTime, Remaining, %year%, HH:mm:ss
Clipboard := Remaining
ExitApp
}
Else
ExitApp
Restart:
Reload
The problem is that sometimes the remaining time before reaching 0 becomes a lot more than 60 minutes(sometimes 15 hours or more)
I think it usually happens when I put the laptop to sleep and when I wake it up after few hours and left click,the countdown time is set to the time that has past since the last 60 minutes(when the script could not show me the tooltip because the laptop was in sleep mode))