windows - Python script importing results to ctrl-c memory -
i know possible python script import results clipboard (ctrl-c memory) on windows. enable me manipulate-transfer results more easily.
is possible do? how?
it's called "clipboard"
copied this link:
import ctypes def winsetclipboard(text): gmem_ddeshare = 0x2000 ctypes.windll.user32.openclipboard(0) ctypes.windll.user32.emptyclipboard() try: # works on python 2 (bytes() takes 1 argument) hcd = ctypes.windll.kernel32.globalalloc(gmem_ddeshare, len(bytes(text))+1) except typeerror: # works on python 3 (bytes() requires encoding) hcd = ctypes.windll.kernel32.globalalloc(gmem_ddeshare, len(bytes(text, 'ascii'))+1) pchdata = ctypes.windll.kernel32.globallock(hcd) try: # works on python 2 (bytes() takes 1 argument) ctypes.cdll.msvcrt.strcpy(ctypes.c_char_p(pchdata), bytes(text)) except typeerror: # works on python 3 (bytes() requires encoding) ctypes.cdll.msvcrt.strcpy(ctypes.c_char_p(pchdata), bytes(text, 'ascii')) ctypes.windll.kernel32.globalunlock(hcd) ctypes.windll.user32.setclipboarddata(1,hcd) ctypes.windll.user32.closeclipboard()
Comments
Post a Comment