Last active
November 28, 2019 11:52
-
-
Save Rhomboid/5155189 to your computer and use it in GitHub Desktop.
Enumerate clipboard formats with Python and Pywin32
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import win32clipboard | |
formats = {val: name for name, val in vars(win32clipboard).items() if name.startswith('CF_')} | |
def format_name(fmt): | |
if fmt in formats: | |
return formats[fmt] | |
try: | |
return win32clipboard.GetClipboardFormatName(fmt) | |
except: | |
return "unknown" | |
win32clipboard.OpenClipboard(None) | |
fmt = 0 | |
while True: | |
fmt = win32clipboard.EnumClipboardFormats(fmt) | |
if fmt == 0: break | |
print('{:5} ({})'.format(fmt, format_name(fmt))) | |
win32clipboard.CloseClipboard() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49161 (DataObject) | |
49798 (text/html) | |
49358 (HTML Format) | |
49871 (text/_moz_htmlcontext) | |
49872 (text/_moz_htmlinfo) | |
13 (CF_UNICODETEXT) | |
1 (CF_TEXT) | |
49873 (text/x-moz-url-priv) | |
49171 (Ole Private Data) | |
16 (CF_LOCALE) | |
7 (CF_OEMTEXT) |
You're right. I edited the gist.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Wouldn't it make more sense to use
vars
rather thandir
here?