Legato
Legato

GoFiler Legato Script Reference

 

Legato v 1.5b

Application v 5.24b

  

 

Chapter FifteenWindows/OS Functions (continued)

15.5 Clipboard Functions

15.5.1 Overview

The clipboard is a convention to transfer data within applications and between dissimilar applications. Because all applications have access to the clipboard, data can be easily transferred between applications or within an application. Legato provides access to the Windows clipboard on a high-level allowing for the retrieval and setting of a number of clipboard formats.

Applications can set and read the clipboard at will, however, only one application may have the clipboard open at any given time. The content, coding and format of the data on the clipboard is a function to the application posting the information. Some applications, such as Microsoft Office, will post many formats of data. For example, a copy of text from Word 2013 will yield the following posted formats:

It it up to the script to determine the best format or formats to use to retrieve the data. Some applications, on the other hand, will post only limited data. For example, Adobe Reader will only post variations on text when copying a segment of data.

Presumably, multiple formats of data on the clipboard gives other applications options when reading information. For example, the most rudimentary format is simple text (e.g,, “ANSI Text”) is presented by most applications if text is available, obviously if an image is copied it does not necessarily make sense to present text. But, as in the case above, Word presents multiple options for reading data. This is useful since simple text rarely contains any meaningful formatting and no style information. So, copying and pasting within Word requires more information. Some information is of known formats, such as HTML or RTF and some is proprietary.

Another interesting aspect of posting multiple formats of data to the clipboard is the fact that not all formats are rendered at the time of the copy operation. Word is a good example of this case. The application will post HTML as an available format but does not render the data unless requested. This makes a great deal of sense when one considers the processing time required to post a dozen or more formats. But, this is at the expense of not receiving an immediate response to a query for data from the clipboard when calling for information. For example, copying a 500 page document to the clipboard from Word and then subsequently requesting HTML from Legato (or any application) may take a minute or more for Word to render the data.

When Legato posts information to the clipboard, the clipboard is “emptied” and then the script can post one or more formats on to the clipboard. For certain formats, such as text, Windows will automatically create UNICODE and OEM versions of the data.

15.5.2 Clipboard Formats

Clipboard formats are both defined by the operating system and by applications. They can be referenced by specific functions, clipboard format types or by clipboard format codes. The key codes for conventional items are defined as follows, they are always in upper case and they are defined in the Windows SDK:

CF_BITMAP — Image data in the form of a Windows bitmap handle.

CF_DIB — Image data in the form of Device Independent Bitmap.

CF_DIF — Data Interchange Format.

CF_ENHMETAFILE — Image data in the format of an Enhanced Meta File as a handle..

CF_HDROP — A list of files land paths.

CF_LOCALE — Location and language information.

CF_METAFILEPICT — Image data in the form of a meta picture.

CF_OEMTEXT — Text in OEM characterset/code page. This is for translation from programs using the command.exe prompt (aka MS-DOS).

CF_PALETTE — Image color palette data.

CF_PENDATA — Pen extensions for drawing.

CF_RIFF — Audio format data.

CF_SYLK — Image data.

CF_TEXT — Text in 8-bit ANSI code set.

CF_TIFF — Image data in the format of Tagged Image File Format.

CF_UNICODETEXT — Text in 16-bit Unicode set.

CF_WAVE — Audio format data.

In addition, the following de facto names are defined by the application and share by many other applications, they are always in lower case. The underlying types for these formats are not fixed.

cf_csv — Comma Delimited Format.

cf_html — HTML Format. This format has a general specification, see MSDN.

cf_gif — Graphic Image Format.

cf_jpg — JPEG Image.

cf_png — Portable Network Graphic.

cf_rtf — Text as Rich Text Format. Presented by some applications, specifically Word and Excel.

Finally, there are application level proprietary codes:

cf_ddcon — Delay Control

cf_control — Application Control

cf_data — Application Data

cf_objects — Application Objects

cf_html_native — HTML Format

cf_utf — Unicode Text Format (UTF-8)

