-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathClock.ahk
42 lines (34 loc) · 1.01 KB
/
Clock.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#Include <_COMMON_SETTINGS_>
#Persistent
; Prefixes in variable's name:
; s - string
; t - time
sHourSound := "Casio F-91W Hour Chime.wav"
sHalfHourSound := "Casio F-91W Half Hour Chime.wav"
tTime := SubStr(A_Now, 1, 10) ;Skip minutes and seconds. YYYYMMDDHH24MISS format. If only a partial string is given (e.g. 200403), any remaining element that has been omitted will be supplied with the default values.
tTime += 1, Hours
tTime -= A_Now, Seconds
tDiffToNextHour := tTime
tDiffToNextHalfHour := tDiffToNextHour + (tDiffToNextHour < 1800 ? 1800 : -1800)
SetTimer, InitHourClock, -%tDiffToNextHour%000 ;negative period - run once
SetTimer, InitHalfHourClock, -%tDiffToNextHalfHour%000
InitHourClock()
{
SetTimer, HourBeep, 3600000
HourBeep()
}
InitHalfHourClock()
{
SetTimer, HalfHourBeep, 3600000
HalfHourBeep()
}
HourBeep()
{
global sHourSound
SoundPlay, %sHourSound%, Wait
}
HalfHourBeep()
{
global sHalfHourSound
SoundPlay, %sHalfHourSound%, Wait
}