Scripting the Clipboard

    The Clipboard is the place that stores text, pictures, and other data that you cut or copy in an application, then paste in another application.

    The Standard Additions dictionary includes several commands that let you use the contents of the Clipboard. Using these commands, you can automate moving data between applications.

    To see the commands, open the Standard Additions dictionary in the Script Editor, then click the Clipboard Commands suite.

    Open the Standard Additions dictionary for me.

    The Clipboard commands can work with many types of data, including styled text, plain text, international text, pictures, and sounds.

    The Standard Additions dictionary defines three commands:
    The Clipboard: Gets the contents of the Clipboard.
    The word "the" is usually optional in scripts, but you should use "the clipboard" for the Standard Additions command because an application may have its own clipboard command. To use the application's command, do not use "the."
    Set The Clipboard To: Sets the contents of the Clipboard.
    Clipboard Info: Returns information about the type and size of data on the Clipboard.
    This command returns a list with this format: {data type, size}.

    You use the Clipboard commands in a Tell statement after using the Activate command to make an application active. The following script assigns the contents of the Clipboard to a variable:

    Show me a Clipboard command.

    The next example sets the contents of the clipboard to the text specified in the script:

    Show me a script that sets the Clipboard's contents.

 


Table of contents