Thursday, December 3, 2020

#1 2020-02-02 05:39:45 pm

BitCy
Member
Registered: 2020-01-12
Posts: 11

Keynote - Movie Export Droplet with ProRes 4444 @ 1920 x 1080

Hello,

I found this Keynote - Movie Export Droplet, that would allow me to export a keynote to mp4.

https://iworkautomation.com/keynote/exa … oplet.html

I am would like to know how can I tweak the code that would allow me to export the Keynote into ProRes 4444 at 1920 x 1080 with Transparency checked.

Keynote-Export.jpg

How can I tweak the code? I have no knowledge of Applescript or coding.

Thank you.

Applescript:


property destinationFolder : (path to movies folder)

on run
   -- TRIGGERED WHEN USER LAUNCHES DROPLET. PROMPT FOR PRESENTATION FILE(S):
   set theseItems to ¬
       (choose file of type "com.apple.iwork.keynote.key" with prompt ¬
           "Pick the Keynote presentation(s) to export to movie:" with multiple selections allowed)
   open theseItems
end run

on open theseItems
   -- TRIGGERED WHEN USER DRAGS ITEMS ONTO THE DROPLET
   display dialog "This droplet will export dragged-on Keynote presentation files as movies to the Movies folder." & return & return & "The movies will be encoded to MPEG format using H.264 compression." with icon 1
   set the filesToProcess to {}
   -- filter the dragged-on items for Keynote presentation files
   repeat with i from 1 to the count of theseItems
       set thisItem to item i of theseItems
       if my checkForIdentifier(thisItem, "com.apple.iwork.keynote.key") is true then
           set the end of the filesToProcess to thisItem
       end if
   end repeat
   if filesToProcess is {} then
       activate
       display alert "INCOMPATIBLE ITEMS" message "None of the items were Keynote presentations."
   else
       -- process the presentations
       my exportPresentationsToMovies(filesToProcess)
   end if
end open

on checkForIdentifier(thisItem, thisIdentifier)
   try
       -- uses Spotlight to check for specified item type
       set the queryResult to ¬
           (do shell script "mdls -name kMDItemContentType " & ¬
               quoted form of the POSIX path of thisItem)
       if queryResult contains "(null)" then
           return false
       else
           set x to the length of "kMDItemContentType = \""
           set the indentifierString to text (x + 1) thru -2 of queryResult
           if the indentifierString is thisIdentifier then
               return true
           end if
       end if
   on error
       return false
   end try
end checkForIdentifier

on exportPresentationsToMovies(thesePresentations)
   try
       repeat with i from 1 to the count of thesePresentations
           set thisPresentation to item i of thesePresentations
           tell application "Keynote"
               activate
               if playing is true then tell front document to stop
               open thisPresentation
               set the documentName to name of the front document
               copy my deriveFileNameForNewFileInFolder(documentName, destinationFolder) to ¬
                   {targetName, targetPOSIXpath}
               set destinationFile to (targetPOSIXpath as POSIX file)
               with timeout of 1200 seconds -- 20 minutes
                   export front document to destinationFile ¬
                       as QuickTime movie with properties {movie format:large}
               end timeout
               close front document saving no
           end tell
           display notification documentName with title "Keynote Movie Export"
       end repeat
   on error errorMessage
       activate
       display alert "EXPORT ERROR" message errorMessage
       error number -128
   end try
end exportPresentationsToMovies

on deriveFileNameForNewFileInFolder(sourceItemBaseName, targetFolderHFSAlias)
   -- UNIX routine that derives a none-conflicting file name
   set targetFolderPOSIXPath to (POSIX path of targetFolderHFSAlias)
   set incrementSeparator to "-"
   set targetExtension to "m4v"
   set extensionSeparator to "."
   
   set targetName to sourceItemBaseName & extensionSeparator & targetExtension
   set targetItemPOSIXPath to targetFolderPOSIXPath & targetName
   set the fileExistenceStatus to ¬
       (do shell script "[ -a " & (quoted form of targetItemPOSIXPath) & ¬
           " ] && echo 'true' || echo 'false'") as boolean
   if fileExistenceStatus is true then
       set the nameIncrement to 1
       repeat
           -- create a new target path with the target item name incremented
           set the newName to ¬
               (the sourceItemBaseName & incrementSeparator & ¬
                   (nameIncrement as Unicode text) & ¬
                   extensionSeparator & targetExtension) as Unicode text
           set targetItemPOSIXPath to targetFolderPOSIXPath & newName
           set the fileExistenceStatus to ¬
               (do shell script "[ -a " & (quoted form of targetItemPOSIXPath) & ¬
                   " ] && echo 'true' || echo 'false'") as boolean
           if fileExistenceStatus is true then
               set the nameIncrement to the nameIncrement + 1
           else
               set the targetPOSIXpath to (targetFolderPOSIXPath & newName)
               return {newName, targetPOSIXpath}
           end if
       end repeat
   else
       set the targetPOSIXpath to (targetFolderPOSIXPath & targetName)
       return {targetName, targetPOSIXpath}
   end if
end deriveFileNameForNewFileInFolder

Offline

 

#2 2020-02-04 11:31:21 pm

BitCy
Member
Registered: 2020-01-12
Posts: 11

Re: Keynote - Movie Export Droplet with ProRes 4444 @ 1920 x 1080

Any experts to share advice on this? Thank you.

Offline

 

#3 2020-02-05 05:14:28 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 4575

Re: Keynote - Movie Export Droplet with ProRes 4444 @ 1920 x 1080

My iMac is unable to run the late version o Keynote but I will try to help you step by step.

Here is a point of departure which is supposed to be executed with a Keynote document open.

Applescript:

tell application "Keynote"
   set exportTo_loc to localized string "1543.title" from table "MainMenu" --> "Exporter vers"
end tell

set {mt, mi, ms} to {3, 14, 3}
tell application id "com.apple.systemevents" to tell process "Keynote"
   set frontmost to true
   tell menu bar 1
       get name of menu bar items --> {"Apple", "Keynote", "Fichier", "Édition", "Insérer", "Diapositive", "Format", "Disposition", "Présentation", "Lecture", "Partager", "Fenêtre", "Aide"}
       get name of menu bar item mt --> "Fichier"-- {"Tableau"}
       tell menu bar item mt to tell menu 1
           get name of menu items --> {"Nouveau", "Créer à partir de la liste de thèmes…", "Ouvrir…", "Ouvrir un document récent", missing value, "Fermer", "Tout fermer", "Enregistrer", "Enregistrer sous…", "Dupliquer", "Renommer…", "Déplacer vers…", "Revenir à", "Exporter vers", missing value, "Réduire la taille du fichier…", "Avancé", missing value, "Définir un mot de passe…", missing value, "Modifier le thème…", "Enregistrer le thème…", missing value, "Imprimer…"}
           get name of menu item mi --> "Exporter vers"
           tell menu item mi to tell menu 1
               get name of menu items --> {"PDF…", "PowerPoint…", "Vidéo…", "GIF animé…", "Images…", "HTML…", "Keynote ’09…"}
               get name of menu item ms --> "Vidéo…"
               click menu item ms
           end tell -- menu item…
       end tell -- menu bar item mt
   end tell -- menu bar 1
   (*
   tell window 1
       class of UI elements --> {radio group, checkbox, static text, scroll area, scroll area, scroll area, button, button, button, menu button, toolbar, image, static text, sheet}
       tell sheet 1
           class of UI elements --> {static text, list, static text, pop up button, static text, text field, static text, static text, text field, static text, static text, static text, text field, static text, text field, radio button, radio button, static text, pop up button, static text, button, button, button}
       end tell
   end tell
   *)

