2013-11-04 53 views
4

我試圖寫一個小的AppleScript的一個項目,我必須:的AppleScript:QuickTime影片記錄自動保存後,它的完成錄音

  • 啓動QuickTime影片記錄
  • 減少記錄的窗口
  • 打開的影片,將自己放到全屏
  • 一旦影片播放完畢,記錄應停止
  • 的記錄本身應該保存在背景文件名爲「當前日期和時間」
  • 關閉正在播放
  • 在Safari中打開一個網站的電影。

這是我設法到目前爲止做:

set theDate to current date 
set filePath to (path to desktop as text) 

tell application "QuickTime Player" 
    activate 
    set newMovieRecording to new movie recording 

    tell newMovieRecording 
     start 
     tell application "QuickTime Player" 
      set miniaturized of window 1 to true 
     end tell 
     tell application "QuickTime Player" 
      open file "Users:test:Desktop:Movie.m4v" 
      tell document "Movie.m4v" to play 

      set the bounds of the first window to {0, 0, 1800, 1100} -- I did not find how to put the window in full screen (whatever the screen size is: I wrote this script on an external screen , but the project will take place on the screen of a laptop). 
     end tell 
     delay 160 -- the length of the movie 
     save newMovieRecording in file (filePath) & theDate 
     stop 
     close newMovieRecording 

     tell application "QuickTime Player" 
      close document "Movie.m4v" 
     end tell 

    end tell 
end tell 

tell application "Safari" 
    activate 
    open location "http://stackoverflow.com" 
end tell 

上述腳本是隻要我能得到:當影片記錄應該自己救自己,我得到了以下信息AppleScript的編輯:「AppleScript的錯誤 - QuickTime播放器得到了一個錯誤:無效的鍵的形式。」

在此先感謝您的幫助。

+0

使用'present'發揮你的電影全屏(而不是'play'。 ) – 2013-11-05 19:36:06

回答

1

你有幾個問題存在。

  1. 「的文件(文件路徑)& theDate」很可能是「文件(文件路徑)」,然後一個日期添加到其上的,因爲它們不能被級聯,其將失敗。爲了解決這個問題,在保存之前創建的文件路徑,類似於:

    組文件名文件路徑& theDate 保存newMovieRecording在文件文件名

  2. 然而,還有另外一個問題:默認的日期格式包含冒號,它可以「不會出現在Mac OS X中使用的文件路徑。你可能會想建造沒有冒號的日期/時間戳記,是這樣的:

    集郵戳到theDate &的一年「 - 」 & theDate &月份「 - 」 & theDate &的日子「」 &小時的theDate &「 - 」 &分鐘theDate

  3. 而且文件名具有正確的擴展名,否則你會得到一個權限被拒絕的錯誤:

    組文件名文件路徑&郵戳& 「的.m4v」

(請注意,我用的.mov進行測試,希望他們的行爲是相同的。)