Name
GetClipboard -- read clipboard contents (V4.5)
Synopsis
type[, data] = GetClipboard()
Function
This function retrieves the data that is currently stored in the clipboard. GetClipboard() will return two values: The first return value indicates the format of the data in the clipboard, and the second return value then contains the format-specific data. Currently, Hollywood supports two different kinds of clipboard data: Text and images.

If there is currently text stored in the clipboard, GetClipboard() will return #CLIPBOARD_TEXT as the first return value, and a string containing the text in the clipboard as the second return value.

If there is currently an image stored in the clipboard, GetClipboard() will return #CLIPBOARD_IMAGE as the first return value, and the second return value will be a handle to a brush which will contain the image from the clipboard. Once you are done working with this brush, you should call FreeBrush() on it to free any memory allocated by it.

If there is neither text nor an image in the clipboard, GetClipboard() will return #CLIPBOARD_UNKNOWN to you. The second return value is unused in this case. If the clipboard is empty, then #CLIPBOARD_EMPTY will be returned.

To get notified whenever the contents of the clipboard change, you can install the ClipboardChange event handler using InstallEventHandler().

If you just want to find out the format of the data currently in the clipboard without actually receiving a copy of this data, you can use the PeekClipboard() command. But keep in mind that the data on the clipboard can change at any time. So there is no guarantee that the data that was on the clipboard when you called PeekClipboard() will still be there when you call GetClipboard().

Inputs
none

Results
type
format of the data currently in the clipboard or #CLIPBOARD_EMPTY or #CLIPBOARD_UNKNOWN
data
optional: if the first return value is not #CLIPBOARD_EMPTY or #CLIPBOARD_UNKNOWN then this return value contains the actual data retrieved from the clipboard; the data that is returned here depends on the format (see above)
Example
SetClipboard(#CLIPBOARD_TEXT, "Hello clipboard!")
type, data = GetClipboard()
If type = #CLIPBOARD_TEXT
  NPrint(data)
Else
  NPrint("No text on the clipboard!")
EndIf
The code above puts the text "Hello clipboard!" on the clipboard and then retrieves the current clipboard contents. If no other program meddles with the clipboard between SetClipboard() and GetClipboard(), this code should print "Hello clipboard!" to the screen then.

Show TOC