end tell -- System Events

What is returned by the instruction
get name of menu items --> {"PDF…", "PowerPoint…", "Vidéo…", "GIF animé…", "Images…", "HTML…", "Keynote ’09…"}
I assume that it return different strings. Which are there ?

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mercredi 5 février 2020  12:13:18

Offline

 

#4 2020-02-05 05:53:19 am

Nigel Garvey
Moderator
From:: Warwickshire, England
Registered: 2002-11-20
Posts: 5313

Re: Keynote - Movie Export Droplet with ProRes 4444 @ 1920 x 1080

BitCy.

Just to explain that what you want isn't possible using Keynote's own AppleScript implementation. The only hope is to use "GUI Scripting", ie. faking the clicking of menu items and buttons in the application as it appears on screen. This is a bit of a hit-or-miss process as an application's layout and text content can vary from version to version, system to system, and user preference to user preference.

Yvan's script is simply a test to find out what's in your menus when running in English. On my machine (running Keynote 9.2.1 in Mojave), it also opens the "Export Your Presentation" sheet with the "Movie" pane selected. If you run it with a Keynote document open and look in Script Editor's "Replies" pane, you should see something like the following, which could help Yvan to develop a script for you:

Applescript:

tell application "Keynote"
   localized string "1543.title" from table "MainMenu"
       --> error number -1708
   «event ascrgdut»
       --> error number -1708
   localized string "1543.title" from table "MainMenu"
       --> "Export To"
end tell
tell application "System Events"
   set frontmost of process "Keynote" to true
   get name of every menu bar item of menu bar 1 of process "Keynote"
       --> {"Apple", "Keynote", "File", "Edit", "Insert", "Slide", "Format", "Arrange", "View", "Play", "Share", "Window", "Help"}
   get name of menu bar item 3 of menu bar 1 of process "Keynote"
       --> "File"
   get name of every menu item of menu 1 of menu bar item 3 of menu bar 1 of process "Keynote"
       --> {"New…", "New…", "Open…", "Open Recent", missing value, "Close", "Close All", "Save…", "Save As…", "Duplicate", "Rename…", "Move To…", "Revert To", "Export To", missing value, "Reduce File Size…", "Advanced", missing value, "Set Password…", missing value, "Change Theme...", "Save Theme…", missing value, "Print…"}
   get name of menu item 14 of menu 1 of menu bar item 3 of menu bar 1 of process "Keynote"
       --> "Export To"
   get name of every menu item of menu 1 of menu item 14 of menu 1 of menu bar item 3 of menu bar 1 of process "Keynote"
       --> {"PDF…", "PowerPoint…", "Movie…", "Animated GIF…", "Images…", "HTML…", "Keynote ’09…"}
   get name of menu item 3 of menu 1 of menu item 14 of menu 1 of menu bar item 3 of menu bar 1 of process "Keynote"
       --> "Movie…"
   click menu item 3 of menu 1 of menu item 14 of menu 1 of menu bar item 3 of menu bar 1 of process "Keynote"
       --> menu item "Movie…" of menu "Export To" of menu item "Export To" of menu "File" of menu bar item "File" of menu bar 1 of application process "Keynote"
end tell
Result:
menu item "Movie…" of menu "Export To" of menu item "Export To" of menu "File" of menu bar item "File" of menu bar 1 of application process "Keynote" of application "System Events"


NG

Offline

 

#5 2020-02-05 10:00:07 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 4575

Re: Keynote - Movie Export Droplet with ProRes 4444 @ 1920 x 1080

Thank you Nigel. You gave useful infos.

Here is where I am.

Applescript:

(*
-- code dropped because it doesn't apply when the app is used in French.
Apple forgot to insert the file: "Keynote.app:Contents:Resources:fr.lproj:MainMenu.strings". They put a MainMenu.nib file.
Happily, there is a clone available as :
"Keynote.app:Contents:Resources:fr_CA.lproj:MainMenu.strings"
On my copy I duplicated the file so now the code works.
Maybe the file is available in versions newer than 9.1
Same odd omission in Pages and Numbers
As the numbering of menu items doesn't change since several years, I choose to trigger the menu items by their index.

tell application "Keynote"
   set exportTo_loc to localized string "1543.title" from table "MainMenu" --> "Exporter vers"
end tell
*)


set indexFile to 3 -- index of menu "File" ("Fichier")
set indexExportTo to 14 -- index of menu item "Export To" ("Exporter vers")
set indexMovie to 3 -- index of menu item "Movie…" ("Vidéo…")

