Reputation: 534
I am trying to write a small AppleScript for a project where I have to:
This is what I managed to do so far:
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
The above script is as far as I could get: When the movie recording is supposed to save itself, I get the following message from AppleScript Editor: "AppleScript Error - QuickTime Player got an error: Invalid key form."
Thanks in advance for any help.
Upvotes: 4
Views: 2013
Reputation: 3466
You have a couple of problems there.
“file (filePath) & theDate” is likely to be “file (file path)” and then a date added onto it, which will fail as they can’t be concatenated. To fix this, create the file path before saving, something like:
set fileName to filePath & theDate save newMovieRecording in file fileName
However, there’s another problem: the default date format contains colons, which can’t be in used in Mac OS X filepaths. You’ll probably want to construct a date/time stamp without colons, something like:
set dateStamp to the year of theDate & "-" & the month of theDate & "-" & the day of theDate & " " & hours of theDate & "-" & minutes of theDate
And the filename has to end in the correct extension or you’ll get a permission denied error:
set fileName to filePath & dateStamp & ".m4v"
(Note that I used .mov for testing, hopefully they act the same.)
Upvotes: 1