Previous Next | Up | Table of Contents | EagleFiler Home

3.7   Writing Capture Scripts

You can add support for capturing from additional applications by adding capture scripts to the folder:

/Users/<username>/Library/Application Support/EagleFiler/Capture Scripts/

A capture script is an AppleScript saved in compiled format. The name of the file is of the form <bundle identifier>.scpt, e.g. com.apple.Safari.scpt. You can determine an application’s bundle identifier by finding the CFBundleIdentifier in the Info.plist file inside the application’s package (which you can open using the Show Package Contents command when Control-clicking on the application).

The script should have a handler called capture that returns a list of AppleScript records. For example, the NetNewsWire capture script looks like:

on capture()
    tell application "NetNewsWire"
        set tabIndex to index of selected tab
        if tabIndex is 0 then
            if exists selectedHeadline then
                set theURL to URL of selectedHeadline
            else
                return {{|error|:"No URL is available to be captured."}}
            end if
        else
            set theURLs to URLs of tabs
            set theURL to item (tabIndex + 1) of theURLs
        end if
    end tell
    return {{|url|:theURL}}
end capture

Each record in the list should have a |url| key (for a remote http URL) or a |path| key (for a full POSIX path). If no items are available for capture, the script can return the empty list, or it can return a record with a |error| key that provides an application-specific error message.

The capture script for the Finder demonstrates how to capture multiple items at once:

on capture()
    tell application "Finder"
        set theSelection to selection as list
        set theResult to {}
        repeat with theFile in theSelection
            set theFile to theFile as alias
            copy {|path|:POSIX path of theFile} to end of theResult
        end repeat
        return theResult
    end tell
end capture

Other, optional, keys are:

|deleteWhenDone|
If the script creates a temporary file for the capture, it can include this key with value true so that EagleFiler will delete the temporary file after it has finished importing the file.
|fromName|
Overrides the From name that would be extracted from the file.
|note|
A string for the note text.
|sourceURL|
The URL that the document was downloaded from.
|tags|
A list of tag names.
|tagsString|
A Unicode string of space-separated tag names, which EagleFiler will parse.
|title|
Overrides the title that would be extracted from the file.
|creationDate|
Sets the creation date of the file.
|modificationDate|
Sets the modification date of the file.
Previous Next | Up | Table of Contents | EagleFiler Home