tell application id "com.apple.systemevents" to tell process "Keynote"
   set frontmost to true
   tell menu bar 1
       -- get name of menu bar items --> {"Apple", "Keynote", "Fichier", "Édition", "Insérer", "Diapositive", "Format", "Disposition", "Présentation", "Lecture", "Partager", "Fenêtre", "Aide"}
       -- get name of menu bar item indexFile --> "Fichier"
       tell menu bar item indexFile to tell menu 1
           -- get name of menu items --> {"Nouveau", "Créer à partir de la liste de thèmes…", "Ouvrir…", "Ouvrir un document récent", missing value, "Fermer", "Tout fermer", "Enregistrer", "Enregistrer sous…", "Dupliquer", "Renommer…", "Déplacer vers…", "Revenir à", "Exporter vers", missing value, "Réduire la taille du fichier…", "Avancé", missing value, "Définir un mot de passe…", missing value, "Modifier le thème…", "Enregistrer le thème…", missing value, "Imprimer…"}
           -- get name of menu item indexExportTo --> "Exporter vers"
           tell menu item indexExportTo to tell menu 1
               -- get name of menu items --> {"PDF…", "PowerPoint…", "Vidéo…", "GIF animé…", "Images…", "HTML…", "Keynote ’09…"}
               -- get name of menu item indexMovie --> "Vidéo…"
               click menu item indexMovie
           end tell -- menu item indexMovie
       end tell -- menu bar item indexFile
   end tell -- menu bar 1
   -- class of UI elements
   tell (first window whose subrole is "AXStandardWindow") -- EDITED
       
       class of UI elements --> {radio group, checkbox, static text, scroll area, scroll area, scroll area, button, button, button, menu button, toolbar, image, static text, sheet}
       
       
       tell sheet 1
           -- class of UI elements --> {static text, list, static text, pop up button, static text, text field, static text, static text, text field, static text, static text, static text, text field, static text, text field, radio button, radio button, static text, pop up button, static text, button, button, button}
           -- help of text fields --> {"Saisissez le nombre de secondes d’attente entre chaque diapositive.", "Saisissez le nombre de secondes d’attente entre chaque composition.", missing value, missing value} -- ADDED
           set value of text field 1 to "10" -- must be a string -- ADDED
           set value of text field 2 to "8" -- must be a string -- ADDED
           
           -- help of pop up button 1 --> "Choisissez le mode de lecture de la vidéo."
           -- help of pop up button 2 --> "Choisissez une taille pour la vidéo."
           tell pop up button 2
               its value --> "1024 x 768"
               click it
               repeat 50 times
                   if exists menu 1 then exit repeat
                   delay 0.2
               end repeat
               tell menu 1
                   -- class of UI elements --> {menu item, menu item, menu item, menu item}
                   -- name of menu items --> {"1024 x 768", "720p", "1080p", "Personnaliser…"}
                   click menu item -1 -- Custom
               end tell
           end tell
           set checkBoxAvailable to (class of UI elements) contains checkbox --> {static text, list, static text, pop up button, static text, text field, static text, static text, text field, static text, static text, static text, text field, static text, text field, radio button, radio button, static text, pop up button, text field, static text, text field, static text, static text, checkbox, radio button, radio button, radio button, button, button, button}
           
           -- help of text field -2 --> "Saisissez la largeur voulue pour la vidéo."
           -- help of text field -1 --> "Saisissez la hauteur voulue pour la vidéo."
           -- value of text field -2 --> "1024"
           -- value of text field -1 --> "768"
           set value of text field -2 to "1920" -- must be a string
           set value of text field -1 to "1080" -- must be a string
           
           -- name of radio button -3 --> "Apple ProRes 422"
           -- name of radio button -2 --> "H.264"
           -- name of radio button -1 --> "Apple ProRes 4444"
           click radio button -1
           if checkBoxAvailable then
               -- name of checkbox 1 --> "Exporter avec des arrière-plans transparents"
               value of checkbox 1 --> 1
               
               -- set value of checkbox 1 to 1 -- enable it to check the box
               -- set value of checkbox 1 to 0 -- enable it to uncheck the box
           end if
           
       end tell -- sheet 1
       
   end tell
end tell -- System Events

As is, the script selects the Custom… format
then it define the width (1920) and the height (1080) of the window
and select the compression Apple ProRes 4444.
It lets the checkbox linked to transparency as is but it contain the instructions required to edit the setting.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mercredi 5 février 2020  16:58:08

Last edited by Yvan Koenig (2020-03-17 04:44:49 am)

Offline

 

#6 2020-02-05 06:17:29 pm

BitCy
Member
Registered: 2020-01-12
Posts: 11

Re: Keynote - Movie Export Droplet with ProRes 4444 @ 1920 x 1080

Thank you, Yvan Koenig and Nigel Garvey!!! Wow! It is brilliant.:D

I have made Quick Action from Automator using this script. Works flawlessly!

Thank you again, and really appreciate!

Offline

 

#7 2020-03-16 05:32:50 pm

BitCy
Member
Registered: 2020-01-12
Posts: 11

Re: Keynote - Movie Export Droplet with ProRes 4444 @ 1920 x 1080

Hello Yvan Koenig,

I am trying to update and improve this script but I am lost.

Keynote-Menus.jpg

How can I add this two fields as well? "Go to next slide after:" and "Go to next build after:", Say if I want to always make that at 1 sec.


Thank you, Yvan Koenig. smile

Offline

 

#8 2020-03-17 01:11:57 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 4575

Re: Keynote - Movie Export Droplet with ProRes 4444 @ 1920 x 1080

I added the 3 needed instructions in the script given in message #5.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mardi 17 mars 2020  08:11:52

Offline

 

#9 2020-03-17 02:36:32 am

BitCy
Member
Registered: 2020-01-12
Posts: 11

Re: Keynote - Movie Export Droplet with ProRes 4444 @ 1920 x 1080

Yvan Koenig wrote:

I added the 3 needed instructions in the script given in message #5.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mardi 17 mars 2020  08:11:52



Thank you Yvan! Really Appreciate it!

I have one final question. Sometimes or rather most of the times in Keynote, I will have multiple floating windows open. Like Colour Picker, Build Order, and Font List. I notices that this script will not work when floating windows from Keynote are open.

Here is the error message.

Error.jpg

How can we fix this?

Thank you, Yvan!

Offline

 

#10 2020-03-17 04:49:09 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 4575

Re: Keynote - Movie Export Droplet with ProRes 4444 @ 1920 x 1080

I was upon that when I saw your question.

replace the instruction

Applescript:

tell window 1

by

Applescript:

tell (first window whose subrole is "AXStandardWindow")

message #5 is edited accordingly.

Is it useful to add a test issuing a warning if the radio buttons related to compression aren't available ?

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mardi 17 mars 2020  11:49:03

Offline

 

#11 2020-03-17 05:43:37 pm

BitCy
Member
Registered: 2020-01-12
Posts: 11

Re: Keynote - Movie Export Droplet with ProRes 4444 @ 1920 x 1080

Yvan Koenig wrote:

I was upon that when I saw your question.

replace the instruction

Applescript:

tell window 1

by

Applescript:

tell (first window whose subrole is "AXStandardWindow")

message #5 is edited accordingly.

Is it useful to add a test issuing a warning if the radio buttons related to compression aren't available ?

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mardi 17 mars 2020  11:49:03




Thank you for the fix Yvan! Awesome and really appreciate it!

I don't think it would be useful for the warning as the radio buttons related to compression will always be available since we are in Custom mode.

Thanks for the help, Yvan! smile

Offline

 

#12 2020-03-24 07:50:35 pm

BitCy
Member
Registered: 2020-01-12
Posts: 11

Re: Keynote - Movie Export Droplet with ProRes 4444 @ 1920 x 1080

Hello Yvan,

I notice a bug and an issue in the script. I am not really sure what is causing it.

When I set both field to 1 and 0, and each time I export the keynote, the video file gets much longer. I have to manually enter 1 and 0 in the keynote movie export to export it out correctly.

Applescript:


           set value of text field 1 to "1" -- must be a string -- ADDED
           set value of text field 2 to "0" -- must be a string -- ADDED

