I’ve been trying to write a simple script that will advance a keynote deck that is already open and running one “click”. I play the slideshow in a window, and use this script:
tell application “keynote”
activate
show next
end tell
This works most of the time, but sometimes does not work and returns an error of -1708 which I’m told means that apple script can’t find the resource it is trying to manipulate (in this case, keynote).
I tried changing the first line to "tell application id “com.apple.iWork.Keynote” to be more specific with the tell, but I’m unsure if that will make a difference (the “misfire” seems to happen at random).
Is there anything I’m missing that could make this work perfectly consistently? I’m a newbie so an advice is much appreciated.
I’m not a Keynote user myself, but trying things out, it doesn’t look as if the ‘show next’ command works when the slide show’s playing “in Window”. Keynote’s AppleScript implementation doesn’t seem to know about the player window.
The command works when the slide show’s playing full screen, but it has to be addressed to the slide show document, eg.:
tell application "Keynote"
activate
tell document 1
show next
end tell
end tell
… which of course isn’t much use if you can’t trigger the script because the slide show’s filling the screen!
It’s not entirely clear what the OP is seeking, but I’d like to point out that Keynote has AppleScript support for play-mode. For example, when my presentation has slides numbered 2 and 3, I can play them using this:
tell application "Keynote"
tell front document
try
stop -- begin with no playing state
end try
start from slide 2 -- show slide 2
end tell
activate
delay 1
show next -- show slide 3
delay 1
tell front document to stop
end tell
The AppleScript support is certainly there when the slide show’s playing in its document. But Keynote also has a function called (in English) “Play Slideshow in Window”. In Keynote 10.1, it’s the second item in the “Play” menu. It’s in this mode that the problem occurs.
I wrote right now a script that works in Script Editor, Script Debugger and as app, but… For some reason, the cursor works but is not visible in the area of the desired window. The name of new window exists, but is hidden too :lol:
tell application "Keynote"
set theBounds to bounds of window 1 -- document window
tell front document
try
stop -- begin with no playing state
end try
start from slide 2 -- show slide 2
end tell
my setBounds(theBounds)
delay 1
show next -- show slide 3
delay 1
-- tell front document to stop
end tell
on setBounds(theBounds)
tell application "Keynote"
set bounds of window 1 to theBounds -- other window
activate
end tell
end setBounds
Thanks to everyone the responded, I’ve been having success using the tell “tell application ID” instead of “tell application”. It seems as though being more specific resolves the error of the script “misfiring” at random.