
One of the selection actions for the various data items displayed is entitled “Run AppleScript.” When this action is triggered for the selected data item, the associated AppleScript (there are different AppleScripts for each data item — e.g., Email, Address, Note, etc.) will be triggered. The AppleScript can include the data item itself and act on it (e.g., create a mailing label for a postal address or print a note, etc.) or it could do any number of other things like configure your system (e.g., mute the volume when a phone number is selected) — the options are limitless.
When using the “Run AppleScript” action for a data item and one of these items is selected, the data is passed to an AppleScript for processing. You specify the AppleScript to use by clicking the appropriate AppleScript button that appears next to the data item selection action list.
When you click the associated AppleScript button, the window will rotate to reveal an AppleScript editor where you can enter your script. You can enter any AppleScript you want but to access the data item, you must use the data placeholder %d. Please be aware when entering this placeholder that the data is passed as a string and will need to be quoted in your script to be properly executed.
To understand how this works, JABMenu contains several pre-configured scripts for acting on the data like search Google, Facebook or Twitter. You can use the Compile & Test buttons at the top of the editor to make sure that your script will function as you expect. When you are finished editing your script, click the “Return to Main Preferences” button and the window will rotate back to the main preferences view.
Advanced Scripters: You can use the placeholder %id to include the unique identifier of the selected contact within your script. You can then use this identifier to script the Contacts.app to gather information beyond the scope of the selected data item. For instance, if your script is triggered by selecting an email address, you could use the identifier to get other information about the contact (e.g., their department & job title) and include this in the body of a new email message. To make the most of this, you may want to add code like the following to your script: