Black Friday sale: 50% off lifetime purchase
Browse the Trickster 4 manual

AppleScript and URL Schemes for Trickster Automation

Automate Trickster with URL schemes and AppleScript.

Trickster can be controlled from other apps, scripts, and launchers. You can add files and links to its list, read recent items, and clear the list.

Add files to Trickster’s list

Files added this way appear in the list even if they are outside your watched folders.

With the Add to Trickster service

Select files in Finder, or select text that contains file paths, then choose Services → Add to Trickster from the app menu or the right-click menu.

With a URL

Open trickster-add-recent:// followed by the file’s full path. For example, in Terminal:

open trickster-add-recent:///Users/yourname/Documents/Report.pdf

You can add these optional parameters:

  • source: the name of the app the file came from.
  • callbackURL: a URL that Trickster opens instead of the file, for example to return to the item in the app it came from.
  • displayPath: text to show in place of the item’s path. The real file path is not changed.
  • bundleID: the bundle ID of the app to associate with the file, for example for the Active Application filter.

With AppleScript

tell application "Trickster" to add recent "/Users/yourname/Documents/Report.pdf"

The item can be a path or a file object. To add several files, send each one separately:

set fs to {"/Users/yourname/Documents/File 1.txt", "/Users/yourname/Pictures/Picture 1.jpg"}
repeat with f in fs
    tell application "Trickster" to add recent (contents of f)
end repeat

add recent accepts the same optional source, callbackURL, displayPath, and bundleID parameters as the URL. They apply when adding one file at a time. For example, the DEVONthink integration uses:

add recent thePath source appname displayPath recordPath callbackURL itemLink bundleID "com.devon-technologies.think3"

Open a trickster-add://url URL with the link’s details as parameters:

open "trickster-add://url?url=https%3A%2F%2Fwww.apple.com%2Fmac%2F&title=Mac%20-%20Apple&browser=Safari"
  • url (required): the web address to save, URL-encoded.
  • title: the title to show in Trickster.
  • favicon: the address of the site’s icon, or a data: URL containing the image.
  • browser: the name of the browser or app the link came from. source and app are accepted as alternatives.

Use unknown for favicon or browser to leave that detail out. Adding a link that is already in the list updates it, rather than creating a duplicate.

Links added this way follow your link tracking settings. They are ignored when Track URLs from apps is off, or when a blocked source or excluded address matches. To protect your list from runaway scripts, Trickster accepts up to 60 of these requests per minute.

The browser extensions are the easiest way to save pages from Safari, Chrome, and Firefox.

Read recent items with AppleScript

Entries

The whole list, without filters, is available as the entries of the application. selected entries contains the items currently selected in Trickster’s window.

Run refresh entries first, so that the list is sorted and up to date without opening Trickster’s window:

tell application "Trickster"
    refresh entries
    get path of entry 1
end tell

To get the path of the first selected item:

tell application "Trickster"
    set se to selected entries
    set t to item 1 of se
    set p to path of t
end tell

Each entry has these properties:

Property Type Description
id text A unique identifier for the item
url file The file itself, for use with Finder and other apps
file name text The file name, without its folder
path text The full path to the file
folder text The folder containing the file
flagged boolean Whether the item is flagged. You can set this property to flag or unflag an item.
favorite boolean Whether the item is in Favorites
modification date date When Trickster last saw activity for the item
uti text The item’s file type (UTI)
sourceAppName text The app the item came from, if known
sourceAppCallbackURL text The URL that returns to the item in its source app, if any
sourceDisplayPath text The path shown in place of the real one, if any
pathForHookmark text The path or address that Hookmark uses for the item

For example, to flag the most recent item:

tell application "Trickster" to set flagged of entry 1 to true

Filters

Your filters are available as filters of the application. Each filter has a title, an icon URL, a position in the sidebar, and its own entries. Pass a filter to refresh entries to update its items first:

tell application "Trickster"
    set f to first filter whose title is "Cedar Studio"
    refresh entries f
    get path of entries of f
end tell

JSON

jsonEntries returns the most recent items as a JSON array, which is convenient for scripts in other languages. Use limit to set how many items to return:

tell application "Trickster" to jsonEntries limit 10

Each item includes filename, fullpath, extension, uti, flagged, modDate, and bundleID, as well as the source details when they are available.

The complete list of commands and properties is in Trickster’s scripting dictionary. Open it from Script Editor with File → Open Dictionary….

Clear the list

Open trickster-empty-list: to remove all items except flagged items and favorites. This is the same as Clear List in Trickster’s main menu.

Examples

These scripts send files from Trickster to LaunchBar. They were written with the help of Brett Terpstra and Eugene Gordin. For a ready-made integration, see Using Trickster with LaunchBar.

Open the most recent file in LaunchBar:

tell application "Trickster"
    refresh entries
    set f to get path of entry 1
    tell application "LaunchBar" to open f
end tell

Send the items selected in Trickster to LaunchBar:

set paths to {}
tell application "Trickster"
    set sel to selected entries
    repeat with i in sel
        copy (path of i) to end of paths
    end repeat
end tell

tell application "LaunchBar"
    remain active
    open paths
end tell

You can assign scripts like these to keyboard shortcuts with Keyboard Maestro or FastScripts. You’re welcome to download both as Keyboard Maestro macros.

If you have an idea for more automation, let us know.