pasteboard

Item Provider

An Item Provider is an object holding data that can be loaded as multiple file types. It can be returned from item_provider() or from shortcuts_attachments(). When you copy text for example, it may have formatting. So an ItemProvider object can in this case retrieve the clipboard as plain text or as an rtf file containing the text format.

pasteboard.ItemProvider

A bridge to Foundation's NSItemProvider class.

pasteboard.ItemProvider.get_file_path

Returns the file path if the item is a file.

pasteboard.ItemProvider.get_type_identifiers

Returns a list of type identifiers (UTI) that can be loaded.

pasteboard.ItemProvider.get_suggested_name

Returns the name of the file from which the receiver was created or None.

pasteboard.ItemProvider.data

Returns the data for the given type identifier as bytes.

pasteboard.ItemProvider.open

Opens the receiver as a file in 'rb' mode with the first item item returned by get_type_identifiers() as the type identifier.

pasteboard.item_provider

Returns an ItemProvider instance storing the data from the pasteboard, if there is any.

pasteboard.shortcuts_attachments

If the script is running from Shortcuts, returns a list of files passed to the Attachments parameter.

Strings

Functions for working with strings.

pasteboard.string

Returns the text contained in the pasteboard.

pasteboard.strings

Returns all strings contained in the pasteboard.

pasteboard.set_string

Copies the given text to the pasteboard.

Images

Functions for working with images (as PIL images).

pasteboard.image

Returns the image contained in the pasteboard as PIL images.

pasteboard.images

Returns all images contained in the pasteboard as PIL images.

pasteboard.set_image

Copies the given image to the pasteboard.

URLs

Functions for working with URLs.

pasteboard.url

Returns the URL contained in the pasteboard as a string.

pasteboard.urls

Returns all URLs contained in the pasteboard as strings.

pasteboard.set_url

Copies the given URL to the pasteboard.