title: Control Quicktime Using Applescript
body: <p>I am looking for a solution to control Quicktime using Applescript.
  All I need to do is - 
  - open quicktime and start a recording
  - stop the recording and save the file to a set location.</p>
  
  <p>From previous posts I managed to get the following.</p>
  
  <pre><code>    set theFilePath to "/Users/jamestebb/Desktop/01TestRecords/ " &amp; "myfile" &amp; ".mov"
  
  tell application "QuickTime Player"
      set newMovieRecording to new movie recording
      tell newMovieRecording
          start
          delay 5
          pause
          save newMovieRecording in POSIX file theFilePath
          stop
          close newMovieRecording
      end 
  </code></pre>
  
  <p>This works perfectly however, for this project I need separate script cues to start and stop the recording as opposed to having a wait / delay.</p>
  
  <p>To start the recording I used.</p>
  
  <pre><code>set theFilePath to "/Users/jamestebb/Desktop/01TestRecords/ " &amp; "myfile" &amp; ".mov"
  
  tell application "QuickTime Player"
      set newMovieRecording to new movie recording
      tell newMovieRecording
          start
  
      end tell
  end tell
  </code></pre>
  
  <p>This works fine however when I try to stop the recording using the below I get errors where Pause is not understood</p>
  
  <pre><code>set theFilePath to "/Users/jamestebb/Desktop/01TestRecords/ " &amp; "myfile" &amp; ".mov"
  
  tell application "QuickTime Player"
      set MovieRecording to new movie recording
      tell MovieRecording
  
          pause
          save MovieRecording in POSIX file theFilePath
          stop
          close MovieRecording
      end tell
  end tell
  </code></pre>
  
  <p>Im guessing that this is because the file currently recording is no longer a "new movie recording"</p>
  
  <p>Any ideas soon how to fix??</p>