3

I'm trying to write a JavaScript Automation script for recording the screen on my Mac. I'm finding that the API is broken at the line that is doc.close(). QuickTime just hangs there and eventually my Script Editor fails with a timeout error.

var QuickTime = Application("QuickTime Player");
var doc = QuickTime.newScreenRecording();
doc.start();
delay(2);
doc.close();

I eventually have to quit QuickTime from the command line with the following:

$ killall QuickTime\ Player

Then I open QuickTime again to find my video waiting for me there. So then I decided to add the arguments the close method and now my script looks like this:

var QuickTime = Application("QuickTime Player");
var doc = QuickTime.newScreenRecording();
doc.start();
delay(2);
doc.close("yes",Path("/Users/myuser/Desktop/movie.mov"));
QuickTime.quit();

Result:
Error -2700: Script too silly to execute.
Error on line 5: Error: Named parameters must be passed as an object.

I don't see enough documentation out there to completely understand when is being asked of me here. What is the proper way to write this script that capture a screen recording and saves that document/file to my Desktop?

user3792132
  • 91
  • 2
  • 4

1 Answers1

0

I guess close expects each of its arguments to come with a name. The name-argument pair can be expressed as an object with the syntax below:

doc.close({saving: 'yes'}, {path: '/Users/myuser/Desktop/movie.mov'});

instead of this:

doc.close("yes",Path("/Users/myuser/Desktop/movie.mov"));

N.B. I didn’t try this live with QuickTime. Please tell me if this doesn’t work or if I’m mistaken.