Pasteboard "Glue" Reference

 

Overview

The Pasteboard "Glue" defines subroutines and constants that allow you to query the services pasteboard for its contents, as well as put data back onto it. It mimics the methods of NSPasteboard class in the Cocoa frameworks, with some differences. The most notable difference is that all of the subroutines take the name of the pasteboard that is to be queried or altered. Additionally, all of the global constants that are used to define pasteboard types are available to your AppleScript services using the same symbolic names as defined in the Cocoa frameworks (e.g. NSStringPboardType).

 

Pasteboard Data Types

The following global variables are automatically available to your AppleScript services and are used to identify the various types of pasteboard data. You can use these symbolic names instead of creating new strings. For more information on the meaning of these types, see the Apple developer documentation for the NSPasteboard class.

Additionally, you can target the general clipboard by name using the NSGeneralPboard constant.

 

Pasteboard "Glue" Subroutines

The following subroutines are available for you to use in your AppleScript services:

 

Pasteboard "Glue" Subroutine Descriptions

getPasteboardTypes(aPasteboard)
Returns a list of pasteboard types that are available on the services pasteboard identified by aPasteboard. The returned list will consist of strings from the list of global pasteboard type constants described earlier in the document.

 

declarePasteboardTypes(aPasteboard, aTypeList)
Configures aPasteboard so that it can hold the pasteboard types in the list aTypeList, which should be a list of strings representing a subset of the pasteboard types defined in the global pasteboard type constants appearing earlier in this document.

 

readPasteboardData(aPasteboard, aType)
Queries the services pasteboard aPasteboard for data of the given pasteboard type aType, and returns it as a String. aType should be one of the pasteboard data types.

 

writePasteboardData(aPasteboard, aType, aData)
Writes aData, which should be a String object, to aPasteboard with the pasteboard data type aType. Before calling this subroutine, be sure to call declarePasteboardTypes() to configure the pasteboard for the proper types.

 

readPasteboardString(aPasteboard, aType)
Queries aPasteboard for data of the given pasteboard type aType, and returns it as a String. Note that this is no different from the readPasteboardData() function defined above; AppleScript strings can also hold data.

 

writePasteboardString(aPasteboard, aType, aString)
Writes aString, which should be a String object, to aPasteboard with the pasteboard data type aType. Before calling this subroutine, be sure to call declarePasteboardTypes() to configure the pasteboard for the proper types.

 

readPasteboardList(aPasteboard, aType)
Queries aPasteboard for a list of objects of the given pasteboard data type aType. Returns the contents as an AppleScript List object.

 

writePasteboardList(aPasteboard, aType, aList)
Writes aList, which should be an AppleScript List object, to aPasteboard with the pasteboard data type aType. Before calling this subroutine, be sure to call declarePasteboardTypes() to configure the pasteboard for the proper types.

 

readPasteboardRecord(aPasteboard, aType)
Queries aPasteboard for an AppleScript record of the given pasteboard data type aType. Returns the contents as an AppleScript Record object.

 

writePasteboardRecord(aPasteboard, aType, aRecord)
Writes aRecord, which should be an AppleScript Record object, to aPasteboard with the pasteboard data type aType. Before calling this subroutine, be sure to call declarePasteboardTypes() to configure the pasteboard for the proper types.