If named type is not available, the registered token is added in hexadecimal after the code ‘cf_’. For example, cf_004e6828. Note that format types will reset each time the operating starts and are not static from machine to machine. 

15.5.3 Clipboard Operations

Legato only supports various formats to and from the clipboard such as text, HTML, CSV and various image formats. Scripts can test availability, read and set data.

Clipboard access can be ad hoc or via a handle. Generally, if a program just wants to grab text or CSV from the clipboard, the ClipboardGetText or ClipboardGetCSVData can be called. Another option is to open the clipboard using the ClipboardOpen function and then perform multiple operations using an object handle (or the default handle).

It should be noted that data retrieved from the clipboard can be potentially very large and can exceed the processing capabilities of many of the string functions.

15.5.4 Functions

Control and General: 

ClipboardCreate — Empties the clipboard and returns a clipboard handle.

ClipboardGetApplication — Returns the application source information from the clipboard.

ClipboardGetFormatCode — Gets the format code associated with a clipboard format string.

ClipboardGetFormatName — Gets the name of a registered or predefined clipboard format.

ClipboardGetFormatSize — Gets the size of a specified format item on the clipboard.

ClipboardGetFormats — Returns a list of available formats from the clipboard.

ClipboardOpen — Opens the clipboard and returns a handle.

ClipboardRegisterFormat — Registers or retrieves a clipboard format.

Retrieving Data:

ClipboardGetCSVData — Gets CSV from the clipboard in the form of a string table.

ClipboardGetCSVText — Gets CSV from the clipboard as a raw text string.

ClipboardGetData — Gets raw data from the clipboard for a specified format as a Data Object.

ClipboardGetGIF — Gets GIF data from the clipboard in the form of a Data Object.

ClipboardGetHTML — Gets raw HTML with control prefix or selected components from the clipboard.

ClipboardGetHTMLComponents — Gets HTML from the clipboard into component sections.

ClipboardGetJPG — Gets JPEG data from the clipboard in the form of a Data Object.

ClipboardGetPNG — Gets PNG data from the clipboard in the form of a Data Object.

ClipboardGetRTF — Gets RTF data from the clipboard as a string.

ClipboardGetText — Gets plain ANSI text from the clipboard.

ClipboardGetUnicode — Gets plain text as Unicode from the clipboard.

ClipboardGetUTF — Gets Unicode Text Format from the clipboard.

ClipboardIsCSVAvailable — Tests for CSV being available on the clipboard.

ClipboardIsDIBAvailable — Tests for DIB image being available on the clipboard.

ClipboardIsFormatAvailable — Tests for a specified format being available on the clipboard.

ClipboardIsGIFAvailable — Tests for GIF image being available on the clipboard.

ClipboardIsHTMLAvailable — Tests for HTML being available on the clipboard.

ClipboardIsImageAvailable — Tests for any image being available on the clipboard.

ClipboardIsJPGAvailable — Tests for JPEG image being available on the clipboard.

ClipboardIsRTFAvailable — Tests for Rich Text Format (RTF) data being available on the clipboard.

ClipboardIsTextAvailable — Tests for text being available on the clipboard.

Posting Data:

ClipboardSetCSV — Sets Comma Separated Values (CSV) data to the clipboard.

ClipboardSetData — Sets data to the clipboard from a variable, Pool Object or Data Object.

ClipboardSetDIB — Sets a DIB image to the clipboard from a buffer or Data Object.

ClipboardSetGIF — Sets a GIF image to the clipboard from a buffer or Data Object.

ClipboardSetHTML — Sets HTML data to the clipboard either as raw data or as basic HTML.

ClipboardSetJPG — Sets a JPEG image to the clipboard from a buffer or Data Object.

ClipboardSetPNG — Sets a PNG image to the clipboard from a buffer or Data Object.

ClipboardSetRTF — Sets Rich Text Format (RTF) data to the clipboard from a string.

ClipboardSetText — Sets text to the clipboard.

ClipboardSetUnicode — Sets Unicode text to the clipboard.

ClipboardSetUTF — Sets Unicode Text Format to the clipboard.