forked from LTEnjoy/easyChat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclipboard.py
39 lines (30 loc) · 801 Bytes
/
clipboard.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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)