AppleScript is an automation technology introduced by Apple in 1993. Over the years it has matured and become the friend of many Mac users wanting to exert more control over their computing experience. Written in an easy to learn, almost conversational language, it offers a tremendous amount of power with less effort than many languages. DEVONthink has very robust AppleScript support and comes with many built-in scripts. These, and those you write or obtain, make it possible to automate nearly every aspect of the application, and to integrate the application with almost every other macOS application that supports AppleScript.

## Installation

Add-On Scripts: All add-on scripts that come with DEVONthink are automatically installed or updated when you open a new version of DEVONthink for the first time. You can, however, manually (re-)install them by choosing DEVONthink > Install Add-Ons. The scripts from this panel are installed in a number of locations:

- Script Menu Extra Scripts: These scripts are accessed from the global Script menu when you are in specific applications, e.g., Safari. They are installed in an application-specific subfolder of `~/Library/Scripts/Applications`. Read more…
- Folder Action Scripts: These scripts are used to created hot folders in the Finder. They are installed in `~/Library/Scripts/Folder Action Scripts`. Read more…
- Apple Mail Rule Scripts: These scripts are for use with Apple Mail Rules. They are installed in `~/Library/Application Scripts/com.apple.mail`. Read more…

DEVONthink Scripts: The internal scripts found in DEVONthink's Scripts menu are installed in `~/Library/Application Scripts/com.devon-technologies.think`. The scripts will be found in one of four directories:

- Menu: These are the scripts found in DEVONthink's Script menu. Read more…
- Toolbar: These scripts are available to add as toolbar buttons. Read more…
- Reminders: These scripts will be executed when a reminder is triggered with an alarm of Execute External Script. Read more…
- Smart Rules: These scripts are used as External Scripts in the actions of smart rules. Read more…

Additional scripts, like those you write yourself, can be put into any of these folders to be used in these contexts. Other scripts that may include integration with DEVONthink can be located wherever it's convenient.

## Script Shortcuts

Many people like mousing around their applications, while others like to use their keyboards. If you want to add keyboard shortcuts to scripts in this menu, you have two options:

- System Preferences: Open System Settings > Keyboard > Shortcuts > App Shortcuts. Add a shortcut for DEVONthink, enter the exact name of the menu item, and assign a hotkey.
- Append Filename: Locate the script in the Finder and append three underscores followed by abbreviated command keys and characters. For example, `eMail Current URL___Cmd-Alt-F2.scpt`. The command key abbreviations are as follows: `Cmd` stands for `⌘︎` Command, `Alt` or `Opt` for `⌥︎` Option, `Ctrl` for `⌃︎` Control, and `Shift` for the `⇧︎` Shift key.

## Learning AppleScript

While this documentation is not an AppleScript language guide, all the scripts that come with DEVONthink are editable and can be explored or modified as you see fit. The separate sections in this chapter provide any required terminology and a simple example script or two. Additionally, there are some great resources available online and in print. For the official archived documentation, refer to Apple's AppleScript web site. Some additional resources are listed below:

Online:

- DEVONtechnologies Community
- MacScripter
- AppleScript, the Language of Automation

Books:

- AppleScript: The Missing Manual
- AppleScript: The Definitive Guide

Note: When using more modern versions of macOS, you will be prompted by the operating system to allow DEVONthink to "control" other applications. If you've seen such a prompt and didn't allow it, open System Settings > Privacy & Security > Automation to enable it. Please make sure to allow the automation requests for DEVONthink to ensure your scripts will run successfully.