Quote of the Week
“Anyone who has lost track of time when using a computer knows the propensity to dream, the urge to make dreams come true and the tendency to miss lunch.”–Tim Berners-Lee
Losing Track of Time
I lose track of time frequently, but most often when I am working on the computer. I will sit down to do something, and the next thing I know it is three hours later.
I read about a way to make Macs speak the time. (If you have a Mac, check out http://heresthethingblog.com/2012/12/17/mac-tip-give-macs-clock-power/). The ability to speak the time is built into the Mac operating system.
But I don’t use a Mac. I am a Windows geek, and I thought that it would be helpful to have this sort of functionality.
So I wrote it.
Making A PC Speak The Time
(It turns out this has been done a bunch of times before, but I didn’t Google it before I started.)
If you want to make your PC speak the time, do the following:
- Create a batch file to speak the time. To do this, right-click in a folder (or on your desktop) and choose New…Text Document. Rename the file “SpeakTime.vbs” Choose “Yes” when it asks you if you really want to change the file extension. Open the file.
- Copy the following code into the file you just created.
'Speak the time
dim curTime, curHour, curMin, curAMPM, strSpeak, sapi
curTime = now()
curHour = hour(curTime)
if curhour > 13 then
curHour = curHour - 12
curAMPM = "P"
else
curAMPM = "A"
end if
curMin = minute(curTime)
strSpeak = cstr(curHour) & " " & cstr(curMin) & " " & curAMPM & " " & "M"
Set sapi=CreateObject("sapi.spvoice")
sapi.Speak strSpeak
- Save the file and close it. Test it by double-clicking on it.
- Schedule the file to run every hour (or half hour, or 15 minutes) using your Windows Task Scheduler. A good tutorial on this (which covers Windows 7 and above) is http://www.digitalcitizen.life/how-create-task-basic-task-wizard.
Now if you want the super edition that I use, which can be turned off by the presence of a file in the directory called SpeakOff.txt, and which will show you the time as well, use the following code:
'Speak The time
dim curTime, curHour, curMin, curAMPM, strSpeak, sapi, FSO, folderName, fileName, ShowTime
ShowTime = 1 'set this to 0 to turn off showing the time
'look for a file named SpeakOff.txt in the current directory
Set fso = CreateObject("Scripting.FileSystemObject")
foldername = "."
filename = "SpeakOff.txt"
'if the file doesn't exist, get the time and read it.
If not fso.FileExists(fso.BuildPath(foldername, filename)) Then
curTime = now()
curHour = hour(curTime)
if curhour > 13 then
curHour = curHour - 12
curAMPM = "P"
else
curAMPM = "A"
end if
curMin = minute(curTime)
strSpeak = cstr(curHour) & " " & cstr(curMin) & " " & curAMPM & " " & "M"
Set sapi=CreateObject("sapi.spvoice")
sapi.Speak strSpeak
'show the time if that option is set
if ShowTime <> 0 then
strSpeak = cstr(curHour) & ":" & cstr(curMin) & " " & curampm & "M"
msgbox strSpeak
end if
end if
Having your computer speak the time can be a valuable tool to prevent those all-too-common moments when you look up from your screen only to realize hours have passed. This simple script helps keep you aware of time passing throughout your day, making it easier to maintain a healthy work schedule and remember important breaks. Whether you use the basic version or the enhanced one with added features, this little utility might just help you regain some control over your day and perhaps even remember to eat lunch!