I am wondering, what is causing the issue? Is there a way to fix this?

Thank you.

Offline

 

#13 2020-03-24 09:25:13 pm

KniazidisR
Member
From:: Greece
Registered: 2019-03-03
Posts: 1457

Re: Keynote - Movie Export Droplet with ProRes 4444 @ 1920 x 1080

The disease of many experienced programmers is that they cannot convey the essence to inexperienced in a simple way. I hope most like the English interface, just like me. Although I perfectly know Russian, Greek, Georgian.

For example, if you use a simple programming language, then the above scripts can be reduced to this. Just compare with your monsters:

Applescript:


tell application id "com.apple.systemevents" to tell process "Keynote"
   
   set frontmost to true
   tell menu bar 1 to tell menu bar item "File" to tell menu 1
       tell menu item "Export To" to tell menu 1 to click menu item "Movie…"
   end tell
   
   delay 0.1
   tell window 1 to tell sheet 1
       set value of 1st text field whose help is "Type how many seconds to wait between slides." to "10"
       set value of 1st text field whose help is "Type how many seconds to wait between builds." to "8"
       
       tell (1st pop up button whose help is "Choose a size for the movie.")
           perform action "AXShowMenu"
           delay 0.1
           click menu item "Custom..." of menu 1
       end tell
       set value of 1st text field whose help is "Type the width you want for the movie." to "1920"
       set value of 1st text field whose help is "Type the height you want for the movie." to "1080"
       
       click (1st radio button whose title is "Apple ProRes 4444")
       delay 0.1
       click button "Next…"
   end tell
   
end tell

Last edited by KniazidisR (2020-03-24 10:23:15 pm)


Model: MacBook Pro
OS X: Catalina 10.15.4
Web Browser: Safari 13.1
Ram: 4 GB

Offline

 

#14 2020-03-25 12:04:29 am

KniazidisR
Member
From:: Greece
Registered: 2019-03-03
Posts: 1457

Re: Keynote - Movie Export Droplet with ProRes 4444 @ 1920 x 1080

Here is your original script without GUI scripting. I fixed in it 2 errors and it works now.

1) For the movie export format you have 4 constants: small, medium, large, native size.  They respond to 360p, 540p, 720p, native size. You should use always KeyNote's constant (for exapmple, instead of 720p you should use large. The compiler automatically changes it to italic 720p, but now it is what should be. (That is, it is other, proper 720p). If you do not make changes in the script in future, it remains correct. If you change the script, always put large again, to fix the issue again. This was first error.

2) Correct UTI of keyNote document is "com.apple.iwork.keynote.sffkey" and not "com.apple.iwork.keynote.key". This was second error.

3) Filtering process is simpler (see here). Handler checkForIdentifier no need at all.

4) No need Posix files, Posix paths and do shell scripts...


Your fixed script (I use native size, you can use small, medium, large instead):

Applescript:


property destinationFolder : (path to desktop folder)

on run
   -- TRIGGERED WHEN USER LAUNCHES DROPLET. PROMPT FOR PRESENTATION FILE(S):
   set theItems to (choose file of type "com.apple.iwork.keynote.sffkey" with prompt "Pick the Keynote presentation(s) to export to movie:" with multiple selections allowed)
   open theItems
end run

on open theItems
   -- TRIGGERED WHEN USER DRAGS ITEMS ONTO THE DROPLET
   display dialog "This droplet will export dragged-on Keynote presentation files as movies" & return & return & "The movies will be encoded to MPEG format using H.264 compression." with icon 1
   set filesToProcess to {}
   -- filter the dragged-on items for Keynote presentation files
   repeat with anItem in theItems
       tell application id "com.apple.systemevents" to set anUTI to type identifier of anItem
       if anUTI is "com.apple.iwork.keynote.sffkey" then set the end of the filesToProcess to anItem
   end repeat
   if filesToProcess is {} then
       activate
       display alert "INCOMPATIBLE ITEMS" message "None of the items were Keynote presentations."
   else
       -- process the presentations
       my exportPresentationsToMovies(filesToProcess)
   end if
end open

on exportPresentationsToMovies(thePresentations)
   tell application "Keynote"
       activate
       if playing is true then tell front document to stop
       try
           repeat with aPresentation in thePresentations
               open aPresentation
               set the documentName to name of the front document
               set destinationFile to my deriveFileNameForNewFileInFolder(documentName, destinationFolder)
               with timeout of 1200 seconds -- 20 minutes
                   export front document to file destinationFile as QuickTime movie with properties {movie format:native size}
               end timeout
               close front document saving no
               display notification documentName with title "Keynote Movie Export"
           end repeat
       on error errorMessage
           activate
           display alert "EXPORT ERROR" message errorMessage
           error number -128
       end try
   end tell
end exportPresentationsToMovies

on deriveFileNameForNewFileInFolder(sourceItemBaseName, targetFolderHFSAlias)
   -- Routine that derives a none-conflicting file name
   set targetName to ((targetFolderHFSAlias & sourceItemBaseName) as text) & ".m4v"
   try
       alias targetName
   on error
       return targetName
   end try
   set n to 1
   repeat
       set targetName to ((targetFolderHFSAlias & sourceItemBaseName) as text) & "(" & n & ").m4v"
       try
           alias targetName
           set n to n + 1
       on error
           return targetName
       end try
   end repeat
end deriveFileNameForNewFileInFolder

Last edited by KniazidisR (2020-03-25 04:01:53 am)


Model: MacBook Pro
OS X: Catalina 10.15.4
Web Browser: Safari 13.1
Ram: 4 GB

Offline

 

#15 2020-03-25 03:56:08 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 4575

Re: Keynote - Movie Export Droplet with ProRes 4444 @ 1920 x 1080

KniazidisR wrote:


2) Correct UTI of keyNote document is "com.apple.iwork.keynote.sffkey" and not "com.apple.iwork.keynote.key".



I apologizes but you are wrong.

On my machine, keynote documents are given the UTI "com.apple.iwork.keynote.key".
Look at the file :
"Keynote.app:Contents:Info.plist"

You will learn that
Keynote Presentation document may be :
com.apple.iwork.keynote.key  -- package
com.apple.iwork.keynote.sffkey -- flat file
com.apple.iwork.keynote.key-tef -- package
com.apple.iwork.keynote.kpf -- package

You may run the script below to check that.

Applescript:

set theApp to path to application id "com.apple.iWork.Keynote"
set thePlist to ((theApp as text) & "Contents:Info.plist") as «class furl»
set answer to choose from list {"Xcode", "BBEdit"} with title "Choose the application to open the plist" with prompt "Xcode: look at the properties “Document types” " & linefeed & "BBEdit: look at keys “UTTypeConformsTo”"
if answer is false then error number -128
set opener to item 1 of answer as text
tell application opener to open thePlist

