You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is possible to enumerate available formats on Windows. You could check that against the known string formats
to determine if a text format is available. One important thing to note is that there's not necessarily just one format of content of the clipboard available at any given time.
If you only care if there's text and want an empty string otherwise, you could catch the exception.
importpyclipfrompyclip.win_clipimportClipboardNotTextFormatException# note this is specific for the Windows platform.defpaste():
try:
returnpyclip.paste(text=True)
exceptClipboardNotTextFormatException:
# optionally maybe put a warning herereturn''
I'm doing a
pyclip.paste(text=True)
But doing it blind. The pasteboard could be binary. As such I get this exception.
pyclip.win_clip.ClipboardNotTextFormatException: Clipboard has no text formats available, but text options were specified.
Is there a way I can detect whether its text or not on the pasteboard? Or maybe can that paste command just return an empty string if its binary?
NB: This is my code if anyones interested. A bit of a dodgy copy history code. https://gist.github.com/willwade/3b4df68cffb1db895c8a3c208dd931e9
The text was updated successfully, but these errors were encountered: