Request for help with Keynote automation

I’m a university professor, now working from home, and I want to record some slick Keynote presentations for my students. I like the style of the ‘talking head’ in the lower corner of the slide and I will probably do this by recording my screen with Screencast-o-matic and its chroma key (green screen) function.

However, if I put my talking head in the corner of the slide, I will inevitably cover up some information on some slides, so I would like to edit my slides to make them wider and then move all the elements a fixed amount to the left. Making the slides wider is easy - if you make the slides a custom size in ‘Document’ within Keynote. If the height remains unchanged, all the slide elements remain unchanged with a border now down the left and the right. What I would like to do is select all the elements on the slide (text, shapes, images, whatever), and move them 200 pixels to the left. Then move to the next slide and do the same. Repeat until the end.

I’ve reviewed iworkautomation.com and the Keynote section and it looks like Applescript has this capability but I don’t have the experience to execute this. Any tips please?

This should get you started. Another possibly simpler solution would be to create a new theme with your preferred layout and then switch your presentation to use that theme.

tell application "Keynote"
	-- optionally set the width via script
	set width of document 1 to 2320
	-- real work happens here
	set s to slides of document 1
	repeat with currentSlide in s
		set i to iWork items of currentSlide
		repeat with currentItem in i
			set theLoc to position of currentItem
			set x to item 1 of theLoc
			set y to item 2 of theLoc
			if x > 200 then
				set x to x - 200
			else
				set x to 0
			end if
			set position of currentItem to {x, y}
		end repeat
	end repeat
end tell

This works perfectly. Thanks so much!

1 Like