On my side I never see com.apple.iwork.keynote.kpf items
and my memory tell me that com.apple.iwork.keynote.key-tef are grabbed from docs generated under iOS (but it may be a wrong souvenir).

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mercredi 25 mars 2020  10:55:39

Offline

 

#16 2020-03-25 04:07:39 am

KniazidisR
Member
From:: Greece
Registered: 2019-03-03
Posts: 1457

Re: Keynote - Movie Export Droplet with ProRes 4444 @ 1920 x 1080

Yvan Koenig wrote:

You will learn that
Keynote Presentation document may be :
com.apple.iwork.keynote.key  -- package
com.apple.iwork.keynote.sffkey -- flat file
com.apple.iwork.keynote.key-tef -- package
com.apple.iwork.keynote.kpf -- package


Thanks for the info. I have only flat file presentations on my Mac. So, I can't test the last script with other UTIs. If it works, then we can provide the list of UTIs in choose file dialog, and we can check if the file's identifier is in the UTIs list in the on open handler.

Last edited by KniazidisR (2020-03-25 04:11:30 am)


Model: MacBook Pro
OS X: Catalina 10.15.4
Web Browser: Safari 13.1
Ram: 4 GB

Offline

 

#17 2020-03-25 04:40:47 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 4575

Re: Keynote - Movie Export Droplet with ProRes 4444 @ 1920 x 1080

When I posted a code asking for com.apple.iwork.keynote.key UTI, it's what I had as files available here.
I knew the com.apple.iwork.keynote.sffkey one but I forgot to insert it in the list passed to choose file.
Below is your completed script

Applescript:


property destinationFolder : (path to desktop folder)
property permittedUTIs : {"com.apple.iwork.keynote.key", "com.apple.iwork.keynote.sffkey", "com.apple.iwork.keynote.key-tef", "com.apple.iwork.keynote.kpf"} -- ADDED

on run
   -- TRIGGERED WHEN USER LAUNCHES DROPLET. PROMPT FOR PRESENTATION FILE(S):
   set theItems to (choose file of type permittedUTIs with prompt "Pick the Keynote presentation(s) to export to movie:" with multiple selections allowed) -- EDITED
   open theItems
end run

on open theItems
   -- TRIGGERED WHEN USER DRAGS ITEMS ONTO THE DROPLET
   display dialog "This droplet will export dragged-on Keynote presentation files as movies" & return & return & "The movies will be encoded to MPEG format using H.264 compression." with icon 1
   set filesToProcess to {}
   -- filter the dragged-on items for Keynote presentation files
   repeat with anItem in theItems
       tell application id "com.apple.systemevents" to set anUTI to type identifier of anItem
       if anUTI is in permittedUTIs then set the end of the filesToProcess to anItem -- EDITED
   end repeat
   if filesToProcess is {} then
       activate
       display alert "INCOMPATIBLE ITEMS" message "None of the items were Keynote presentations."
   else
       -- process the presentations
       my exportPresentationsToMovies(filesToProcess)
   end if
end open

on exportPresentationsToMovies(thePresentations)
   tell application "Keynote"
       activate
       if playing is true then tell front document to stop
       try
           repeat with aPresentation in thePresentations
               open aPresentation
               set the documentName to name of the front document
               set destinationFile to my deriveFileNameForNewFileInFolder(documentName, destinationFolder)
               with timeout of 1200 seconds -- 20 minutes
                   export front document to file destinationFile as QuickTime movie with properties {movie format:native size}
               end timeout
               close front document saving no
               display notification documentName with title "Keynote Movie Export"
           end repeat
       on error errorMessage
           activate
           display alert "EXPORT ERROR" message errorMessage
           error number -128
       end try
   end tell
end exportPresentationsToMovies

on deriveFileNameForNewFileInFolder(sourceItemBaseName, targetFolderHFSAlias)
   -- Routine that derives a none-conflicting file name
   set targetName to ((targetFolderHFSAlias & sourceItemBaseName) as text) & ".m4v"
   try
       alias targetName
   on error
       return targetName
   end try
   set n to 1
   repeat
       set targetName to ((targetFolderHFSAlias & sourceItemBaseName) as text) & "(" & n & ").m4v"
       try
           alias targetName
           set n to n + 1
       on error
           return targetName
       end try
   end repeat
end deriveFileNameForNewFileInFolder

I applied it upon a "com.apple.iwork.keynote.key" file.

VLC executed the created m4v file without problem.


Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mercredi 25 mars 2020  11:40:25

Last edited by Yvan Koenig (2020-03-25 04:51:13 am)

Offline

 

#18 2020-03-25 05:14:45 am

KniazidisR
Member
From:: Greece
Registered: 2019-03-03
Posts: 1457

Re: Keynote - Movie Export Droplet with ProRes 4444 @ 1920 x 1080

Cool smile

Last edited by KniazidisR (2020-03-25 05:14:58 am)


Model: MacBook Pro
OS X: Catalina 10.15.4
Web Browser: Safari 13.1
Ram: 4 GB

Offline

 

#19 2020-03-25 06:05:34 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 4575

Re: Keynote - Movie Export Droplet with ProRes 4444 @ 1920 x 1080

It would be fine to get feedback from users having documents with UTI com.apple.iwork.keynote.key-tef or com.apple.iwork.keynote.kpf

This way, helpers like us would be aware of behaviors which they can't test.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mercredi 25 mars 2020  13:05:27

Offline

 

#20 2020-03-25 05:56:14 pm

BitCy
Member
Registered: 2020-01-12
Posts: 11

Re: Keynote - Movie Export Droplet with ProRes 4444 @ 1920 x 1080

BitCy wrote:

Hello Yvan,

I notice a bug and an issue in the script. I am not really sure what is causing it.

When I set both field to 1 and 0, and each time I export the keynote, the video file gets much longer. I have to manually enter 1 and 0 in the keynote movie export to export it out correctly.

Applescript:


           set value of text field 1 to "1" -- must be a string -- ADDED
           set value of text field 2 to "0" -- must be a string -- ADDED

I am wondering, what is causing the issue? Is there a way to fix this?

Thank you.




Hello Yvan!

Any fix on this? I got mixed up with the code from KniazidisR.

Thank you.

Offline

 

#21 2020-03-26 12:42:56 am

KniazidisR
Member
From:: Greece
Registered: 2019-03-03
Posts: 1457

Re: Keynote - Movie Export Droplet with ProRes 4444 @ 1920 x 1080

BitCy wrote:


Any fix on this? I got mixed up with the code from KniazidisR.


How many slides has your presentation? I tested with 4 slides using my GUI script.  The duration of created movie was 20 seconds. When I set values manually it creates movie with duration = 4 seconds. Indeed, it is very strange. It seems to me that setting to 1 second doesn't work, and remains default value = 5 seconds per slide!!!

