1
votes

I need my Mac to say the number of the current slide when presenting. I've written the below script, but it's not working as expected.

on slideNumber()
    tell application "Keynote"
        return the slide number of the current slide of the front document
    end tell
end slideNumber

repeat
    say slideNumber()
    delay 1
end repeat

When I run this is will correctly say the current slide number in Keynote, however if I go to Keynote and change slides, or start presenting the slides, the Applescript doesn't update the slide number. If I go back to the Applescript window it immediately starts saying the correct slide number.

I've also tried this using:

on idle
    say slideNumber()
    return 1
end idle

and exporting as a stay-open application, but the same problem occurs.

Is it not possible to have the Applescript application return the correct slide number without the application/script being in the foreground? I'm using Keynote 6.2 if that's relevant.

1

1 Answers

0
votes

I realize this question is old. For what it's worth, having seen it just now, your script works perfectly fine for me. I'm on macOS Sierra (10.12.1) using Keynote version 7.0.5. Copy/pasted your script into Script Editor and ran it. Speaks correct slide number as I switch between slides both in edit mode and while presenting.

Could there have been something wrong with the scripting interface of Keynote 6.2? I have seen cases where a buggy app just doesn't do what it advertises, and a later version fixes it. Do you still specifically need this to run against Keynote 6.2?