-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpy_cp.py
103 lines (90 loc) · 4.06 KB
/
py_cp.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#from PythonMagick import Image
from pynput.keyboard import Key
import win32clipboard
import pyperclip
import sys
import ctypes
class py_copy_paste:
def __init__(self, keyboard):
self.keyboard_obj = keyboard
self.buffer = ['', '', '', '', '', '', '', '', '', '']
self.object_type_buffer = ['', '', '', '', '', '', '', '', '', '']
self.key_type_buffer = ['u\'1\'', 'u\'2\'', 'u\'3\'', 'u\'4\'', 'u\'5\'', 'u\'6\'', 'u\'7\'', 'u\'8\'', 'u\'9\'']
self.gmem_ddeshare = 0x2000
def get_key_type_buffer(self):
return self.key_type_buffer
def get_object_type_buffer(self):
return self.key_type_buffer
def get_index_in_key_type_buffer(self, stringtoSearch):
return self.key_type_buffer.index(stringtoSearch)
def get_object_type_buffer_at_index(self, index):
return self.object_type_buffer[index]
def copy_image(self, current):
# Doesn't Work
"""
for val in self.key_type_buffer:
if str(current[2]) in val:
buffers = self.key_type_buffer.index(val)
Image("clipboard:").write("PNG32:" + str(buffers) + ".png")
self.object_type_buffer[buffers] = "Image"
"""
def paste_image(self, current):
# Doesn't Work
"""
for val in self.key_type_buffer:
if str(current[1]) in val:
buffers = self.key_type_buffer.index(val)
Image(str(buffers) + ".png").write("clipboard:")
self.keyboard_obj.release(Key.ctrl_l)
self.keyboard_obj.press(Key.ctrl_r)
self.keyboard_obj.press('v')
self.keyboard_obj.release('v')
self.keyboard_obj.release(Key.ctrl_r)
self.keyboard_obj.press(Key.ctrl_l)
"""
def copy_file(self, current):
# Doesn't Work
for val in self.key_type_buffer:
if str(current[2]) in val:
buffers = self.key_type_buffer.index(val)
win32clipboard.OpenClipboard()
rawData = win32clipboard.GetClipboardData(win32clipboard.CF_HDROP)
self.buffer[buffers] = rawData
self.object_type_buffer[buffers] = "File"
def paste_file(self, current):
# Doesn't Work
for val in self.key_type_buffer:
if str(current[1]) in val:
buffers = self.key_type_buffer.index(val)
rawData = self.buffer[buffers]
hcd = ctypes.windll.kernel32.GlobalAlloc(self.gmem_ddeshare, sys.getsizeof(rawData) + 1)
pchData = ctypes.windll.kernel32.GlobalLock(hcd)
pchData = hcd
ctypes.windll.kernel32.GlobalUnlock(hCd)
win32clipboard.SetClipboardData(win32clipboard.CF_HDROP, pchData)
self.keyboard_obj.release(Key.ctrl_l)
self.keyboard_obj.press(Key.ctrl_r)
self.keyboard_obj.press('v')
self.keyboard_obj.release('v')
self.keyboard_obj.release(Key.ctrl_r)
self.keyboard_obj.press(Key.ctrl_l)
win32clipboard.CloseClipboard()
def copy_text(self, current):
for val in self.key_type_buffer:
if str(current[2]) in val:
index = self.key_type_buffer.index(val)
self.buffer[index] = pyperclip.paste()
self.object_type_buffer[index] = "Text"
print("Copy at "+str(index)+": "+self.buffer[index])
def paste_text(self, current):
for val in self.key_type_buffer:
if str(current[1]) in val:
index = self.key_type_buffer.index(val)
pyperclip.copy(self.buffer[index])
self.keyboard_obj.release(Key.ctrl_l)
self.keyboard_obj.press(Key.ctrl_r)
self.keyboard_obj.press('v')
self.keyboard_obj.release('v')
self.keyboard_obj.release(Key.ctrl_r)
self.keyboard_obj.press(Key.ctrl_l)
print("Paste from " + str(index) + ": " + self.buffer[index])