I have owned Script Debugger for years, but just haven’t needed it, but I need to script one small thing in Keynote and I don’t know enough about the basics of scripting to know what I am doing wrong.
What I want to do is this:
Select a slide in Keynote manually
Run a script that tells that slide to apply a 1 second Dissolve transition.
That’s it!
Here is as far as I have gotten, but it doesn’t work because I don’t know what I am doing. Most of you will know immediately what is wrong. Would you please help me fix this code so it works?
Thanks so much!
activate application "Keynote"
tell application "System Events"
tell process "Keynote"
set thisSlide to current slide
tell thisSlide
set the transition properties to
{transition effect:dissolve, transition duration:1.0, transition delay:0, automatic transition:false}
end
end tell
end tell
Your code looks like GUI Scripting (“System Events”, tell process “Keynote”). For direct Keynote scripting You must use tell application “Keynote”:
tell application "Keynote"
set thisSlide to current slide
tell thisSlide
set the transition properties to {transition effect:dissolve, transition duration:1.0, transition delay:0, automatic transition:false}
end tell
end tell
@spherico you were right, I had to adjust the very helpful code and advice from @Dirk to include the document. It works!
tell front document
set thisSlide to current slide
tell thisSlide
set the transition properties to {transition effect:dissolve, transition duration:1.0, transition delay:0, automatic transition:false}
end tell
end tell
end tell
The only issue I have left is selecting a range. Instead of current slide how to I write it so that it affects “whatever slides happen to be selected at the moment”?
You can try this, but I don’t know how can I detect if the selection is not a slide without the error routine. But I think it work’s:
tell application "Keynote"
tell front document
try
set theSlides to selection
repeat with theSlide in theSlides
set the transition properties of theSlide to {transition effect:dissolve, transition duration:1.0, transition delay:0, automatic transition:false}
end repeat
on error errMsg number errNum
-- no slide selected
end try
end tell
end tell