How to do this in powerpoint

Subject: Help with Keyboard Maestro for PowerPoint Animations

Hi,

I'm new to Keyboard Maestro but have already made some cool macros. I love this app!

I'm a teacher and use PowerPoint for listening exercises. I need to add sound to each slide and have some macros for inserting audio files, which work great.

Now, I need some help with changing settings in the animations pane. Here are the steps I want to automate:

  1. Click on the audio file
  2. Select "Timing"
  3. Click on "Start with previous"
  4. Set the delay to 1 second
  5. Click on the second audio file
  6. Select "Timing"
  7. Click on "After previous"
  8. Set the delay to 2 seconds

Any ideas?

Thanks a lot!

CleanShot 2024-08-03 at 05.55.30@2x

I am sure there is a more elegant way to do this. It almost works. The first time I type the hotkey, it doesn't go to the right place. I type the hotkey once again, and it works. Any help?

I haven't experimented much, and I'm not sure whether the corresponding properties of the shape animation settings are, in fact:

  • animation order :: integer
  • advance time :: real

but it may be possible to do this kind of thing fairly directly with a Keyboard Maestro Execute AppleScript action:

A first draft experiment, assuming that there are two sound shapes on the active slide, might look something like:

Animations settings for two sound shapes on active slide.kmmacros (3.5 KB)


Draft AppleScript Source:

tell application "Microsoft PowerPoint"
    set activePresn to its active presentation
    tell first document window
        tell its selection
            tell its slide range
                set slideIndex to slide index
                tell slide slideIndex of activePresn
                    
                    script go
                        on |λ|(pair)
                            set {t, shp} to pair
                            
                            if media type sound = t then
                                {shp}
                            else
                                {}
                            end if
                        end |λ|
                    end script
                    
                    set xs to my zip(media type of its shapes, its shapes)
                    set {a, b} to my concatMap(go, xs)
                    
                    tell animation settings of a
                        set animation order to 1
                        set advance time to 1.0
                    end tell
                    
                    tell animation settings of b
                        set animation order to 2
                        set advance time to 2.0
                    end tell
                    
                    "Animation orders::1, 2  advance times::1.0, 2.0"
                end tell
            end tell
        end tell
    end tell
end tell


------------------------- GENERIC ------------------------


-- concatMap :: (a -> [b]) -> [a] -> [b]
on concatMap(f, xs)
    set lng to length of xs
    set acc to {}
    
    tell mReturn(f)
        repeat with i from 1 to lng
            set acc to acc & (|λ|(item i of xs, i, xs))
        end repeat
    end tell
    acc
end concatMap


-- min :: Ord a => a -> a -> a
on min(x, y)
    if y < x then
        y
    else
        x
    end if
end min


-- mReturn :: First-class m => (a -> b) -> m (a -> b)
on mReturn(f)
    -- 2nd class handler function lifted into 1st class script wrapper. 
    if script is class of f then
        f
    else
        script
            property |λ| : f
        end script
    end if
end mReturn


-- zip :: [a] -> [b] -> [(a, b)]
on zip(xs, ys)
    set n to min(length of xs, length of ys)
    
    set lst to {}
    repeat with i from 1 to n
        set end of lst to {item i of xs, item i of ys}
    end repeat
    return lst
end zip

PS

Looks like advance time is indeed the script property corresponding to the GUI "delay"

BUT experimentally, setting an animation order value doesn't suffice to set the GUI Start :: (After | With Previous) option.

Not sure whether anyone else has experimented with scripting this.

I would have expected it to be possible through the osascript (AppleScript | JavaScript) interface somehow.