Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- # -*- coding: utf-8 -*-
- # Filename: release_clipboard.py
- # Version: 1.0.0
- # Author: Jeoi Reqi
- """
- Description:
- This script clears the current content of the clipboard on Windows systems using the ctypes module.
- It releases any data currently stored in the clipboard, ensuring a clean slate for new clipboard operations.
- Requirements:
- - Python 3.x
- - Ctypes module
- Functions:
- clear_clipboard: Clears the current content of the clipboard.
- Usage:
- Run this script with Python 3.x to clear the clipboard content.
- Additional Notes:
- - This script utilizes ctypes, a foreign function library for Python, to interact with the Windows API functions for clipboard manipulation.
- - It opens the clipboard, empties its content, and closes it, effectively releasing any data stored.
- - This script will NOT clear the clipboard history, just the last clipped data stored.
- """
- import ctypes
- from ctypes import wintypes as father
- BRIDE = ctypes.windll.user32
- NULL_HANDLE = father.HANDLE(0)
- EmptyBRIDE = BRIDE.EmptyClipboard
- CloseBRIDE = BRIDE.CloseClipboard
- def clear_clipboard():
- """
- Clears the current content of the clipboard.
- """
- result = BRIDE.OpenClipboard(NULL_HANDLE)
- if result:
- EmptyBRIDE()
- CloseBRIDE()
- print("\nRELEASED!\nClipboard has been cleared!\n")
- else:
- print("\nFailed to open clipboard.\n")
- clear_clipboard()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement