Having duplicated your QuickTime Player application and named it Reaction, I understand you've created an AppleScript applet, and placed this copy of Reaction.app within the Resources
folder of the AppleScript applet.
Because it's a duplicate of QuickTime Player (which is scriptable), Reaction is also scriptable, and can also be scripted from within the applet's AppleScript (located at Resources/scripts/main.scpt
).
Your main.scpt
should look something like this:
set A to path to resource "Reaction.app"
set home to POSIX path of (path to home folder)
set fp to home & "/Movies/Reaction Recording.mov"
set f to a reference to POSIX file fp
using terms from application "QuickTime Player"
tell the application named A
activate
tell the (new movie recording)
start
delay 10
pause
save in f
stop
close
end tell
end tell
end using terms from
application "QuickTime Player"
may change of its own accord to application "Reaction"
, which is completely fine.
This script creates a ~10 second recording, minus a couple of seconds to account for the initialisation of the script and such. Change delay 10
to whatever value represents a sensible recording time in seconds.
To send it as an attachment using Mail:
set msgSubject to "My Reaction Recording"
set msgBody to "Hi. Please see the attached recording. \n"
set msgFrom to "[email protected]"
set msgTo to "[email protected]"
tell application "Mail"
activate
tell (make new outgoing message ¬
with properties {visible:true ¬
, subject:msgSubject ¬
, content:msgBody ¬
, sender:msgFrom})
make new to recipient ¬
at end of to recipients ¬
with properties {address:msgTo}
tell its content to make new attachment ¬
at after the last paragraph ¬
with properties {file name:f as alias}
delay 2
-- send
end tell
end tell
The top script and the bottom script can simply join to form one continuous script. You might need a delay in between the two portions, but I didn't require one on my system.
However, the delay within the Mail block is important if you wish to send the email (you must also uncomment the send
command by removing the --
; keeping it in, which I did during testing, will allow you to preview the email and send it manually).