我正在寻找一种使用Applescript控制Quicktime的解决方案。我所要做的就是--打开快速时间并开始录制-停止录制并将文件保存到设置的位置。
从以前的帖子中,我设法获得了以下内容。
set theFilePath to "/Users/jamestebb/Desktop/01TestRecords/ " & "myfile" & ".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
然而,这很好用,对于这个项目,我需要单独的脚本提示来开始和停止录制,而不是等待/延迟。
开始我使用的记录。
set theFilePath to "/Users/jamestebb/Desktop/01TestRecords/ " & "myfile" & ".mov"
tell application "QuickTime Player"
set newMovieRecording to new movie recording
tell newMovieRecording
start
end tell
end tell
这很好,但是当我尝试使用以下方法停止录制时,出现无法理解暂停的错误
set theFilePath to "/Users/jamestebb/Desktop/01TestRecords/ " & "myfile" & ".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
我猜这是因为当前正在记录的文件不再是“新电影记录”
很快有任何想法如何解决?
AppleScript code来测试在QuickTime Player中使用第一个script开始一个New Movie Recording,然后用第二个脚本将其处理为暂停,保存,停止和关闭。
tell application "QuickTime Player"
set newMovieRecording to new movie recording
tell newMovieRecording to start
end tell
脚本2:
set theFilePath to POSIX path of (path to movies folder) & "myMovie.mov"
tell application "QuickTime Player"
tell document "Movie Recording"
pause
save it in POSIX file theFilePath
stop
close
end tell
end tell
在这两个之间,它成功地在我的
脚本
主页 文件夹的电影 文件夹的电影 文件夹中创建了myMovie.mov
文件 。测试已在macOS High Sierra]下完成。
注意:示例 AppleScript 代码就是这样,并且不包含任何错误处理。用户有责任添加任何适当的,需要的或想要的。看看try中的error statement和AppleScript Language Guide statement。另请参阅Working with Errors。另外,在适当的情况下,例如,在事件之间,可能需要使用delay command。 delay 0.5
,并已适当设置delay的value。