Automates Apple Keynote using JXA with AppleScript dictionary discovery...
automating-mac-apps for cross-app workflows or general macOS scripting foundations.automating-mac-apps skill (PyXA Installation section)..name(), write with assignments.Path() function is required when specifying file paths to Keynote (e.g., for images, exports, or opening documents). Use Path("/path/to/file") instead of plain strings.tell application "Keynote" to get name of document 1.Application("Keynote").documents[0].name() with try-catch blocks.Application("Keynote").documents.length > 0.Application("System Events")).Prototype (AppleScript):
tell application "Keynote"
get name of document 1
end tell
Production (JXA):
const keynote = Application("Keynote");
if (keynote.documents.length > 0) {
console.log(keynote.documents[0].name());
}
Create Slide:
const doc = keynote.documents[0];
const slide = doc.slides.push(keynote.Slide({baseSlide: doc.masterSlides['Title - Center']}));
slide.defaultTitleItem.objectText = "New Slide";
Add Image to Slide (note Path() usage):
const slide = doc.slides[0];
const img = keynote.Image({
file: Path("/Users/you/Desktop/diagram.png"), // Path() required!
position: { x: 100, y: 100 },
width: 800
});
slide.images.push(img);
After implementing Keynote automation:
Path() functionautomating-keynote/references/keynote-basics.mdautomating-keynote/references/keynote-recipes.mdautomating-keynote/references/keynote-deck-generator.mdautomating-keynote/references/keynote-chart-aware-deck.mdautomating-keynote/references/keynote-advanced.mdautomating-keynote/references/keynote-pyxa.mdautomating-keynote/references/keynote-pyxa-api-reference.md