I am trying to automate video recording in our meeting rooms and have written a few scripts that work together to allow the starting and stopping of the recording through quicktime. I’m now trying to add the ability to have the recording automatically quit after a set amount of time. This is the flow of the scripts: “Start Recording” → which launches → “Delay Stop Recording” → which launches → “Stop Recording”
Just to try and not muddy this up with all the scripts, I have included the “Delay Recording” script:
delay 2700 --(45 minutes)
tell application “Finder”
activate
open application file “Stop Recording.app” of…
end tell
I’m using Spark to set hotkeys to launch the “Start Recording” and “Stop Recording” scripts/apps which works fine when I don’t have the delay in the mix. When I add the delay, Spark just hangs waiting for the “Delay Stop Recording” to finish and won’t let itself launch the “Stop Recording” app which I have kill the “Delay Stop Recording”.
Anyone have any ideas of how to better go about this?
Thanks
If possible you may want to write all three in to the one script like below, save it as a app (stay open.
and use spark to launch the app (application list- NOT Applescript list )
set counter to ""
global counter
on idle
set counter to counter + 1
if counter is 1 then
my start_rec()
return 20 -- lengh of delay
else if counter is 2 then
my stop_rec()
return 1
else
my the_quit()
end if
end idle
on start_rec()
-- put your recording script here
tell application "Finder"
activate
say "start recording"
end tell
end start_rec
on stop_rec()
-- put your stop recording script here
tell application "Finder"
activate
say "stop recording"
end tell
end stop_rec
on the_quit()
tell me to quit
end the_quit
** JUST updated the script to get it to quit virtually straight after the stop part rather than wait a whole idle cycle first
I’m not able to get that script to run, but I think that what I need it to do might have been lost in my original explanation…
I need the recording to start with a keystroke, and end automatically after a set length of time. Or someone can interrupt the recording with the press of a different key.
I had the start with a keystroke and stop with a keystroke working great, so I added the delay portion which works great if I actually launch the apps themselves.
My problem started when I added Spark into the mix. For some reason it seems that it won’t launch any other app (won’t respond to any hotkey) as long as I’m at the “delay” command. Is there another way to delay without using delay? Without eating up CPU performance too bad (I’m going to need the CPU to do the video encoding)? Is there any way to log the start time and end when “date” reaches 45 minutes later?
These are my scripts:
“Start Audio Recording”
--start quicktime player audio recording
tell application "QuickTime Player"
activate
new audio recording
start first recording
end tell
--tell everyone the audio is recording
set volume output volume 100
say "Audio Recording, Started"
set volume output volume 0
--start "delay audio" to auto-quit recording at specific time
tell application "Finder"
activate
open application file "Delay Audio.app" of folder "Scripts" of folder "Documents" of folder "ollie" of folder "Users" of startup disk
end tell
“Delay Audio”
delay 2700
--launch "Stop Audio Recording" after 45 minutes
tell application "Finder"
activate
open application file "Stop Audio Recording.app" of folder "Scripts" of folder "Documents" of folder "ollie" of folder "Users" of startup disk
end tell
“Stop Audio Recording”
--Stop recording in Quicktime
tell application "QuickTime Player"
activate
try
stop first recording
end try
quit "QuickTime Player"
end tell
--tell everyone the audio stopped recording
set volume output volume 100
say "Audio Recording, Stopped"
set volume output volume 0
--quit Delay Audio if running
set app_name to "Delay Audio"
set the_pid to (do shell script "ps ax | grep " & (quoted form of app_name) & "|grep -v grep | awk '{print $1}'")
if the_pid is not "" then do shell script ("kill -9 " & the_pid)
Sorry missed that second key bit.
Ok do what I said above with this script sav it as a stay open app and set a application list hot key to ’ 'Launch or Quit ’ the app you just saved, this will act as a toggle
set counter to ""
global counter
on idle
set counter to counter + 1
if counter is 1 then
my start_rec()
return 20 -- lengh of delay
else if counter is 2 then
my stop_rec()
return 1
else
my the_quit()
end if
end idle
on start_rec()
--start quicktime player audio recording
tell application "QuickTime Player"
activate
new audio recording
start first recording
end tell
--tell everyone the audio is recording
set volume output volume 100
say "Audio Recording, Started"
set volume output volume 0
end start_rec
on stop_rec()
--Stop recording in Quicktime
tell application "QuickTime Player"
activate
try
stop first recording
end try
quit "QuickTime Player"
end tell
--tell everyone the audio stopped recording
set volume output volume 100
say "Audio Recording, Stopped"
set volume output volume 0
end stop_rec
on the_quit()
tell me to quit
end the_quit
on quit
-- if you set Spark to quit the app with a hot key this part will kick in.
try
tell application "QuickTime Player"
activate
try
stop first recording
end try
quit "QuickTime Player"
end tell
end try
continue quit
end quit
That works well for the automated stopping but when I quit the app I would like to also have the script say “audio recording, stopped”, any idea for that? Thanks, a bunch already…
Yer was just playing with that.
Give me a min.
here you go
set counter to ""
global counter
on idle
set counter to counter + 1
if counter is 1 then
my start_rec()
return 10 -- lengh of delay
else
my the_quit()
return 1
end if
end idle
on start_rec()
--start quicktime player audio recording
tell application "QuickTime Player"
activate
new audio recording
start first recording
end tell
--tell everyone the audio is recording
set volume output volume 100
say "Audio Recording, Started"
set volume output volume 0
end start_rec
on the_quit()
tell me to quit
end the_quit
on quit
-- if you set Spark to quit the app with a hot key this part will kick in.
try
tell application "QuickTime Player"
try
stop first recording
quit "QuickTime Player"
end try
end tell
--tell everyone the audio stopped recording
set volume output volume 100
say "Audio Recording, Stopped"
set volume output volume 0
end try
continue quit
end quit
You kick a$$… Thanks, very much…