└── README.md /README.md: -------------------------------------------------------------------------------- 1 | # Introduction to AppleScript libraries 2 | 3 | AppleScript libraries were introduced along with AppleScriptObjective-C, in Mavericks (OSX 10.9). The AppleScript Language Reference has this chapter on script libraries (also on p. 72 of the pdf): 4 | 5 | https://developer.apple.com/library/mac/documentation/AppleScript/Conceptual/AppleScriptLangGuide/conceptual/ASLR_script_objects.html#//apple_ref/doc/uid/TP40000983-CH207-SW6 6 | 7 | MacOsxAutomation explains libraries in simpler terms: 8 | 9 | https://macosxautomation.com/mavericks/libraries/ 10 | 11 | MacScripter also has a tutorial: 12 | 13 | http://macscripter.net/viewtopic.php?id=41638 14 | 15 | Chris Page says a few things about script library caching: 16 | 17 | http://lists.apple.com/archives/applescript-users/2016/Jan/msg00031.html 18 | 19 | Although it is not strictly related to AppleScript libraries, the AppleScript Reference Library caters to the AppleScript developers and as such is an invaluable ressource: 20 | 21 | https://applescriptlibrary.wordpress.com 22 | 23 | 24 | # Listing of existing AppleScript libraries 25 | (alphabetical order of author) 26 | 27 | ## Code by Apple 28 | 29 | **Apple Configurator 2** provides users with a library inside its /Contents/Library/Script Libraries/ folder. The application itself is not scriptable. As Shane Stanley explains on the Apple Script list, the handlers are built around command line tools via **do shell script**.(1) The application is available from the App Store only. 30 | 31 | https://support.apple.com/en-ap/HT205285 32 | 33 | (1) http://lists.apple.com/archives/applescript-users/2015/Oct/msg00032.html 34 | 35 | ## Code by hhas 36 | 37 | **applescript-stdlib** is an attempt at writing a standard library for AppleScript.(1) It proposes handlers for dates, files, formats, library support, lists, maths, tasks, tests, text and types. 38 | 39 | https://github.com/hhas/applescript-stdlib 40 | 41 | (1) http://lists.apple.com/archives/applescript-users/2016/Jan/msg00042.html 42 | 43 | ## Code by Jon Pugh 44 | 45 | **SmartString** is a string manipulation library, "based on a 1984 Scientific American article by Niklaus Wirth about a better way to manipulate strings" (1). 46 | 47 | http://www.seanet.com/~jonpugh/software/SmartString.applescript 48 | 49 | (1) Quoted from Jon's mail to the AS list on December 21 2015 50 | 51 | ## Code by Lukas Reindl 52 | 53 | Lukas has a nice collection of libraries either written by himself or copied from the net. They offer handlers for display, files & folders, iWorks, Keychain, lists, numbers, property lists, strings, Time Machine, and urls. 54 | 55 | http://applescript.bratis-lover.net/library/ 56 | 57 | ## Code by PFiddlesoft 58 | 59 | The disk image for UI Browser includes the **PFiddlesoft GUI Scripting Library** that offers handlers useful in GUI Scripting scripts. The library can be used independently of UI Browser. 60 | 61 | http://pfiddlesoft.com/uibrowser/ 62 | 63 | ## Code by Shane Stanley 64 | 65 | Shane is consolidating the various libraries he provides at the following link: 66 | 67 | http://www.macosxautomation.com/applescript/apps/Script_Libs.html 68 | 69 | At the time of writing, the link gives access to: 70 | * **BridgePlus** (collection of handlers based on the functionality of ASObjC Runner.app, and commands that support improved bridging between AppleScript and Cocoa) 71 | * **CalendarLib** (script library for manipulating calendar events without using Calendar.app) 72 | * **CalendarLib EC** (identical to CalendarLib except it requires El Capitan or later and does not require BridgePlus) 73 | * **DefaultsLib** (makes it simple to take advantage of the built-in defaults system for storing your scripts' preferences) 74 | * **Dialog Toolkit** (script library for showing enhanced dialogs) 75 | * **FileTagsLib** (to retrieve and set file tags) 76 | * **FileManagerLib** (provides handlers for file management tasks like duplicating, copying, moving, renaming, deleting, and trashing files, etc.) 77 | 78 | Shane also posted three sample libraries to the AppleScript list in December 2013. "All were based on an object-oriented design shamelessly borrowed from SmartString, down to the names." (1) The code will eventually be consolidated on Shane's page, but I'm putting the links here in the meanwhile. 79 | 80 | **Smartset** (One of the useful classes in Cocoa (and other languages) is the set, which is like a list except each item can only appear once. Sets are not normally ordered like lists, but Cocoa also has ordered lists, which maintain their order. Anyway, they are a good class to show the convenience of using ASObjC-based script libraries.) 81 | http://lists.apple.com/archives/applescript-users/2013/Dec/msg00057.html 82 | 83 | **SmartRecord** (This is an ASObjC-based library for a SmartRecord object. AppleScript records have several limitations: you can't get the keys/labels as strings, you can't delete items from a record, and you can't coerce them to text. Unfortunately the scripting bridge ASObjC relies on has a limitation too: it drops entries whose value is missing value. The SmartRecord will return an error if you pass it a record with a value set to missing value (or if one of the labels is an AppleScript keyword). 84 | http://lists.apple.com/archives/applescript-users/2013/Dec/msg00113.html 85 | 86 | **SmartList** (This is an ASObjC-based library for a SmartList object, similar to the SmartSet) 87 | http://lists.apple.com/archives/applescript-users/2013/Dec/msg00093.html 88 | 89 | (1) Quoted from Shane's December 22 mail to the AS list 90 | 91 | ## Code by Chris Stone 92 | 93 | Chris' gist page is here: 94 | 95 | https://gist.github.com/ccstone 96 | 97 | It includes: 98 | * **REFERENCES FOR LEARNING & USING APPLESCRIPT** lists various references to learn and become familiar with AppleScript. 99 | * **Edit_Email_in_BBEdit.applescript** finds the selected email message with Spotlight and open it in BBEdit/TextWrangler for editing. 100 | * **Desktop_Sweeper.applescript** creates a dated folder inside ~/Documents/Sweep Desktop/ with newly swept items. 101 | 102 | --------------------------------------------------------------------------------