I’ve been digging into iWork’s Applescript library, inspired by Episode 3 of Automators. What I’m trying to produce is an Applescript that will duplicate an existing slide and remove all animations contained in the slide. I often want to produce a final slide that shows the final version of the previous slide for when my animations get unwieldy.
From what I can tell, Keynote lets you automate the slide transition, but I can’t find any way to control builds within the slide. Any tips (or bad news)?
There’s a great website that @Sal put together called iWork Automation, but unfortunately I didn’t find anything in the Keynote information regarding individual object animation.
For those interested, here’s what I came up with that seems to work quite well. Thank you again @dfay for all your help! This will save me a ton of time.
tell application "System Events"
tell process "Keynote"
set frontmost to true
tell window 1
-- open the toolbar if it's not open already
if toolbars is {} then
click menu item "Show Toolbar" of menu "View" of menu bar item "View" of menu bar 1
end if
-- tell application "System Events" to keystroke "d" using command down
-- getting the properties of the default body item also selects it in the UI
tell document 1 of application "Keynote"
set s to current slide
duplicate s to after (get the current slide)
set transition properties of current slide to {transition delay:0, automatic transition:false, transition effect:no transition effect, transition duration:0}
properties of iWork item in current slide
end tell
tell application "System Events" to keystroke "a" using command down
tell application "System Events"
tell process "Keynote"
set frontmost to true
tell window 1
-- open the animations pane if it's not open already
if value of radio button "Animate" of radio group 1 of toolbar 1 is 0 then
click radio button "Animate" of radio group 1 of toolbar 1
end if
-- deal with existing and new animations
-- edit the following to reflect your desired build
if button "Change" exists then
click button "Change"
click button "None" of scroll area 1 of pop over 1 of button "Change"
end if
if button "Change" exists then
click button "Change"
click button "None" of scroll area 1 of pop over 1 of button "Change"
end if
end tell
end tell
end tell
end tell
end tell
end tell
Wondering if your conversation can help me with Keynote as well.
I am a Bible teacher and I use Keynote for everything. My default most used slide animation is a 1 Second Dissolve. My second is Magic Move, but that is more infrequent (and more manual so I don’t care about automating it as much.
The default dissolve time for a Slide Dissolve is 1.5 seconds, which is too slow. I desperately wish I could set the default to 1 second SOMEWHERE in Keynote, but there is no way.
Is there a way to create a script that
Applies the Dissolve Transition and
Sets the Duration to 1.00 seconds?
I literally do this hundreds of times in a week, and yes I know that I can select them all and apply it, but then I would have to go through manually and undo all of the magic moves
The best scenario would be to write a script that applies the dissolve, sets it to 1 second and then I could take that script, create a macro in Keyboard Maestro, map it to a Stream Deck button and all would be right with the world.
Any help would be amazingly appreciated!
You have no idea what an incredibly time-saving help this would be for me.
Fortunately this can be done directly, without UI scripting:
tell document 1 of application "Keynote"
set transition properties of current slide to {transition duration:1, transition delay:0.5, transition effect:dissolve, automatic transition:false}
end tell
@dfay You are awesome! Thank you! I will definitely be trying this out.
One follow up question: Will this action work on anything I have selected?
For example:
a) Sometimes I want to select one slide and apply a slide transition
b) Other times I want to select a range of slides and apply it to all of the selected slides
c) Sometimes I want to select an object or range of objects within a single slide and affect those
Is there a way to modify the code to do something like current slides or current selection or current object? I don’t know enough about AppleScript to know if those are even real properties, but once I know the correct syntax for a single slide (above) a range of slides and how to target objects, I think I can handle all of the transition properties from there.
Thanks so much for your help! Being able to apply these with one button press will be a dream come true!
this works for a & b - transition properties are only found in slides so c is trickier (taking us full circle back to the first post in this thread)
tell document 1 of application "Keynote"
set s to selection
repeat with aSlide in s
set transition properties of aSlide to {transition duration:1, transition delay:0.5, transition effect:dissolve, automatic transition:false}
end repeat
end tell
@dfay Much appreciate your taking the time to help and respond. I will review the code earlier and what you taught me in this later script to see if I can get it to work.