AppleScript Libraries are written to extend existing AppleScript functionality, and/or to provide commands “missing” from the default set of AppleScript tools.
Each of the AppleScript Libraries downloadable from this page, are fully editable, and are intended to function as examples and to provide ideas for the creation of your own libraries. Feel free to edit, alter, or expand them to suit your needs.
NOTE:
- For instructions on how to install the libraries, refer to the documentation on the Overview page.
- When analyzing their scripting dictionaries, refer to the section titled Libraries with Terminology.
- Many of the example libraries contain “use” statements. For detail information regarding this new AppleScript construct, refer to the documentation in the Use Statements section.
Viewing the scripting dictionary of an installed AppleScript Library is easy:
To view the scripting dictionary of an installed AppleScript Library, choose Open Dictionary… from the File menu in the AppleScript Editor application. Select the library to view in the list of scriptable resources on your computer, and click the Open button in the dialog.
Once installed, the commands contained in AppleScript Libraries can be accessed by AppleScript scripts using either of two techniques:
- Libraries can be addressed directly via tell statements or tell blocks:
tell script "Sharing Utilities" to tweet text sourceText
- A library’s terminology can be imported with a global scope via use statements placed at the top of scripts:
use script "Sharing Utilities"
tweet text sourceText
Written using AppleScript/Objective-C, the Text Utilities library contains terminology for three commands designed to perform common text manipulation tasks:
transform text sourceText to upper case | lower case | word case
replace text searchString with replacementString in sourceText
remove white space around sourceText
DOWNLOAD: Text Utilities library
Written using AppleScript/Objective-C, the Sharing Utilities library contains terminology for three sharing commands that implement OS X’s native sharing services. The first two are designed to Tweet using the current user’s default Twitter account:
tweet text sourceText
tweet image imageFile with text sourceText
The third command is for beginning an AirDrop session containing one or more disk items:
begin AirDrop with theseItems
DOWNLOAD: Sharing Utilities library (v1.1 updated 5-30-14)
Written using AppleScript/Objective-C, the Text Utilities library contains terminology for a single command designed to display the contents of a URL in a created web viewer window:
display URL targetURL window size widthHeightList
IMPORTANT: Because the WebKit Utilities library draws windows using Cococa framework methods, it must be called from Cocoa-AppleScript applets (ASOC) instead of standard AppleScript Applets, in order to display windows correctly. Cocoa-AppleScript applets can created via the New from Template menu item in the File menu in the AppleScript Editor application.
DOWNLOAD: WebKit Utilities library • WebKit Utilities library and Example ASOC applet
The Alert Utilities library is an example of using an AppleScript Library to provide an AppleScript terminology interface to a UNIX command-line utility. View the library’s dictionary for more example scripts and detail.
Click magnifying glass icon to view dictionary:
NOTE: This AppleScript Library incorporates the infamous BigHonkingText UNIX utility. Used with permission.
The script shown below will display a text message overlaid on the computer screen:
set advancedSettings to {background color:{65535, 0, 0}, background dimensions:{1024, 90}, opacity:100}
display overlay text "Warning. Boss approaching…" duration 1 advanced settings advancedSettings with goose honk
DOWNLOAD: Alert Utilities library