Last active
August 29, 2015 13:56
-
-
Save patridge/8944332 to your computer and use it in GitHub Desktop.
PowerPoint slide screenshots via AppleScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tell application "Microsoft PowerPoint" | |
activate | |
set slideShow to run slide show slide show settings of active presentation | |
set finalShotSize to 250 | |
set oPres to active presentation | |
set desktopPath to (path to desktop) | |
set N to 1 | |
-- Give presentation enough time to start. | |
delay 0.5 | |
-- Loop over all slides in the presentation, setting currentSlide to the current slide in each loop. | |
repeat with currentSlide in (get every slide of oPres) | |
-- Get a path for capture. | |
set picPath to "/Users/{yourusername}/Desktop/Slides/Slide_" & N & ".png" | |
-- Setting to same path will overwrite original, if you don't need the original. | |
set picSmallPath to "/Users/{yourusername}/Desktop/Slides/Slide_" & N & "_small.png" | |
-- Run console command to trigger screencapture. | |
do shell script "screencapture -tpng " & quoted form of picPath | |
-- -R<x,y,w,h> (capture rect) | |
-- -s (mouse selection mode) | |
-- -w (window selection mode) | |
-- -c (capture to clipboard) | |
-- Give screenshot enough time to finish. | |
delay 0.3 | |
-- Resize image to desired size. | |
-- NOTE: Does not verify final size is smaller. | |
tell application "Image Events" | |
set capturedImage to open picPath | |
scale capturedImage to size finalShotSize | |
save capturedImage in picSmallPath | |
close capturedImage | |
end tell | |
set N to N + 1 | |
--tell active presentation to set currentSlide to slide N | |
tell application "System Events" | |
-- Press the space bar to advance slide | |
key code 49 | |
end tell | |
-- Give slide change enough time to finish. | |
delay 0.3 | |
end repeat | |
end tell |
Added ability to resize to desired final image width, scaled proportionally. Just set finalShotSize
in the first variables to adjust (or remove that section entirely, if you don't like it).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
NOTE: This probably fails spectacularly if you use any sort of animations/transitions. (EDIT: Current, this definitely fails with click-triggered animations. It also takes an extra shot for every hidden slide since the count doesn't exclude them.)