Timer

By Chris Norman, 29 June, 2014

Forum
Other Apple Chat

Hi all,
I hope someone finds the below script useful which I wrote for Coventry Samaritans so that I can log the lengths of telephone calls with a minimum of effort.

Sorry, but it's another script (yes, I'm obsessed).

Anyways, here's the script, which as with my others, you can bind to a VoiceOver key:

(*
Samaritans Timer: Version 1.0
By Chris Norman

Written for my own personal use at the Coventry Samaritans branch.

Usage:
Ensure Text edit is open, and you have a document created.

Note: Text Edit is quite happy to save all the information in the document without asking if you quit unless you have the "Ask to save when closing documents" checkbox ticked in the General pane of System Preferences. This could be of particular importants to Samaritans, as most likely the stuff you will be saving in your logs will be confidential. Other than this feature of Mac OS X, this script fully maintains Samaritans view of confidentiality.

To use, map a voiceover key (using a commander), or run from Applescript Editor. Ensure you have the checkbox labeled "Allow VoiceOver to be controlled with AppleScript" checked, or parts of the script will fail.

The first time you run the script, VoiceOver will announce the start time of the current call. This is where the error will appear if you do not have the checkbox ticked (see above).

When you run the script again, it will print text to your text edit document, of the form:

Start time-Duration (in minutes).

For example:

00:17-1

Write a synopsis for the call below this line, and you have a perfectly formed log which you can use to fill in the actual branch logs.

For support or feature requests, please email me on:
chris.norman2@googlemail.com
*)

property day : 0
property startTime : 0
property timecode : 0
on resetTimes()
set day to day of (current date)
set timecode to time of (current date)
set startTime to (do shell script "date +\"%H:%M\"")
end resetTimes

if timecode = 0 then
resetTimes()
tell application "VoiceOver" to output "Started at " & startTime & "."
else
if (day of (current date)) ≠ day then
set currentTime to (time of (current date)) + (24 * 3600)
else
set currentTime to (time of (current date))
end if
set currentTime to (((currentTime - timecode) / 60) as integer)
if currentTime = 0 then
set currentTime to 1
end if
tell application "TextEdit"
set text of first document to (((text of first document) & startTime & "-" & currentTime) & "
")
activate
end tell
set currentTime to 0
set day to 0
set timecode to 0
end if

Options