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
CommentsAn 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
To DoCF_METAFILEPICT format returns a pointer to a METAFILEPICT struct which contains the metafile handle, rather than returning the handle directly. This code currently fails with error: (6, 'GetClipboardData:GetMetafileBitsEx(NULL)', 'The handle is invalid.')
Return ValueIf the function fails, the standard win32api.error exception is raised. If the function succeeds, the return value is as described in the following table:
|CF_HDROP||A tuple of Unicode filenames.|
|CF_UNICODETEXT||A unicode object.|
|CF_OEMTEXT||A string object.|
|CF_TEXT||A string object.|
|CF_ENHMETAFILE||A string with binary data obtained from GetEnhMetaFileBits|
|CF_METAFILEPICT||A string with binary data obtained from GetMetaFileBitsEx (currently broken)|
|All other formats||A string with binary data obtained directly from the global memory referenced by the handle.|