It doesn't seem to be the case currently.

Win32::Clipboard only supports a fixed set of constants and does not pass other formats to the Win32 API.

See this bug report, made just now.

As a fun exercise, I wrote the following:

#!perl -w use strict; use Win32::API; use Win32::Clipboard; use 5.006; our $registerClipboardFormat = Win32::API::More->new( 'user32', 'RegisterClipboardFormat', 'P', 'I' ); die "$^E" unless $registerClipboardFormat; #int WINAPI GetClipboardFormatName( # _In_ UINT format, # _Out_ LPTSTR lpszFormatName, # _In_ int cchMaxCount #); our $_getClipboardFormatName = Win32::API::More->new( 'user32', 'GetClipboardFormatName', 'IPI', 'I' ); die "$^E" unless $_getClipboardFormatName; sub getClipboardFormatName { my( $format ) = @_; my $buffer = "\0" x 1024; my $addr = unpack 'I', pack 'P', $buffer; #print $addr; warn $format; return "<builtin format>" if $format < 17; # CF_MAX $_getClipboardFormatName->Call( $format, $buffer, length $buffer ) or die $^E; $buffer =~ s/\0+$//; $buffer } our $CF_HTML; sub CF_HTML() { $CF_HTML ||= do { $registerClipboardFormat->Call("HTML Format"); }; } my $cb = Win32::Clipboard->new(); for my $fmt ($cb->EnumFormats()) { print getClipboardFormatName( $fmt ), "\n"; }; warn "Retrieving as " . CF_HTML(); print $cb->GetAs(CF_HTML()); print "\ndone\n";

This code lists the names and also fetches the custom formats. I plan to do this as a patch to Win32::Clipboard, but currently don't have the time, sorry.


In reply to Re: HTML from Clipboard in Windows by Corion
in thread HTML from Clipboard in Windows by kean

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.