You could also do something like this:
Code: Select all
;
; TimeSpeak v1.1
; by Grendahl
; Announces the time on the hour using Microsoft's text-to-speech engine
;
; Change Log
; v1.1 (2011-11-28)
; First version (inspired by http://www.autohotkey.com/forum/viewtopic.php?t=14305)
;********** settings, variable declarations **********
#NoEnv
#Warn
SendMode Input
SetWorkingDir %A_ScriptDir%
#SingleInstance Force
;********** auto-execute section **********
SetTimer, AnnounceHour, 1000
Return
;********** hotkeys **********
!ESC::ExitApp
!t::gosub SayTime
;********** subroutines **********
AnnounceHour:
FormatTime, AnnounceHour, %A_Now%, h ; get current hour
FormatTime, AnnounceMinute, %A_Now%, m ; get current minutes
FormatTime, AnnounceAMPM, %A_Now%, tt ; get AM/PM
If(AnnounceMinute<1)
{
IfInString, AnnounceAMPM, AM ; If AM, say a m instead of ameters
AnnounceAMPM = ae em
IfInString, AnnounceAMPM, PM ; If PM, say p m instead of pmeters
AnnounceAMPM = pee em
AnnounceHourString = The time is %AnnounceHour% %AnnounceAMPM% ;oh clock %AnnounceAMPM% ; announce time
ComObjCreate("SAPI.SpVoice").Speak(AnnounceHourString)
sleep 1000
loop %AnnounceHour%
{
SoundPlay, %A_ScriptDir%\Chime.wav
Sleep 1200
}
}
If(AnnounceMinute=15 || AnnounceMinute=30 || AnnounceMinute=45)
{
IfInString, AnnounceAMPM, AM ; If AM, say a m instead of ameters
AnnounceAMPM = ae em
IfInString, AnnounceAMPM, PM ; If PM, say p m instead of pmeters
AnnounceAMPM = pee em
AnnounceHourString = The time is %AnnounceHour% %AnnounceMinute% %AnnounceAMPM% ;oh clock %AnnounceAMPM% ; announce time
ComObjCreate("SAPI.SpVoice").Speak(AnnounceHourString)
}
SetTimer, AnnounceHour, Off ; stop the timer for 90 seconds so we don't get spammed
Sleep 90000
SetTimer, AnnounceHour, On
Return
SayTime:
FormatTime, SayHour, %A_Now%, h ; get current hour
FormatTime, SayMinute, %A_Now%, m ; get current minutes
FormatTime, SayAMPM, %A_Now%, tt ; get AM/PM
If(SayMinute>0 && SayMinute<10) ; add the "oh" for minutes 1 through nine
SayMinute = oh %SayMinute%
If(SayMinute=0) ; if the current minute is 0, say oh clock instead of zero
SayMinute = oh clock
IfInString, SayAMPM, AM ; If AM, say a m instead of ameters
SayAMPM = ae em
IfInString, SayAMPM, PM ; If PM, say p m instead of pmeters
SayAMPM = pee em
SayTimeString = The time is %SayHour% %SayMinute% %SayAMPM% ; announce time
ComObjCreate("SAPI.SpVoice").Speak(SayTimeString)
Return