How do I launch Play-in-window from AppleScript
You can define custom keyboard shortcuts for pretty much erverything via System Preferences.
Open the &quot;System Preferences&quot; app ➔ &quot;Keyboard&quot; preferences ➔ &quot;Shortcuts&quot; pref pane ➔ App Shortcuts. Click the Plus (+) button.

Choose Keynote from the &quot;Application:&quot; list. Enter the name of the menu title, in this case &quot;Play Slideshow in Window&quot; 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 &quot;Add&quot; button.

Tadaaa! :) Custom keyboard shortcut in Keynote.

You can then automate this via AppleScript just like with &quot;default&quot; keyboard shortcuts, like so:
tell application &quot;Keynote&quot;
    activate
    tell application &quot;System Events&quot;
        keystroke &quot;w&quot; 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 &quot;Security &amp; Privacy&quot; ➔ &quot;Privacy&quot; settings so that the app can send keystrokes.