1

I have made a duplicate of the application "Quicktime player" on my Mac and renamed it "Reaction" then I have put this copy inside of a applescript. I am trying to write a code that tells the "Reaction" to start a "New Movie Recording" (which is a option of recording) then save the recording within the applescript. (the name of the recording is irrelevant)

Extra: Also if anyone knows how I could then code a way to add the recording to a email and send it to people that would be great.

At the moment I know how to open "Reaction" but not how to tell "Reaction" to start a "New Movie Recording"

So far i'm using this to open "Reaction"

  set appPath1 to path to resource "Reaction.app"
tell application "Finder"


open appPath1

end tell
3

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 "your@email.com"
set msgTo to "friend@email.com"

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).

  • +1 Thanks for taking the time to post a better and more thorough answer! :) – Monomeeth Aug 17 '18 at 22:58
  • 1
    Have a look at path to (folder) and you'll see that you can instead use path to movies folder and avoid unnecessary getting path to home folder first. Lines 2 and 3 get replaced by set fp to POSIX path of (path to movies folder) & "Reaction Recording.mov", thus negating the need for line 2. Nice script otherwise. +1 – user3439894 Aug 18 '18 at 0:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .