How to clear clipboard in using python?


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.

Asked By: user2651231



You can just copy an empty string: pyperclip.copy('')

Answered By: vencaslac

If you are on Windows

from ctypes import windll
if windll.user32.OpenClipboard(None):

No external libraries needed.

Answered By: Priyank Chheda

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.

Answered By: Ace
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.