Automating Adobe InDesign 2019 - AppleScript

Happy Holidays

Monday, December 16, 2019

Happy Holidays

There seems to be a lot of confusion as to what days the Twelve Days of Christmas start on--and even why there is such a thing as the Twelve Days of Christmas. Some say that the earliest Christians celebrated January 6 as the birthday of the Christ child and that it wasn't until over three hundred years later that the date was set for December 25. Whatever the reason and the season, somebody came up with a song that may have something to do with the 12 days of Yuletide which begins December 22. And for you, who want to do something silly for the Holidays, here is a script that demonstrates using repeat loops to have your Macintosh "sing" the silly song. (Experiment with the values for the voice, speaking rate, pitch, and modulation just for fun.)

Copy the script into the AppleScript editor and save it using Application as the File Format (without options checked). Make sure you have sound turned on when you double click on the file to run the script.

The Twelve Days of Christmas

set theCounters to {"First", "Second", "Third", "Fourth", "Fifth", "Sixth", ¬
"Seventh", "Eighth", "Ninth", "Tenth", "Eleventh", "Twelfth"}
set theCounted to {"a partridge in a pear tree.", "two turtle doves, and ", ¬
"three French hens, ", "four calling birds, ", "five golden rings, ", "six geese a-laying, ", ¬
"seven swans a-swimming, ", "eight maids a-milking, ", "nine ladies dancing, ", ¬
"ten lords a-leaping, ", "eleven pipers piping, ", "twelve drummers drumming, "}
set thisList to {}
set countedSoFar to ""
repeat with n from 1 to 12
	set countedSoFar to item n of theCounted & countedSoFar
	set thisPhrase to "On the " & item n of theCounters & ¬
" Day of Christmas, my true love sent to me: " & countedSoFar
	set end of thisList to thisPhrase
	say thisPhrase using "Alex" speaking rate 140 pitch 42 ¬
modulation 60 with waiting until completion
end repeat

Labeled Parameters

Notice in the above how the parameters for the say method are added following the direct parameter which defines the voice. With the exception of the direct parameter, which must directly follow the handler name, labeled parameters can appear in any order, with the labels from the handler definition identifying the parameter values. This includes parameters listed in given, with, and without clauses (of which there can be any number). With the exception of display dialog, can you think of any other methods in AppleScript which use labeled parameters?

안전사이트 commented on 23-Jul-2020 06:30 AM
Love watching movies !
Post a Comment
Captcha Image
Trackback Link
Post has no trackbacks.

Recent Posts


find change options entire path Find by Attribute Repeat With script templates Combobox auto tag repeat loops dropdowns threaded text frames intent table styles InDesign template giving up after draw from center Choose from list Placing images try/on error Previous text frame choose file name reference to stacking order Place text Library Folder Checkbox Control Buttons Image Events text editbox Create Document active spread date objects Script Preferences radiobutton control handlers Document from Template Change Text import text tabs grid Adding Captions import styles time page items next text frame bookmarks Chaining Paragraph Styles Next Style Text Style Mapping Styling Text StandardAdditions Apply Object Style XML structure lists of lists object styles master spread integer editboxes Keyboard Shortcuts Script Library start paragraph Editbox map tags to styles do script Write to File lists dialog Script panel Templates move file Enabling Groups info for convert to text Document stylesheets text import preferences import XML Clearing Overrides Multi-state objects primary text frame tab list automated workflow Duplicate Adjust Layout Nested Repeat Loops XML selection Character Styles Radiobutton Group text item delimiters live bounds random number rest of list GREP rest Excel paragraph styles Document Presets CALS tables image metadata static alignment Choose file file paths measurement editboxes Image Placement measurements coordinates user interaction level Read text file as list Check for Styles file info fit Custom Dialog XML tags script folder Border Panel Create Text Frame sort list Find Text Autoflow Export to PDF place point