| Store | Cart

ActiveState Docs

ActivePython 2.4 Documentation

Loading...

win32clipboard.GetClipboardData

string/unicode = GetClipboardData(format)

The GetClipboardData function retrieves data from the clipboard in a specified format. The clipboard must have been opened previously. Note that not all data formats are supported, and that the underlying handle can be retrieved with win32clipboard::GetClipboardDataHandle

Parameters

format=CF_TEXT : int

Specifies a clipboard format. For a description of the standard clipboard formats, see Standard Clipboard Formats.

Comments

An application can enumerate the available formats in advance by using the EnumClipboardFormats function.
The clipboard controls the handle that the GetClipboardData function returns, not the application. The application should copy the data immediately. The application cannot rely on being able to make long-term use of the handle. The application must not free the handle nor leave it locked.
The system performs implicit data format conversions between certain clipboard formats when an application calls the GetClipboardData function. For example, if the CF_OEMTEXT format is on the clipboard, a window can retrieve data in the CF_TEXT format. The format on the clipboard is converted to the requested format on demand. For more information, see Synthesized Clipboard Formats.

Win32 API References

Search for GetClipboardData at msdn, google or google groups.

Search for Standard Clipboard Formats at msdn, google or google groups.

Return Value

If the function fails, the standard win32api.error exception is raised. If the function succeeds, the return value is as described in the following table:

Format Result type


CF_HDROPA tuple of Unicode filenames.
CF_UNICODETEXTA unicode object.
CF_UNICODETEXTA string object.
CF_ENHMETAFILEA string with binary data obtained from GetEnhMetaFileBits
CF_METAFILEPICTA string with binary data obtained from GetMetaFileBitsEx
All other formatsA string with binary data obtained directly from the global memory referenced by the handle.