Last edited by KniazidisR (2020-03-26 01:17:32 am)


Model: MacBook Pro
OS X: Catalina 10.15.4
Web Browser: Safari 13.1
Ram: 4 GB

Offline

 

#22 2020-03-26 02:44:10 am

KniazidisR
Member
From:: Greece
Registered: 2019-03-03
Posts: 1457

Re: Keynote - Movie Export Droplet with ProRes 4444 @ 1920 x 1080

The solution founded.

Mm, yes. I barely figured it out ... It turns out that you first need to focus the text field. Otherwise, Keynote ignores the new values:

Applescript:


set movieName to "myNewKeynoteMovie"

tell application id "com.apple.systemevents" to tell process "Keynote"
   
   set frontmost to true
   tell menu bar 1 to tell menu bar item "File" to tell menu 1
       tell menu item "Export To" to tell menu 1 to click menu item "Movie…"
   end tell
   
   delay 0.1
   tell window 1 to tell sheet 1
       
       tell (1st text field whose help is "Type how many seconds to wait between slides.")
           set focused to true -- ADDED
           set value to "1"
       end tell
       tell (1st text field whose help is "Type how many seconds to wait between builds.")
           set focused to true -- ADDED
           set value to "0"
       end tell
       delay 1
       
       tell (1st pop up button whose help is "Choose a size for the movie.")
           perform action "AXShowMenu"
           delay 0.1
           click menu item "Custom..." of menu 1
       end tell
       set value of 1st text field whose help is "Type the width you want for the movie." to "1920"
       set value of 1st text field whose help is "Type the height you want for the movie." to "1080"
       
       click (1st radio button whose title is "Apple ProRes 4444")
       delay 0.1
       click button "Next…"
   end tell
   
   delay 1
   click text field 1 of sheet 1 of window 1
   keystroke movieName & return -- naming the movie
   delay 1
   repeat while sheet 1 of window 1 exists -- show creating movie progress
       delay 0.1
   end repeat
   
end tell


Model: MacBook Pro
OS X: Catalina 10.15.4
Web Browser: Safari 13.1
Ram: 4 GB

Offline

 

#23 2020-03-26 03:25:26 pm

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 4575

Re: Keynote - Movie Export Droplet with ProRes 4444 @ 1920 x 1080

English is not used by everybody.

Here is a “partially” localized version.

Applescript:

----------------------------------------------------------------
use AppleScript version "2.5"
use framework "Foundation"
use scripting additions
----------------------------------------------------------------

