Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

How to? Detecting clipboard format

Dec
238
2
I want to make a .btm file that does something with text in the clipboard but that detects non-text content of the clipboard before it tries -- this to avoid the "TCC: Clipboard is not in text format" message. If the clipboard contents are already "plain text" -- not RTF or other styled/formatted text -- I wouldn't want to bother running the routine either.

This test certainly works for detecting non-text content:

"%@clip[0]" == "**EOC**"

If "**EOC**" is not returned, I still don't know if I have styled/formatted text in the clipboard.

Is there a function that returns data about what the clipboard's present format is? A search in the help-file for "clipboard" hasn't turned up anything yet.
 
I wrote a test program to determine what format the clipboard data is in.

When I did;

Code:
echo tcc > clip:

then ran my test program, it returned;

Code:
There are 4 clipboard formats.
07 - CF_OEMTEXT
16 - CF_LOCALE
01 - CF_TEXT
13 - CF_UNICODETEXT

which returned the ClipboardFormat Number and Name. I used http://msdn.microsoft.com/en-us/library/windows/desktop/ff729168(v=vs.85).aspx as my guide to the list of Standard Clipboard Formats.

When I placed jpsoft.com/forums/threads/detecting-clipboard-format.5225/ into the clipboard, then ran my test program, it returned;

Code:
There are 6 clipboard formats.
49161 - UNKNOWN
13 - CF_UNICODETEXT
01 - CF_TEXT
49171 - UNKNOWN
16 - CF_LOCALE
07 - CF_OEMTEXT

Are you just wanting to see if it has a ClipboardFormat of 01, CF_TEXT, or would something like;

Code:
echo %@clipfmt[1]

be more useful, where you pass in the clipboard format, to see if that format is present on the clipboard?

Joe
 
I've been trying to find out what those "UNKNOWN" formats are (49161, 49171, etc.)

These appear not to be "Standard Clipboard Formats".

I've been searching the Internet, and have found a few (49161 = DATAOBJECT, 49171 = "Ole Private Data").

Once I have eliminated these "UNKNOWNS", I will post an update to the plugin.

Joe
 
These are the "standard" ones listed in my VS 2010 docs

CF_BITMAP
2
A handle to a bitmap ( HBITMAP).

CF_DIB
8
A memory object containing a BITMAPINFO structure followed by the bitmap bits.

CF_DIBV5
17
A memory object containing a BITMAPV5HEADER structure followed by the bitmap color space information and the bitmap bits.

CF_DIF
5
Software Arts' Data Interchange Format.

CF_DSPBITMAP
0x0082
Bitmap display format associated with a private format. The hMem parameter must be a handle to data that can be displayed in bitmap format in lieu of the privately formatted data.

CF_DSPENHMETAFILE
0x008E
Enhanced metafile display format associated with a private format. The hMem parameter must be a handle to data that can be displayed in enhanced metafile format in lieu of the privately formatted data.

CF_DSPMETAFILEPICT
0x0083
Metafile-picture display format associated with a private format. The hMem parameter must be a handle to data that can be displayed in metafile-picture format in lieu of the privately formatted data.

CF_DSPTEXT
0x0081
Text display format associated with a private format. The hMem parameter must be a handle to data that can be displayed in text format in lieu of the privately formatted data.

CF_ENHMETAFILE
14
A handle to an enhanced metafile ( HENHMETAFILE).

CF_GDIOBJFIRST
0x0300
Start of a range of integer values for application-defined GDI object clipboard formats. The end of the range is CF_GDIOBJLAST.

Handles associated with clipboard formats in this range are not automatically deleted using the GlobalFree function when the clipboard is emptied. Also, when using values in this range, the hMem parameter is not a handle to a GDI object, but is a handle allocated by the GlobalAlloc function with the GMEM_MOVEABLE flag.

CF_GDIOBJLAST
0x03FF
See CF_GDIOBJFIRST.

CF_HDROP
15
A handle to type HDROP that identifies a list of files. An application can retrieve information about the files by passing the handle to the DragQueryFile function.

CF_LOCALE
16
The data is a handle to the locale identifier associated with text in the clipboard. When you close the clipboard, if it contains CF_TEXT data but no CF_LOCALE data, the system automatically sets the CF_LOCALE format to the current input language. You can use the CF_LOCALE format to associate a different locale with the clipboard text.

An application that pastes text from the clipboard can retrieve this format to determine which character set was used to generate the text.

Note that the clipboard does not support plain text in multiple character sets. To achieve this, use a formatted text data type such as RTF instead.

The system uses the code page associated with CF_LOCALE to implicitly convert from CF_TEXT to CF_UNICODETEXT. Therefore, the correct code page table is used for the conversion.

CF_METAFILEPICT
3
Handle to a metafile picture format as defined by the METAFILEPICT structure. When passing a CF_METAFILEPICT handle by means of DDE, the application responsible for deleting hMem should also free the metafile referred to by the CF_METAFILEPICT handle.

CF_OEMTEXT
7
Text format containing characters in the OEM character set. Each line ends with a carriage return/linefeed (CR-LF) combination. A null character signals the end of the data.

CF_OWNERDISPLAY
0x0080
Owner-display format. The clipboard owner must display and update the clipboard viewer window, and receive the WM_ASKCBFORMATNAME, WM_HSCROLLCLIPBOARD, WM_PAINTCLIPBOARD, WM_SIZECLIPBOARD, and WM_VSCROLLCLIPBOARD messages. The hMem parameter must be NULL.

CF_PALETTE
9
Handle to a color palette. Whenever an application places data in the clipboard that depends on or assumes a color palette, it should place the palette on the clipboard as well.

If the clipboard contains data in the CF_PALETTE (logical color palette) format, the application should use the SelectPalette and RealizePalette functions to realize (compare) any other data in the clipboard against that logical palette.

When displaying clipboard data, the clipboard always uses as its current palette any object on the clipboard that is in the CF_PALETTE format.

CF_PENDATA
10
Data for the pen extensions to the Microsoft Windows for Pen Computing.

CF_PRIVATEFIRST
0x0200
Start of a range of integer values for private clipboard formats. The range ends with CF_PRIVATELAST. Handles associated with private clipboard formats are not freed automatically; the clipboard owner must free such handles, typically in response to the WM_DESTROYCLIPBOARD message.

CF_PRIVATELAST
0x02FF
See CF_PRIVATEFIRST.

CF_RIFF
11
Represents audio data more complex than can be represented in a CF_WAVE standard wave format.

CF_SYLK
4
Microsoft Symbolic Link (SYLK) format.

CF_TEXT
1
Text format. Each line ends with a carriage return/linefeed (CR-LF) combination. A null character signals the end of the data. Use this format for ANSI text.

CF_TIFF
6
Tagged-image file format.

CF_UNICODETEXT
13
Unicode text format. Each line ends with a carriage return/linefeed (CR-LF) combination. A null character signals the end of the data.

CF_WAVE
12
Represents audio data in one of the standard wave formats, such as 11 kHz or 22 kHz PCM.
 
These are the "standard" ones listed in my VS 2010 docs

Thanks, these are the sames ones I have listed when one does clipfmt /? and the same ones for which I provided the link to the Microsoft site in message #2 of this thread.

Joe
 
I wrote a .btm that does the same thing as the plugin.

Visit jpsoft.com/forums/threads/detect-clipboard-format.5227/ for the .btm

Joe
 

Similar threads

Back
Top