-
Notifications
You must be signed in to change notification settings - Fork 2
/
clipboard.py
62 lines (53 loc) · 1.69 KB
/
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# -*- coding: utf-8 -*-
# Falcon clipboard utility
# Copyright (C) 2019 Yukio Nozawa <[email protected]>
import struct
import clipboardHelper
COPY = 1
MOVE = 2
class ClipboardFile(object):
def __init__(self):
self.lst = None
self.operation = COPY
self.bytes = 0
def SetFileList(self, lst):
self.byte = bytearray(struct.pack('iiiii', 20, 0, 0, 0, 1))
for elem in lst:
a = bytearray(elem.encode('UTF-16'))
a.append(0)
a.append(0)
del(a[0:2])
self.byte += a
# end for
self.byte.append(0)
self.byte.append(0)
def SetOperation(self, op):
self.operation = op
def GetFileList(self):
with clipboardHelper.Clipboard() as c:
lst = c.get_dropped_files()
# end
return lst
def GetOperation(self):
with clipboardHelper.Clipboard() as c:
fmt = c.register_format("Preferred DropEffect")
buf = c.get_data(fmt)
op = struct.unpack('i', buf)[0]
# end with
return op
# end getOperation
def SendToClipboard(self):
with clipboardHelper.Clipboard() as c:
c.empty()
c.set_data(
clipboardHelper.ClipboardFormats.drop_handle,
bytes(
self.byte))
fmt = c.register_format("Preferred DropEffect")
c.set_data(fmt, struct.pack('i', self.operation))
# end with
# end def
def ReceiveFromClipboard(self):
with clipboardHelper.Clipboard() as c:
s = c.get_dropped_files()
# end with