natlinkclipboard
The natlinkclipboard
module offers easy access to and manipulation of
the Windows clipboard. The Clipboard
class forms the core of this
module. Each instance of this class is a container with a structure similar
to the system clipboard, mapping content formats to content data.
Clipboard class
- class Clipboard(contents=None, text=None, from_system=False, save_clear=False, debug=None)[source]
Clipboard class, manages getting and setting the windows clipboard
- classmethod Get_clipboard_formats()[source]
returns a list of format types of current clipboard
This is mainly meant for debugging purposes.
- classmethod Get_folderinfo(waiting_time=0.05)
returns a tuple of file/folder info of selected files or folders
As alias use Get_folderinfo, Get_hdrop or get_system_hdrop
win32con.CF_HDROP is the parameter for calling this type of clipboard data
- classmethod Get_hdrop(waiting_time=0.05)
returns a tuple of file/folder info of selected files or folders
As alias use Get_folderinfo, Get_hdrop or get_system_hdrop
win32con.CF_HDROP is the parameter for calling this type of clipboard data
- classmethod Get_text()
get text from the clipboard
from natlinkclipboard import Clipboard
simply call: text = Clipboard.get_system_text()
as alias also Get_text can be used, so: text = Clipboard.Get_text()
- classmethod Set_text(content)
set text to the clipboard
First the clipboard is emptied.
This method fails when not in elevated mode.
As alias, you can also call: Clipboard.Set_text(“abacadabra”)
- clear_clipboard()[source]
Empty the clipboard and clear the internal clipboard data
assume the clipboard is open
this will be done at init phase with save_clear == True
- copy_from_system(formats=None, save_clear=False, waiting_interval=None, waiting_iterations=None)[source]
Copy the Windows system clipboard contents into this instance.
- Arguments:
formats (iterable, default: None) – if not None, only the given content formats will be retrieved. If None, all available formats will be retrieved.
save_clear (boolean, default: False) – if true, the Windows system clipboard will be saved in self._backup, and cleared after its contents have been retrieved. Will be restored from self._backup when the instance is destroyed. If false contents are retrieved in self._contents
- copy_to_system(data=None, clear=True)[source]
Copy the contents of this instance to the Windows clipboard
Arguments: - data: text or dict of clipboard items (format, content) pairs
clear (boolean, default: True) – if true, the Windows system clipboard will be cleared before this instance’s contents are transferred.
- get_folderinfo(waiting_interval=None, waiting_iterations=None)[source]
Retrieve this instance’s folderinfo (also hdrop)
do a copy_from_system automatically
This should be a tuple of valid paths. The paths are not checked.
If no valid info, return None
- get_format(format)[source]
Retrieved this instance’s content for the given format.
- Arguments:
format (int) – the clipboard format to retrieve.
If the given format is not available, a ValueError is raised.
- get_hdrop(waiting_interval=None, waiting_iterations=None)
Retrieve this instance’s folderinfo (also hdrop)
do a copy_from_system automatically
This should be a tuple of valid paths. The paths are not checked.
If no valid info, return None
- classmethod get_system_folderinfo(waiting_time=0.05)[source]
returns a tuple of file/folder info of selected files or folders
As alias use Get_folderinfo, Get_hdrop or get_system_hdrop
win32con.CF_HDROP is the parameter for calling this type of clipboard data
- classmethod get_system_hdrop(waiting_time=0.05)
returns a tuple of file/folder info of selected files or folders
As alias use Get_folderinfo, Get_hdrop or get_system_hdrop
win32con.CF_HDROP is the parameter for calling this type of clipboard data
- classmethod get_system_text()[source]
get text from the clipboard
from natlinkclipboard import Clipboard
simply call: text = Clipboard.get_system_text()
as alias also Get_text can be used, so: text = Clipboard.Get_text()
- get_text(waiting_interval=None, waiting_iterations=None, replaceNullChar=True)[source]
get the text (mostly unicode) contents of the clipboard
This method first does a copy from system.
If no text content available, return “”
- has_format(format)[source]
Determine whether this instance has content for the given format
- Arguments:
format (int) – the clipboard format to look for.
- has_text(waiting_interval=None, waiting_iterations=None)[source]
Determine whether this instance has text content.