Python win32clipboard.GetClipboardData() Examples
The following are 21
code examples of win32clipboard.GetClipboardData().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
win32clipboard
, or try the search function
.
Example #1
Source File: cmd2plus.py From OpenTrader with GNU Lesser General Public License v3.0 | 6 votes |
def get_paste_buffer(): win32clipboard.OpenClipboard(0) try: result = win32clipboard.GetClipboardData() except TypeError: result = '' #non-text win32clipboard.CloseClipboard() return result
Example #2
Source File: interact.py From ironpython2 with Apache License 2.0 | 5 votes |
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()
Example #3
Source File: clipboard.py From code with MIT License | 5 votes |
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")
Example #4
Source File: winguiauto.py From pyAutoTrading with GNU General Public License v2.0 | 5 votes |
def _getContentsFromClipboard(): win32clipboard.OpenClipboard() content = win32clipboard.GetClipboardData() win32clipboard.CloseClipboard() return content
Example #5
Source File: __init__.py From pyrexecd with MIT License | 5 votes |
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
Example #6
Source File: mem.py From Fastir_Collector with GNU General Public License v3.0 | 5 votes |
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
Example #7
Source File: cmd2.py From ZEROScan with MIT License | 5 votes |
def get_paste_buffer(): win32clipboard.OpenClipboard(0) try: result = win32clipboard.GetClipboardData() except TypeError: result = '' #non-text win32clipboard.CloseClipboard() return result
Example #8
Source File: cmd2.py From PocHunter with MIT License | 5 votes |
def get_paste_buffer(): win32clipboard.OpenClipboard(0) try: result = win32clipboard.GetClipboardData() except TypeError: result = '' #non-text win32clipboard.CloseClipboard() return result
Example #9
Source File: release_puppet_unity_ths.py From puppet with MIT License | 5 votes |
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
Example #10
Source File: recipe-576887.py From code with MIT License | 5 votes |
def getClipboardData(): from win32clipboard import CF_UNICODETEXT if win32clipboard.IsClipboardFormatAvailable(CF_UNICODETEXT): return win32clipboard.GetClipboardData().decode('cp1252') else: return None
Example #11
Source File: clipboard.py From dragonfly with GNU Lesser General Public License v3.0 | 5 votes |
def get_system_text(cls): win32clipboard.OpenClipboard() try: content = win32clipboard.GetClipboardData(cls.format_unicode) finally: win32clipboard.CloseClipboard() return content
Example #12
Source File: clipboard.py From cross3d with MIT License | 5 votes |
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
Example #13
Source File: _repeat.py From dragonfly-commands with GNU Lesser General Public License v3.0 | 5 votes |
def _execute(self, data=None): win32clipboard.OpenClipboard() data = win32clipboard.GetClipboardData() win32clipboard.CloseClipboard() print("Opening link: %s" % data) webbrowser.open(data)
Example #14
Source File: pylogger.py From pylogger with MIT License | 5 votes |
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
Example #15
Source File: clipboard.py From dragonfly with GNU Lesser General Public License v3.0 | 5 votes |
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
Example #16
Source File: cmd2.py From Beehive with GNU General Public License v3.0 | 5 votes |
def get_paste_buffer(): win32clipboard.OpenClipboard(0) try: result = win32clipboard.GetClipboardData() except TypeError: result = '' #non-text win32clipboard.CloseClipboard() return result
Example #17
Source File: testClipboard.py From ironpython2 with Apache License 2.0 | 5 votes |
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()
Example #18
Source File: Lo0sR.py From Lo0sR with MIT License | 4 votes |
def keydown(self, event): global data global curr_window if event.WindowName != curr_window: curr_window = event.WindowName fp = open(file_name, 'a') data = self.get_curr_window() fp.write(data + "\n") fp.close() if event.Ascii > 32 and event.Ascii < 127: fp = open(file_name, 'a') data = chr(event.Ascii) fp.write(data) fp.close() else: while event.Key == "Lcontrol" or "Rcontrol" and event.Key == "A": fp = open(file_name, 'a') fp.write("[SELECT-ALL]") fp.close() break while event.Key == "Lcontrol" or "Rcontrol" and event.Key == "C": fp = open(file_name, 'a') fp.write("[COPY]") fp.close() break while event.Key == "Lcontrol" or "Rcontrol" and event.Key == "V": win32clipboard.OpenClipboard() try: data = "\n[PASTE] - %s\n" % win32clipboard.GetClipboardData() except TypeError: pass win32clipboard.CloseClipboard() fp = open(file_name, 'a') fp.write(data) fp.close() break if event.Key == "Lshift" or "Rshift" or "Return" or "Back": fp = open(file_name, 'a') data = "[%s]" % event.Key fp.write(data) fp.close() else: fp = open(file_name, 'a') data = "\n[%s]\n" % event.Key fp.write(data) fp.close()
Example #19
Source File: clipboard.py From dragonfly with GNU Lesser General Public License v3.0 | 4 votes |
def copy_from_system(self, formats=None, clear=False): """ 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. - *clear* (boolean, default: False) -- if true, the Windows system clipboard will be cleared after its contents have been retrieved. """ win32clipboard.OpenClipboard() try: # Determine which formats to retrieve. if not formats: format = 0 formats = [] while 1: format = win32clipboard.EnumClipboardFormats(format) if not format: break formats.append(format) elif isinstance(formats, int): formats = (formats,) # Verify that the given formats are valid. try: for format in formats: if not isinstance(format, int): raise TypeError("Invalid clipboard format: %r" % format) except Exception, e: raise # Retrieve Windows system clipboard content. contents = {} for format in formats: content = win32clipboard.GetClipboardData(format) contents[format] = content self._contents = contents # Clear the system clipboard, if requested, and close it. if clear: win32clipboard.EmptyClipboard()
Example #20
Source File: clipboard.py From dragonfly with GNU Lesser General Public License v3.0 | 4 votes |
def copy_from_system(self, formats=None, clear=False): """ 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. - *clear* (boolean, default: False) -- if true, the Windows system clipboard will be cleared after its contents have been retrieved. """ win32clipboard.OpenClipboard() try: # Determine which formats to retrieve. if not formats: format = 0 formats = [] while 1: format = win32clipboard.EnumClipboardFormats(format) if not format: break formats.append(format) elif isinstance(formats, integer_types): formats = (formats,) # Verify that the given formats are valid. for format in formats: if not isinstance(format, integer_types): raise TypeError("Invalid clipboard format: %r" % format) # Retrieve Windows system clipboard content. contents = {} for format in formats: content = win32clipboard.GetClipboardData(format) contents[format] = content self._contents = contents # Clear the system clipboard, if requested, and close it. if clear: win32clipboard.EmptyClipboard() finally: win32clipboard.CloseClipboard()
Example #21
Source File: clipboard.py From Computable with MIT License | 4 votes |
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