Created
July 6, 2020 16:28
-
-
Save udf/23a992d006b4c8f2984a769f1338804c to your computer and use it in GitHub Desktop.
Prints available clipboard formats on windows
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 as clipboard | |
class ClipboardWrapper: | |
def __init__(self): | |
pass | |
def __enter__(self): | |
clipboard.OpenClipboard() | |
def __exit__(self, type, value, traceback): | |
clipboard.CloseClipboard() | |
formats = [] | |
with ClipboardWrapper(): | |
format = clipboard.EnumClipboardFormats(0) | |
formats.append(format) | |
while 1: | |
format = clipboard.EnumClipboardFormats(formats[-1]) | |
if format == 0: | |
break | |
formats.append(format) | |
format_names = {} | |
for format in formats: | |
name = '' | |
try: | |
name = clipboard.GetClipboardFormatName(format) | |
except: | |
pass | |
try: | |
data = clipboard.GetClipboardData(format) | |
except: | |
pass | |
format_names[format] = name | |
print(format_names) | |
breakpoint() | |
print() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment