Scripts Tab

This document first provides the background to Hook’s Script editor. Then it describes the Script Editor itself.

The Scripts tab contains scripts that control how Hook interacts with your favorite apps, linking them together.

The Scripts tab is a Hook Pro feature. It is not shown in Essentials mode of Hook.

Many apps work with Hook “out of the box”, and are not visible on this tab. For many other apps, Hook contains “integration script bundles” which are listed in the Apps pane on the left of this tab.


Background to Script Editor

If your favorite app is not yet supported by Hook, you can use Hook’s Script Editor tab to copy and paste some AppleScript that does the trick. You can also press the “Update Built-in Scripts” button to get updated Scripts from CogSci Apps that might do the trick.

The Script Editor tab is for users who know AppleScript or JavaScript, or who wish to use AppleScript they receive from trusted sources. If you do not understand AppleScript, then do not use AppleScript unless it comes from a trusted source. (This recommendation applies also to Apple’s own Script Editor app, not just Hook). You can ask for input on the Hook Productivity forum.

Hook implicitly assumes an app is either “read-only” or “create-read-write”.

Read-only apps include web browsers, ebook readers, mail apps, and PDF readers. Yes, you can create emails, but that is irrelevant to Hook at the moment because their ID is not known until the message is sent.

Create-read-write apps are apps that can appear in the “Hook to New” menu. Those are apps in which you can create new files or objects. Most apps are of this type.

What Hook needs from apps

The primary function of Hook is linking. To do this Hook needs to be able to get the address (“URL” or “ID”) of the current app’s foreground resource. For example, to work with a web browser, Hook needs to get the address of the web page (resource) in the frontmost window (or tab). This is the bare minimum requirement.

It is very helpful (but not strictly required) for Hook to be able to get the name of the frontmost window’s resource, so that Hook can insert this name in links that it creates (whether Hook formats those links in Markdown, RTF or for presentation in the Hook window).

What Hook needs to be able to create new items depends on the type of app.

a. If it is a file-based app, Hook just needs a template for the app to be in the templates folder. As explained on the Notes Tab preferences help page, “Hook to New” then copies that template into the new folder, renames the file, and links the file to the foreground resource.
b. For database apps, Hook needs to be able to tell the app to create a new resource. Either Hook will instruct the app about what address (URL or ID) the new resource should have, or the app will return the address of the new resource.

AppleScript requirements of third-party apps

Hook mainly uses AppleScript to interact with third party app. (For apps that lack the required AppleScript, like Firefox, Hook (also) does “UI scripting”, and may use other tricks.).

The AppleScript dictionary needs to support methods for the above. In sum, depending on the app, Hook may need a script (or standard macOS support) for

a. opening an item (for most types of files, a script is not required),
b. getting the name of the foreground item,
c. getting the address of the foreground item, and
d. creating a new item (with the “Hook to New” command)

The Script Editor tab itself

This section describes the components of the Scripts tab, and how to use them.

The Scripts tab consists of

  1. a list of scriptable applications on the left
  2. a five-tab script editor panel on the right, where you can edit the script of a selected app, and
  3. Scripts version information at the bottom (version number and date).

Apps pane (on left)

The Apps pane, on the left, presents a list of scriptable apps. That is a subset of all the apps in your /Applications folder, and elsewhere. The name and bundle of each app name are presented together. When you select an app in this pane, the Script Pane (on right) displays its content.

Hook comes with built-in scripts for many apps. However, you can customize these scripts with the Script Editor tab (on the right). When you customize a built-in script, Hook places an asterisk (*) after its name.

Below the list of apps there are two checkboxes:

  • The Only show installed apps checkbox allows you to only see the apps that are on your Mac.
  • The Hide default built-in scripts checkbox allows you to focus on scripts that you have customized. (For most users, there will be no customized scripts.)

Script Editor pane (on right)

The Script Editor pane consists of 4 tabs (at the top) and a text editor pane. There is a tab for each scriptable function, meaning :

a. opening an item (for files a script is not required)
b. getting the name of the foreground item
c. getting the address of the foreground item
d. creating a new item (with the “Hook to New” command)

Just click on the tab to get to the script you’d like to edit.

You will notice in perusing the built-in scripts that not all tabs require text. When text is not provided, Hook uses a default mechanism to interact with the app. For example, if it is a file-based app, then Hook will simply open the file using a system call.

Don’t forget to save a script bundle when you are ready to deploy it, using the “Save” button.

If you wish to revert to a built-in script, just click the “Revert to Built-in Script” button. So please feel free to experiment with scripts knowing that you can easily roll-back your changes.

NB: There will soon be an Export button so that you can save the selected script to a zip file.

Updating built-in scripts (bottom section)

Hook is capable of updating its scripts through communication with the Hook Productivity server. This update mechanism is separate from the process of updating the Hook app. This enables the updating of scripts to be more lightweight and frequent than updating the apps. However, when you update the app, you also get the latest scripts.

Three methods are available to update Hook scripts:

  1. using the Update Now button on the Script Editor pane,
  2. with the “Update Scripts during launch” checkbox on the Script Editor pane,
  3. by updating the entire Hook app.

If you edit a script or write your own custom scripts they will override Hook’s built-in scripts and will not be affected by any changes or updates. If you “Reset to Default” the scripts for an app, they will reset to the latest available version.

At the bottom of the Script Editor pane, there is a label that indicates the date and time at which Hook’s scripts were last synced from the server.

Updating of the app and scripts is subject to the same overall Hook license agreement.

URL Scheme

The scheme field must be filled in if there is an Open Item script. Hook matches the scheme to URLs to open links to an application with the right Open Item script.

If the application can handle the URL natively (website URLs, Omnifocus and other applications which support URL schemes) then it doesn’t need an Open Item script and doesn’t need the scheme to be filled out.

The scheme is used to find the appropriate script to open URLs with.

Scheme should match the URL returned by Get Address which is formatted scheme://document-identifier .

How to write Hook integration scripts

If you’d like to learn more about creating or editing integration scripts, please check out Integration – Hook, which points to Creating Integration Scripts – Hook.

Help Contents

Help > Preferences Window :

  1. General tab
  2. Notes tab
  3. Scripts tab This page.
  4. Shortcuts tab
  5. Favorite Apps tab
  6. Sync tab and
  7. Update tab

Hook Productivity App Newsletter

Sign-up to receive emails about Hook productivity app. Our emails sometimes include coupons for discounts on great Hook-linkable apps made by other developers.

 Marketing permission: I give my consent to to be in touch with me via email using the information I have provided in this form for the purpose of news, updates and marketing.

What to expect: If you wish to withdraw your consent and stop hearing from us, simply click the unsubscribe link at the bottom of every email we send or contact us at We value and respect your personal data and privacy. To view our privacy policy, please visit our website. By submitting this form, you agree that we may process your information in accordance with these terms.