我正在尝试为我必须的项目编写一个小AppleScript:
这是我到目前为止所做的事情:
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 :(得分:1)
你有几个问题。
“file(filePath)& theDate“可能是”文件(文件路径)“,然后添加一个日期,由于它们无法连接而失败。要解决此问题,请在保存之前创建文件路径,例如:
将fileName设置为filePath&日期 在文件fileName中保存newMovieRecording
但是,还有另一个问题:默认日期格式包含冒号,不能在Mac OS X文件路径中使用。您可能想要构建一个没有冒号的日期/时间戳,例如:
将dateStamp设置为theDate&的年份“ - ”&日期和日期“ - ”&日期和日期“”&小时和日期“ - ”&分钟的日期
文件名必须以正确的扩展名结尾,否则您将收到权限被拒绝错误:
将fileName设置为filePath& dateStamp& “的.m4v”
(请注意,我使用.mov进行测试,希望它们的行为相同。)