Question

I'd like automatically launch Keynote's "Play->Play slideshow in window" feature. There's no predefined shortcut. Can that be done from AppleScript? How? Thanks.

Was it helpful?

Solution

You can define custom keyboard shortcuts for pretty much erverything via System Preferences.

Open the "System Preferences" app ➔ "Keyboard" preferences ➔ "Shortcuts" pref pane ➔ App Shortcuts. Click the Plus (+) button.

Keyboard prefs add shortcut

Choose Keynote from the "Application:" list. Enter the name of the menu title, in this case "Play Slideshow in Window" exactly as it appears in the menu item (spaces, upper/lower case etc.). Enter a keyboard shortcut (Control-Option-Command-W in the screenshot below). Click the "Add" button.

Add shortcut

Tadaaa! :) Custom keyboard shortcut in Keynote.

You can then automate this via AppleScript just like with "default" keyboard shortcuts, like so:

tell application "Keynote"
    activate
    tell application "System Events"
        keystroke "w" using {control down, option down, command down}
    end tell
end tell

(The keystroke in the script is corresponding to the example used above.)

Please remember that you have to allow the respective script editor/compiled script app to control the computer in the Accessibility settings pane in "Security & Privacy" ➔ "Privacy" settings so that the app can send keystrokes.

Licensed under: CC-BY-SA with attribution
Not affiliated with apple.stackexchange
scroll top