AppleScript Types

From Quicksilver Wiki
Jump to: navigation, search


This page lists the supported types that can be used in an AppleScript's get direct types and get indirect types routines.

get direct types Use this handler to return a list of valid object types for which your AppleScript action will appear

get indirect types Use this handler to return a list of valid types that you want to appear in the 3rd pane for your AppleScript action. Note that for the 3rd pane to appear for an AppleScript action, you must implement the get argument count handler. See the AppleScript Actions page for more information.

Object Types[edit]

Type Description
"NSFilenamesPboardType" Files and folders
"NSStringPboardType" Text or a string
"Apple URL pasteboard type" URLs
"QSFormulaType" Formulas as used by the Calculator Plugin
"qs.process" Running applications or processes
"qs.command" Quicksilver command
"QSRemoteHostsType" Remote hosts (from the Remote Hosts Plugin)
"" iTunes tracks (indexed by the iTunes Plugin)
"ABPeopleUIDsPboardType" Address Book / contacts (requires plugin?)


Specify the objects for which an action displays[edit]

If you would only like a certain AppleScript action to display for URLs and Text, you would add the following code to your AppleScript:

on get direct types
     return {"Apple URL pasteboard type", "NSStringPboardType"}
end get direct types

Specify the 3rd pane object types[edit]

For a given AppleScript action, if you only want files to appear in the 3rd pane, you would use the following code:

on get indirect types
    return {"NSFilenamesPboardType"}
end get indirect types

Note that the difference between this and the first example is the use of indirect as opposed to direct

A real live example[edit]

A handy AppleScript for creating short URLs can be found on the Shorten URL (AppleScript) page. It makes sense to only have this action available for URL objects, instead of all text objects (which is the default for the on process text handler. In order to achieve this, you would modify the (first) script to be as follows:

using terms from application "Quicksilver"
        on get direct types
                return {"Apple URL pasteboard type"}
        end get direct types

        on process text theURL
                set shortURL to do shell script "curl -s -H 'Content-Type: application/json' -d \"{\\\"longUrl\\\": \\\"" & theURL & "\\\"}\" | awk '/\"id\":/{print substr($2, 2, length($2)-3)}'"
                return shortURL
        end process text
end using terms from