I simplified the scripts (below), so now I don't have to schedule my bittorrent downloading or video conversion around my SuperDuper backup schedule.
Code:
-- Pauses VisualHub and Transmission, if running
-- So they won't muck up SuperDuper's scheduled backups
tell application "System Events"
if (exists process "VisualHub") then
tell process "VisualHub"
set frontmost to true
tell me to do shell script "/bin/sleep 5"
keystroke "." using command down
end tell
end if
if (exists process "Transmission") then
tell process "Transmission"
set frontmost to true
keystroke "." using {option down, command down}
end tell
end if
end tell
The "sleep" line helps with those instances where I'd awake in the morning to find VisualHub as my frontmost app, but not paused, and SD! most distinctly unhappy with that situation.