set thisLocale to current application's NSLocale's currentLocale()
set langX to thisLocale's localeIdentifier as string --> "fr_FR"
set lang2 to thisLocale's languageCode as text --> "fr"
set sys2 to (system attribute "sys2") as integer
tell application "Keynote"
   set x to "1543.title"
   set loc to localized string x from table "MainMenu"
   if loc = x then
       if sys2 < 14 then
           if lang2 = "ar" then
               set loc to "تصدير إلى"
           else if lang2 = "ca" then
               set loc to "¿¿¿"
           else if lang2 = "cs" then
               set loc to "Exportovat do"
           else if lang2 = "da" then
               set loc to "¿¿¿"
           else if lang2 = "de" then
               set loc to "¿¿¿"
           else if lang2 = "el" then
               set loc to "Εξαγωγή σε"
           else if lang2 = "en_AU" then
               set loc to "Export To"
           else if lang2 = "en_GB" then
               set loc to "Export To"
           else if lang2 = "en" then
               set loc to "Export To"
           else if lang2 = "es_419" then
               set loc to "Exportar a"
           else if lang2 = "es" then
               set loc to "Exportar a"
           else if lang2 = "fi" then
               set loc to "¿¿¿"
           else if lang2 = "fr_CA" then
               set loc to "Exporter vers"
           else if lang2 = "fr" then
               set loc to "Exporter vers"
           else if lang2 = "he" then
               set loc to "ייצא אל"
           else if lang2 = "hi" then
               set loc to "इसमें एक्सपोर्ट करें"
           else if lang2 = "hr" then
               set loc to "Eksportiraj u"
           else if lang2 = "hu" then
               set loc to "Exportálás"
           else if lang2 = "id" then
               set loc to "Ekspor Ke"
           else if lang2 = "it" then
               set loc to "¿¿¿"
           else if lang2 = "ja" then
               set loc to "¿¿¿"
           else if lang2 = "ko" then
               set loc to "다음으로 내보내기"
           else if lang2 = "ms" then
               set loc to "Eksport Ke"
           else if lang2 = "nl" then
               set loc to "Exporteer naar"
           else if lang2 = "no" then
               set loc to "¿¿¿"
           else if lang2 = "pl" then
               set loc to "Eksportuj do"
           else if lang2 = "pt_PT" then
               set loc to "Exportar Para"
           else if lang2 = "pt" then
               set loc to "Exportar Para"
           else if lang2 = "ro" then
               set loc to "Exportă în format"
           else if lang2 = "ru" then
               set loc to "¿¿¿"
           else if lang2 = "sk" then
               set loc to "¿¿¿"
           else if lang2 = "sv" then
               set loc to "¿¿¿"
           else if lang2 = "th" then
               set loc to "ส่งออกไปยัง"
           else if lang2 = "tr" then
               set loc to "¿¿¿"
           else if lang2 = "uk" then
               set loc to "¿¿¿"
           else if lang2 = "vi" then
               set loc to "Xuất ra"
           else if lang2 = "zh_CN" then
               set loc to "导出为"
           else if lang2 = "zh_HK" then
               set loc to "輸出至"
           else if lang2 = "zh_TW" then
               set loc to "輸出至"
           else
               set loc to "Export To"
           end if
       else -- Mojave or higher
           set loc to "Export to"
       end if
   end if
   set exportTo_loc to loc
   
   -- set x to "1787.title"
   -- set loc to localized string x from table "MainMenu" -- doesn't cover the entire range
   if lang2 = "ar" then
       set loc to "فيلم…"
   else if lang2 = "ca" then
       set loc to "Vídeo…"
   else if lang2 = "cs" then
       set loc to "Film…"
   else if lang2 = "da" then
       set loc to "Film…"
   else if lang2 = "de" then
       set loc to "Film …"
   else if lang2 = "el" then
       set loc to "Ταινία…"
   else if lang2 = "en_AU" then
       set loc to "Movie…"
   else if lang2 = "en_GB" then
       set loc to "Movie…"
   else if lang2 = "en" then
       set loc to "Movie…"
   else if lang2 = "es_419" then
       set loc to "Video…"
   else if lang2 = "es" then
       set loc to "Vídeo…"
   else if lang2 = "fi" then
       set loc to "Elokuva…"
   else if lang2 = "fr_CA" then
       set loc to "Vidéo…"
   else if lang2 = "fr" then
       set loc to "Vidéo…"
   else if lang2 = "he" then
       set loc to "סרטון…"
   else if lang2 = "hi" then
       set loc to "फ़िल्म…"
   else if lang2 = "hr" then
       set loc to "Film…"
   else if lang2 = "hu" then
       set loc to "Film…"
   else if lang2 = "id" then
       set loc to "Film…"
   else if lang2 = "it" then
       set loc to "Filmato…"
   else if lang2 = "ja" then
       set loc to "ムービー…"
   else if lang2 = "ko" then
       set loc to "동영상…"
   else if lang2 = "ms" then
       set loc to "Filem…"
   else if lang2 = "nl" then
       set loc to "Film…"
   else if lang2 = "no" then
       set loc to "Film…"
   else if lang2 = "pl" then
       set loc to "Film…"
   else if lang2 = "pt_PT" then
       set loc to "Filme…"
   else if lang2 = "pt" then
       set loc to "Filme…"
   else if lang2 = "ro" then
       set loc to "Film…"
   else if lang2 = "ru" then
       set loc to "Фильм…"
   else if lang2 = "sk" then
       set loc to "Film…"
   else if lang2 = "sv" then
       set loc to "Film…"
   else if lang2 = "th" then
       set loc to "ภาพยนตร์…"
   else if lang2 = "tr" then
       set loc to "Film…"
   else if lang2 = "uk" then
       set loc to "Фільм…"
   else if lang2 = "vi" then
       set loc to "Phim…"
   else if lang2 = "zh_CN" then
       set loc to "影片…"
   else if lang2 = "zh_HK" then
       set loc to "影片⋯"
   else if lang2 = "zh_TW" then
       set loc to "影片⋯"
   else
       set loc to "Movie…"
   end if
   set movieDots_loc to loc
   
   set x to "kn.exportQuickTime.goToNextSlideAfterField"
   set exportQuickTimeGoToNextSlideAfterField_loc to localized string x from table "TMAToolTips"
   
   set x to "kn.exportQuickTime.goToNextBuildAfterField"
   set exportQuickTimeGoToNextBuildAfterField_loc to localized string x from table "TMAToolTips"
   
   set x to "260.title"
   set loc to localized string x from table "KNMacExportQuickTimeFormatOptionsView"
   if loc = x then
       if sys2 < 14 then
           if lang2 = "ar" then
               set loc to "مخصص..."
           else if lang2 = "ca" then
               set loc to "Personalitzar…"
           else if lang2 = "cs" then
               set loc to "Vlastní…"
           else if lang2 = "da" then
               set loc to "Speciel…"
           else if lang2 = "de" then
               set loc to "Eigene …"
           else if lang2 = "el" then
               set loc to "Προσαρμογή…"
           else if lang2 = "en_AU" then
               set loc to "Custom..."
           else if lang2 = "en_GB" then
               set loc to "Custom..."
           else if lang2 = "en" then
               set loc to "Custom..."
           else if lang2 = "es_419" then
               set loc to "Personalizar…"
           else if lang2 = "es" then
               set loc to "Personalizar…"
           else if lang2 = "fi" then
               set loc to "Muokattu…"
           else if lang2 = "fr_CA" then
               set loc to "Personnaliser…"
           else if lang2 = "fr" then
               set loc to "Personnaliser…"
           else if lang2 = "he" then
               set loc to "מותאם אישית…"
           else if lang2 = "hi" then
               set loc to "कस्टम..."
           else if lang2 = "hr" then
               set loc to "Po izboru..."
           else if lang2 = "hu" then
               set loc to "Egyéni..."
           else if lang2 = "id" then
               set loc to "Khusus..."
           else if lang2 = "it" then
               set loc to "Personalizzata…"
           else if lang2 = "ja" then
               set loc to "カスタム…"
           else if lang2 = "ko" then
               set loc to "사용자화..."
           else if lang2 = "ms" then
               set loc to "Tersuai…"
           else if lang2 = "nl" then
               set loc to "Aangepast..."
           else if lang2 = "no" then
               set loc to "Tilpasset…"
           else if lang2 = "pl" then
               set loc to "Własna…"
           else if lang2 = "pt_PT" then
               set loc to "Personalizar…"
           else if lang2 = "pt" then
               set loc to "Personalizar…"
           else if lang2 = "ro" then
               set loc to "Personalizat…"
           else if lang2 = "ru" then
               set loc to "Настроить…"
           else if lang2 = "sk" then
               set loc to "Vlastné…"
           else if lang2 = "sv" then
               set loc to "Anpassat..."
           else if lang2 = "th" then
               set loc to "กำหนดเอง…"
           else if lang2 = "tr" then
               set loc to "Özel..."
           else if lang2 = "uk" then
               set loc to "власний варіант…"
           else if lang2 = "vi" then
               set loc to "Tùy chỉnh..."
           else if lang2 = "zh_CN" then
               set loc to "自定…"
           else if lang2 = "zh_HK" then
               set loc to "自訂⋯"
           else if lang2 = "zh_TW" then
               set loc to "自訂⋯"
           else
               set loc to "Custom…"
           end if
       else -- Mojave or higher
           set loc to "Custom..."
       end if
   end if
   set customDots_loc to loc
   
   set x to "kn.exportQuickTime.formatCustomWidthField"
   set exportQuickTimeFormatCustomWidthField_loc to localized string x from table "TMAToolTips"
   
   set x to "kn.exportQuickTime.formatCustomHeightField"
   set exportQuickTimeFormatCustomHeightField_loc to localized string x from table "TMAToolTips"
   
   set x to "kn.exportQuickTime.formatPopUp"
   set exportQuickTimeFormatPopUp_loc to localized string x from table "TMAToolTips"
   
   set x to "Next" & character id 92 & "U2026"
   set nextDots_loc to localized string x from table "TSApplication"
   
end tell

set movieName to "myNewKeynoteMovie"

tell application id "com.apple.systemevents" to tell process "Keynote"
   
   set frontmost to true
   tell menu bar 1 to tell menu bar item 3 to tell menu 1
       tell menu item exportTo_loc to tell menu 1 to click menu item movieDots_loc
   end tell
   
   delay 0.1
   tell window 1 to tell sheet 1
       
       tell (1st text field whose help is exportQuickTimeGoToNextSlideAfterField_loc)
           set focused to true -- ADDED
           set value to "1"
       end tell
       tell (1st text field whose help is exportQuickTimeGoToNextBuildAfterField_loc)
           set focused to true -- ADDED
           set value to "0"
       end tell
       delay 1
       
       tell (1st pop up button whose help is exportQuickTimeFormatPopUp_loc)
           perform action "AXShowMenu"
           delay 0.1
           click menu item customDots_loc of menu 1
       end tell
       set value of 1st text field whose help is exportQuickTimeFormatCustomWidthField_loc to "1920"
       set value of 1st text field whose help is exportQuickTimeFormatCustomHeightField_loc to "1080"
       
       click (1st radio button whose title is "Apple ProRes 4444") -- isn't localized
       delay 0.1
       click button nextDots_loc
   end tell
   
   delay 1
   click text field 1 of sheet 1 of window 1
   keystroke movieName & return -- naming the movie
   delay 1
   repeat while sheet 1 of window 1 exists -- show creating movie progress
       delay 0.1
   end repeat
   
