国产精品天干天干,亚洲毛片在线,日韩gay小鲜肉啪啪18禁,女同Gay自慰喷水

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

python復制任意類型的文件到剪切板

2023-07-30 10:19 作者:升斗之祿  | 我要投稿

一開始做了微信查詢車牌信息時候? 開始返回的是文本信息

后來想著再改進功能?在車牌信息后追加 可返回顯示汽車圖片


一想如果微信需要發(fā)送其他類型文件呢?(例如:word excel 壓縮文件等)那就繼續(xù)改進?

可以復制任意類型的文件到剪切板?(按crtl+v 可粘貼出來)

代碼如下

import win32clipboard

from ctypes import *

#復制任意類型的文件到剪切板 按crtl+v 可粘貼出來

class DROPFILES(Structure):

? ? _fields_ = [

? ? ? ? ("pFiles", c_uint),

? ? ? ? ("x", c_long),

? ? ? ? ("y", c_long),

? ? ? ? ("fNC", c_int),

? ? ? ? ("fWide", c_bool),

? ? ]


pDropFiles = DROPFILES()

pDropFiles.pFiles = sizeof(DROPFILES)

pDropFiles.fWide = True

matedata = bytes(pDropFiles)


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 setClipboardFile(file):

? ? setClipboardFiles([file])


示例使用

# file_path = r'D:\python\微信錄入車牌\1.png'? # 替換為您要復制的文件路徑

# setClipboardFile(file_path)

file_path = r'D:\python\微信錄入車牌\example.xlsx'? # 替換為您要復制的文件路徑

setClipboardFile(file_path)


python復制任意類型的文件到剪切板的評論 (共 條)

分享到微博請遵守國家法律
调兵山市| 罗城| 合肥市| 恭城| 抚州市| 凤台县| 蒙山县| 三门峡市| 黄山市| 塔河县| 衡南县| 大渡口区| 财经| 锡林浩特市| 眉山市| 江陵县| 赣榆县| 读书| 广宁县| 杭州市| 阿克苏市| 米易县| 黑河市| 铜川市| 孟津县| 红桥区| 海淀区| 博客| 鞍山市| 咸阳市| 深州市| 淅川县| 策勒县| 莱阳市| 凌海市| 安陆市| 南木林县| 江孜县| 红桥区| 南涧| 九台市|