I am baffled. I'm trying to set up some simple AppleScripts to start/stop/backup audio clips being played in QuickTime, so I can use it when transcribing recorded conversations in TextEdit. There is no problem setting keyboard shortcuts via FastScripts or via other means (e.g. QuicKeys) for starting/stopping QuickTime while keeping focus on TextEdit.
But scripts like this, where I attempt to paste in a time code along with a speaker name via a shortcut key combination, refuse to work. They run fine when run from the Scripts menu, or from Script Editor - but I just get a beep or various weird behaviors when run via a shortcut key. Doesn't matter what shortcut key combination I choose - it never works.
Here is a sample script - here the letters "TL" that are part of what I want to keystroke just stand for the initials of a speaker's name. I have more complicated scripts that allow these to be read from a config file for convenience, but no use in trying them when even something simple like this doesn't work.
I have also tried other ways of sending the keystrokes, but though this can be coded in slightly different ways, no variation has helped.
--set printable current time of playback in document being played
tell application \"QuickTime Player\"
set thisDoc to document 1
set thisNow to current time of thisDoc
set thisSeconds to thisNow / 600 as integer
set thisMinutes to thisSeconds / 60
copy (AppleScript's text item delimiters) to old_delimiters
set AppleScript's text item delimiters to \".\"
set stringMinutes to thisMinutes as string
set PrettyMinutes to text item 1 of stringMinutes
set PrettySeconds to (thisSeconds - PrettyMinutes * 60)
set prettyTime to PrettyMinutes & \":\" & PrettySeconds
set AppleScript's text item delimiters to old_delimiters
set speakerInsert to \"TL\" & \" \" & prettyTime
tell application \"System Events\"
tell application \"TextEdit\" to activate