end tell

I'm busy to enhance the cases where there is a test after the call to localized string because these tests don't treat every cases.

As you may see several strings are missing.
At this time I didn't found them.
The links between the property which I named lang2 is right for most cases.
For languages grabbing their string in a lproj named like en_GB.lproj,
I am unable to build the exact link.
I tried to install and activate some of them (like "pt" Portuguese from Brazil and "pt_PT"
Portuguese from Portugal) but on my machine they were given the same couples:

Applescript:

set langX to thisLocale's localeIdentifier as string --> "pt_FR"
set lang2 to thisLocale's languageCode as text --> "pt"

So I didn't understood how the system link them to the correct spelling.

If someone knows the correct incantation, I am interested.

I apologize if I introduced typos when I inserted the strings belonging to languages which I totally ignore.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) jeudi 26 mars 2020  22:25:15

Last edited by Yvan Koenig (2020-03-26 03:27:42 pm)

Offline

 

#24 2020-03-26 10:41:37 pm

KniazidisR
Member
From:: Greece
Registered: 2019-03-03
Posts: 1457

Re: Keynote - Movie Export Droplet with ProRes 4444 @ 1920 x 1080

Yvan Koenig wrote:

English is not used by everybody.


When I said that I love the English interface, I did not want to offend others. Anyone can choose the interface they need from your script and the script will be as concise as English. Special thanks for the Greek interface.

NOTE: if you created the correspondence of the language and the value in the form of records at the beginning of the script, then your script can be greatly reduced.

I say this because this is not the first time I have seen this bad practice of hard-coded verification of conditions for truth:

Applescript:


set langRecord to {ar:"مخصص...", ca:"Personalitzar…"}

set lang2 to "ar"

set the clipboard to langRecord
set langRecordAsList to the clipboard as list

repeat with i from 1 to count langRecordAsList by 2
   if lang2 is item i of langRecordAsList then
       set loc to item (i + 1) of langRecordAsList
       exit repeat
   end if
end repeat

return loc

This my script is equivalent to the following your code. And you need it twice... Imagine that a programmer needs to sort out 250 languages or more, and not 40 as here ...:

Applescript:


if lang2 = "ar" then
set loc to "مخصص..."
else if lang2 = "ca" then
set loc to "Personalitzar…"
else if lang2 = "cs" then
set loc to "Vlastní…"
else if lang2 = "da" then
set loc to "Speciel…"
else if lang2 = "de" then
set loc to "Eigene …"
else if lang2 = "el" then
set loc to "Προσαρμογή…"
else if lang2 = "en_AU" then
set loc to "Custom..."
else if lang2 = "en_GB" then
set loc to "Custom..."
else if lang2 = "en" then
set loc to "Custom..."
else if lang2 = "es_419" then
set loc to "Personalizar…"
else if lang2 = "es" then
set loc to "Personalizar…"
else if lang2 = "fi" then
set loc to "Muokattu…"
else if lang2 = "fr_CA" then
set loc to "Personnaliser…"
else if lang2 = "fr" then
set loc to "Personnaliser…"
else if lang2 = "he" then
set loc to "מותאם אישית…"
else if lang2 = "hi" then
set loc to "कस्टम..."
else if lang2 = "hr" then
set loc to "Po izboru..."
else if lang2 = "hu" then
set loc to "Egyéni..."
else if lang2 = "id" then
set loc to "Khusus..."
else if lang2 = "it" then
set loc to "Personalizzata…"
else if lang2 = "ja" then
set loc to "カスタム…"
else if lang2 = "ko" then
set loc to "사용자화..."
else if lang2 = "ms" then
set loc to "Tersuai…"
else if lang2 = "nl" then
set loc to "Aangepast..."
else if lang2 = "no" then
set loc to "Tilpasset…"
else if lang2 = "pl" then
set loc to "Własna…"
else if lang2 = "pt_PT" then
set loc to "Personalizar…"
else if lang2 = "pt" then
set loc to "Personalizar…"
else if lang2 = "ro" then
set loc to "Personalizat…"
else if lang2 = "ru" then
set loc to "Настроить…"
else if lang2 = "sk" then
set loc to "Vlastné…"
else if lang2 = "sv" then
set loc to "Anpassat..."
else if lang2 = "th" then
set loc to "กำหนดเอง…"
else if lang2 = "tr" then
set loc to "Özel..."
else if lang2 = "uk" then
set loc to "власний варіант…"
else if lang2 = "vi" then
set loc to "Tùy chỉnh..."
else if lang2 = "zh_CN" then
set loc to "自定…"
else if lang2 = "zh_HK" then
set loc to "自訂⋯"
else if lang2 = "zh_TW" then
set loc to "自訂⋯"
else
set loc to "Custom…"
end if
else -- Mojave or higher
set loc to "Custom..."
end if

Last edited by KniazidisR (2020-03-26 11:36:34 pm)


Model: MacBook Pro
OS X: Catalina 10.15.4
Web Browser: Safari 13.1
Ram: 4 GB

Offline

 

#25 2020-03-27 02:27:27 am

KniazidisR
Member
From:: Greece
Registered: 2019-03-03
Posts: 1457

Re: Keynote - Movie Export Droplet with ProRes 4444 @ 1920 x 1080

You can create 1 text file LocalStrings.txt as database, and in it - records, for 10 basic (or more) locals. To each English TEXT should correspond 1 record. There are not so many English texts of UI elements, so this is quite real.

Putting English local in each record as 1st entry, you can determine always what English TEXT is this record for. Then you can simply copy the record and paste in the new created script when you need. This way you create step by step wonderful database, to reuse it multiply times.

Because searching some English text in the text file is not problem. Then, you can sell this database to other programmers as well. lol Or, to make a wide gesture - to give as I do. Take it, it’s not a pity.

NOTE: the most appropriate approach would be to create a separate LocalStrings.txt file for each specific application. Because the translation of the same English text can potentially differ from application to application. I think, it can even be automated.

Last edited by KniazidisR (2020-03-27 02:34:48 am)


Model: MacBook Pro
OS X: Catalina 10.15.4
Web Browser: Safari 13.1
Ram: 4 GB

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)