I dislike UI Browser because it build scripts dedicated to a single localized version and I hate such scripts.
Here is an edited version usable worldwide.
Don’t be afraid if it appears to be long, it’s just that I left instructions useful for tests and of course it’s commented.
tell application "Installation OS X 10.9 - 10.9:Applications:Keynote.app:"
activate
set slideCount to count of slides of document 1
end tell
# Since 10.6 we are urged to no longer call an OSAX (here Standard Additions) from a tell application block !
# SystemUIServer is the exception confirming the rule ;-)
tell application "SystemUIServer" to set theSlideNo to text returned of (display dialog "Please enter a slide number between 1 - " & slideCount & " to export" default answer "") as integer
# If theSlideNo is too big, set it to slideCount
if theSlideNo ≥ slideCount then set theSlideNo to slideCount
# Activate is required again due to the preceeding tell to SystemUIServer
tell application "Installation OS X 10.9 - 10.9:Applications:Keynote.app:" to activate
tell application "System Events" to tell (first process whose frontmost is true)
# I use the pathname and (first process whose frontmost is true)
# because here, the app used currently is Keynote 5.3
# Coding this way I'm sure that I use the 6.1 one.
click window 1 # seems to be useless
tell menu bar 1
# name of every menu bar item # just for tests
--> {"Apple", "Keynote", "Fichier", "Édition", "Insertion", "Diapositive", "Format", "Disposition", "Présentation", "Lecture", "Partage", "Fenêtre", "Aide"}
set SlideIndex to 6
# name of every menu item of menu 1 of menu bar item SlideIndex # just for tests
--> {"Nouvelle diapositive", missing value, "Ignorer la diapositive", missing value, "Développer", "Tout développer", "Condenser", "Tout condenser", missing value, "Afficher les numéros de diapo sur toutes les diapos", missing value, "Copier les guides", "Coller les guides", missing value, "Aller à "}
set GotoIndex to -1
# name of every menu item of menu 1 of menu item GotoIndex of menu 1 of menu bar item SlideIndex # just for tests
--> {"Diapositive suivante", "Diapositive précédente", missing value, "Première diapositive", "Dernière diapositive"}
set nextSlideIndex to 1
set firstSlideIndex to 4
tell menu 1 of menu item GotoIndex of menu 1 of menu bar item SlideIndex
# name of menu item firstSlideIndex # just for tests
--> "Première diapositive"
enabled of menu item firstSlideIndex
if result then click menu item firstSlideIndex # If needed, jump to 1st slide
# name of menu item nextSlideIndex # just for tests
--> "Diapositive suivante"
# Now advance to slice index theSlideNo
repeat (theSlideNo - 1) times
click menu item nextSlideIndex
end repeat
end tell # menu 1 .
end tell # menu bar 1
end tell # System Events & process
My original script wasn’t using GUIScripting because I assumed that you wanted to grab notes from every slides. :rolleyes:
Yvan KOENIG (VALLAURIS, France) mardi 11 février 2014 18:49:33