Recently, I've been working on a JavaScript Automation script to record my screen on my Mac. However, I encountered an issue with the API when it reaches the line doc.close()
. QuickTime would hang indefinitely and eventually my Script Editor would time out.
var QuickTime = Application("QuickTime Player");
var doc = QuickTime.newScreenRecording();
doc.start();
delay(2);
doc.close();
To resolve this, I had to force quit QuickTime using the command line:
$ killall QuickTime\ Player
Upon reopening QuickTime, I found my video waiting for me. So, I tried adding arguments to the close method resulting in the following revised script:
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 haven't been able to find sufficient documentation to fully comprehend what is required of me here. Can someone enlighten me on the correct way to write a script that captures a screen recording and saves it to my Desktop?