I need to open Keynote files programmatically via Node.js. using

open -a Keynote -W "path/to/file.key"

everything works well. But there are two tasks I cannot solve:

  1. the presentation needs to start directly so no further user interaction is necessary.

As I have no control over the presentation itself, I cannot alter the files to start in presentation mode. Somehow I have to tell Keynote. In Powerpoint this is possible via the /s Argument (powerpoint.exe /s "path/to/presentation.pptx" will go directly in presentation mode). Does something similar exist for Keynote?

  1. After the last slide I need to quit Keynote

Is there any possibility to tell Keynote to quit after the last slide? My Application needs to know when the presentation is finished and I can track when the program closes, but as default it only closes the presentation, not Keynote itself.

3 Answers 3


You could use an AppleScript to do this and run it with osascript...

osascript << EOF
if running of application "Keynote" is true then
    tell application "Keynote"
            if playing is false then start the front document
        end try
    end tell
end if

In the Keynote presentation, from the Document inspector, enable ‘Automatically play upon open’. This is a per-document setting that will be saved to the document, similar to a PowerPoint ppsx extension.

Unfortunately there is no way to quit Keynote automatically.



As unknowndomain pointed out - AppleScript is the way to go. To give me feedback on when the presentation is finished I had to change the script but here is what works for me:

on run argv  //I give the filename as parameter
    tell application "Keynote"

        open item 1 of argv
        start the front document

    end tell

    tell application "Keynote"
        repeat while playing  //this loop continues as long as the presentation is running
            delay 1
        end repeat
    end tell
    quit application "Keynote"  //as the presentation ends it quits Keynote

end run

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .