用python 复制文件到剪贴板
作者:互联网
import win32clipboard from ctypes import * class DROPFILES(Structure): _fields_ = [ ("pFiles", c_uint), ("x", c_long), ("y", c_long), ("fNC", c_int), ("fWide", c_bool), ] def setClipboardFiles(paths): files = ("\0".join(paths)).replace("/", "\\") data = files.encode("U16")[2:]+b"\0\0" win32clipboard.OpenClipboard() try: win32clipboard.EmptyClipboard() win32clipboard.SetClipboardData( win32clipboard.CF_HDROP, matedata+data) finally: win32clipboard.CloseClipboard() def readClipboardFilePaths(): win32clipboard.OpenClipboard() try: return win32clipboard.GetClipboardData(win32clipboard.CF_HDROP) finally: win32clipboard.CloseClipboard() pDropFiles = DROPFILES() pDropFiles.pFiles = sizeof(DROPFILES) pDropFiles.fWide = True matedata = bytes(pDropFiles) filename = [r"d:\a.pptx",r"d:\peaks-valleys.png"] setClipboardFiles(filename)
标签:剪贴板,win32clipboard,python,HDROP,pDropFiles,DROPFILES,复制,pFiles,fWide 来源: https://www.cnblogs.com/szyicol/p/16377870.html