Trickster automation in version 2.1

Trickster, in version 2.1, adds extensive support for AppleScript and other ways to interact with the application. This way you can make it more useful and adapt it to your workflow. Read below if you’re interested to learn how you can benefit from this, including sample scripts.

Adding files to Trickster’s list

With a System Service “Add to Trickster”.

Either select files in Finder or similar apps or select text that contain paths to files and use “Add to Trickster” service.

With custom URL scheme:

Use trickster-add-recent://fullPath to add the file at fullPath to Trickster.

For example, use in the Terminal as:

open trickster-add-recent:///Users/jacob/Dropbox/Public

For another example, click here to add Preview application to Trickster on your Mac.

With AppleScript

Like this:

tell application "Trickster" to add recent "/Users/jacob/Documents/Sample of Xcode.txt"

or even with multiple files, like this:

set fs to {"/Users/jacob/Documents/File 1.txt", "/Users/jacob/Pictures/Picture 1.jpg"}
tell application "Trickster" to add recent fs

The items can also be file objects and not only string paths.

Getting recent items from Trickster using AppleScript

It’s possible to get either the recent items as they’re shown in Trickster or the selected items. It’s possible to get individual items or the whole list (which might be slow).

There’s a command refresh entries that forces Trickster to sort its recent entries without opening Trickster’s window. You’ll probably want to use it before getting recent entries.

The list of all recent files (no filters applied) is available in entries elements of application object. A specific item (in this example, the first one) can be retrieved directly with the following AppleScript command: get path of entry 1

The selected items are available as selected entries property of the application object. The path to the first selected file can be retrieved with the following script:

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

The entry object contains the following properties of the file:

  • url (file, r/o) : The file object itself. Use it with Finder or in other ways
  • file name (text, r/o) : File name (without the folder)
  • flagged (boolean, r/o) : Is the item flagged
  • path (text, r/o) : Full path to the file as text
  • folder (text, r/o) : Folder of the file as text
  • favorite (boolean, r/o) : Is the item marked as favorite? If yes, it appears in the Favorites sidebar
  • modification date (date, r/o) : Modification date of the entry. Actually, it’s most usually the time that Trickster detected this change.
  • uti (text, r/o) : UTI of the entry

All of this information is available in the AppleScript dictionary which can be opened with AppleScript Editor.

As a user of LaunchBar I wanted to create a way to send files quickly from Trickster to LaunchBar. I also use the fabulous Keyboard Maestro, which lets me assign hot keys to call these scripts. As an alternative to Keyboard Maestro, you could use FastScripts from Red Sweater, if all you need is call AppleScripts.

The scripts were written with the help of Brett Terpstra and Eugene Gordin.

Script to select 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

Script to get selected items in Trickster and put into LauchBar for further processing there:

set sel to selected entries
set paths to {}

repeat with i in sel
    set p to path of i
    set p to POSIX path of p
    copy p to end of paths
end repeat

tell application "LaunchBar"
    remain active
    open paths
end tell

I assigned both scripts to ⌃⌥Z in Keyboard Maestro. You’re welcome to download them.

I also created a custom search in LaunchBar that uses the special URL scheme to add a file from LaunchBar to Trickster. I called it “Add to Trickster”, and can invoke with at. I suppose similar actions can be performed with Alfred or other launchers.

Another usage pattern that Brett suggested is saving these scripts as files in scripts folder for LaunchBar, thus making them available right from within LaunchBar.

You can also create scripts to copy most recent files to the clipboard, for example.

I hope you find it useful in your workflow.

Maybe you can think of new ways to use Trickster’s automation. If you think something is missing and you want more automation functionality, let us know.

Comments are closed.

Trickster Cashculator ImageFramer