
Security News
MCP Community Begins Work on Official MCP Metaregistry
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
Package for accessing the clipboard with Python.
pip install clip-util
Windows Only
Allows you to set text, RTF, and HTML to the clipboard on Windows. Any other format can also be specified using the format type integer, specified by Windows.
Will open and close every time the values are set, or retrieved. It's better to use a context manager.
from clipboard import Clipboard
clipboard = Clipboard()
# Set Clipboard
clipboard["text"] = "Hello World!"
# OR
clipboard.set_clipboard("Hello World!")
# Get Clipboard
text = clipboard["text"]
# OR
text = clipboard.get_clipboard("text")
# Supports HTML
clipboard["html"] = "<h1>Hello World</h1>"
from clipboard import Clipboard
with Clipboard() as clipboard:
# Set Clipboard
clipboard["text"] = "Hello World!"
# OR
clipboard.set_clipboard("Hello World!")
# Get Clipboard
text = clipboard["text"]
# OR
text = clipboard.get_clipboard("text")
# HTML
clipboard["html"] = "<h1>Hello World</h1>"
You can use clip-util
to access the clipboard formats directly.
ClipboardFormat
: Enum for clipboard formats.
ClipboardFormat.CF_HTML
: Represents HTML format.
ClipboardFormat.CF_RTF
: Represents RTF format.
from clipboard import Clipboard
from clipboard import ClipboardFormat
from clipboard import get_format_name
with Clipboard() as clipboard:
# Get All Available Formats
format_ids: list[int] = clipboard.available_formats()
# Get Specific Format by ID
# Use parentheses to access the format by ID
formats: list[ClipboardFormat] = []
format_id: int
for format_id in format_ids:
if format_id in ClipboardFormat:
format_: ClipboardFormat = ClipboardFormat(format_id)
formats.append(format_)
else:
# Format is not supported directly by this library
pass
# Get Specified Format by Name (directly)
format_names: list[str] = []
format_id: int
for format_id in format_ids:
name: str = get_format_name(format_id)
format_names.append(name)
# Get Specified Format by Name (using enum)
# Use bracket notation to access the format
#
# Note: this method is not as robust as using `get_format_name`
formats: list[ClipboardFormat] = []
format_names: list[str] = []
format_name: str
for format_name in [f.name for f in formats]:
if format_name in ClipboardFormat:
format_: ClipboardFormat = ClipboardFormat[format_name]
name: str = format_.name
formats.append(format_)
format_names.append(name)
else:
# Format is not supported directly by this library
pass
You can even get the content of all available formats currently in the clipboard.
from clipboard import get_available_formats
from clipboard import get_format_name
from clipboard import get_clipboard
available: list[int] = get_available_formats()
print(f"{available=}")
for format_id in available:
name: str = get_format_name(format_id)
content: str = get_clipboard(format_id)
print(f"{format_id=}", f"{name=}, {content=}")
FAQs
Clipboard utilities for use with Python.
We found that clip-util demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
Research
Security News
Socket uncovers an npm Trojan stealing crypto wallets and BullX credentials via obfuscated code and Telegram exfiltration.
Research
Security News
Malicious npm packages posing as developer tools target macOS Cursor IDE users, stealing credentials and modifying files to gain persistent backdoor access.