Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- # Filename: clear_clipboard_history.py
- # Version: 1.0.0
- # Author: Jeoi Reqi
- """
- Description:
- - This script clears the current content of the clipboard and clipboard history on Windows OS.
- Requirements:
- - Python 3.x
- - Windows OS
- Functions:
- - disable_clipboard:
- Clears the current content of the clipboard.
- - clear_clipboard_history_cmd:
- Clears the clipboard history on Windows using Command Prompt.
- Usage:
- - Run this script in a Python environment.
- Additional Notes:
- - This script utilizes ctypes and subprocess modules for interacting with the Windows clipboard and executing commands.
- - ctypes is used to interact with the Windows API functions for clipboard manipulation.
- - subprocess is used to run a command in Command Prompt to clear the clipboard history.
- """
- import ctypes
- import subprocess
- def disable_clipboard():
- """
- Clears the current content of the clipboard.
- """
- # Open the clipboard
- ctypes.windll.user32.OpenClipboard(0)
- # Empty the clipboard by setting its data to None
- ctypes.windll.user32.EmptyClipboard()
- # Close the clipboard
- ctypes.windll.user32.CloseClipboard()
- def clear_clipboard_history_cmd():
- """
- Clears the clipboard history on Windows using Command Prompt.
- """
- # Clear clipboard history using Command Prompt
- subprocess.run('cmd /c echo.|clip', shell=True)
- if __name__ == "__main__":
- # Call functions to clear clipboard and clipboard history
- disable_clipboard()
- clear_clipboard_history_cmd()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement