MCPcopy Create free account
hub / github.com/ipython/ipython / win32_clipboard_get

Function win32_clipboard_get

IPython/lib/clipboard.py:12–33  ·  view source on GitHub ↗

Get the current clipboard's text on Windows. Requires Mark Hammond's pywin32 extensions.

()

Source from the content-addressed store, hash-verified

10 pass
11
12def win32_clipboard_get():
13 """ Get the current clipboard's text on Windows.
14
15 Requires Mark Hammond's pywin32 extensions.
16 """
17 try:
18 import win32clipboard
19 except ImportError:
20 raise TryNext("Getting text from the clipboard requires the pywin32 "
21 "extensions: http://sourceforge.net/projects/pywin32/")
22 win32clipboard.OpenClipboard()
23 try:
24 text = win32clipboard.GetClipboardData(win32clipboard.CF_UNICODETEXT)
25 except (TypeError, win32clipboard.error):
26 try:
27 text = win32clipboard.GetClipboardData(win32clipboard.CF_TEXT)
28 text = py3compat.cast_unicode(text, py3compat.DEFAULT_ENCODING)
29 except (TypeError, win32clipboard.error):
30 raise ClipboardEmpty
31 finally:
32 win32clipboard.CloseClipboard()
33 return text
34
35def osx_clipboard_get() -> str:
36 """ Get the clipboard's text on OS X.

Callers 1

win_pasteFunction · 0.90

Calls 1

TryNextClass · 0.90

Tested by

no test coverage detected