How to clear clipboard in using python?
Question:
I want to clear my clipboard after copying stuff. Is this possible?
I tried using clipboard and paperclip, but they don’t have clear methods.
https://pypi.org/project/pyperclip/#description
Answers:
You can just copy an empty string: pyperclip.copy('')
If you are on Windows
from ctypes import windll
if windll.user32.OpenClipboard(None):
windll.user32.EmptyClipboard()
windll.user32.CloseClipboard()
No external libraries needed.
Selected answer may not be sufficient as Windows 10 onwards has Clipboard history (optional, Win key + V), so copying "" won’t delete past copies which defeats the purpose.
I want to clear my clipboard after copying stuff. Is this possible?
I tried using clipboard and paperclip, but they don’t have clear methods.
https://pypi.org/project/pyperclip/#description
You can just copy an empty string: pyperclip.copy('')
If you are on Windows
from ctypes import windll
if windll.user32.OpenClipboard(None):
windll.user32.EmptyClipboard()
windll.user32.CloseClipboard()
No external libraries needed.
Selected answer may not be sufficient as Windows 10 onwards has Clipboard history (optional, Win key + V), so copying "" won’t delete past copies which defeats the purpose.