-
Notifications
You must be signed in to change notification settings - Fork 0
/
CheesePad.py
160 lines (134 loc) · 5.45 KB
/
CheesePad.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
from tkinter import *
import time
import pyautogui
class KeySim:
def left_key_down():
#PressKey(VK_LEFT)
pyautogui.keyDown('left')
def left_key_up():
#ReleaseKey(VK_LEFT)
pyautogui.keyUp('left')
def right_key_down():
#PressKey(VK_RIGHT)
pyautogui.keyDown('right')
def right_key_up():
#ReleaseKey(VK_RIGHT)
pyautogui.keyUp('right')
def up_key_down():
#PressKey(VK_UP)
pyautogui.keyDown('up')
def up_key_up():
#ReleaseKey(VK_UP)
pyautogui.keyUp('up')
def down_key_down():
#PressKey(VK_DOWN)
pyautogui.keyDown('down')
def down_key_up():
#ReleaseKey(VK_DOWN)
pyautogui.keyUp('down')
class App:
up_string = '\u21D1'
down_string = '\u21D3'
left_string = '\u21D0'
right_string = '\u21D2'
up_right_string = '\u21D7'
up_left_string = '\u21D6'
down_right_string = '\u21D8'
down_left_string = '\u21D9'
def __init__(self, master):
frame = Frame(master)
frame.pack()
self.up = Button(frame, text=self.up_string, command=self.key_press, height='5', width='10')
self.up.grid(row=0, column=1)
self.left = Button(frame, text=self.left_string, command=self.key_press, height='5', width='10')
self.left.grid(row=1, column=0)
self.right = Button(frame, text=self.right_string, command=self.key_press, height='5', width='10')
self.right.grid(row=1, column=2)
self.down = Button(frame, text=self.down_string, command=self.key_press, height='5', width='10')
self.down.grid(row=2, column=1)
self.top_left = Button(frame, text=self.up_left_string, command=self.key_press, height='5', width='10')
self.top_left.grid(row=0, column=0)
self.down_left = Button(frame, text=self.down_left_string, command=self.key_press, height='5', width='10')
self.down_left.grid(row=2, column=0)
self.top_right = Button(frame, text=self.up_right_string, command=self.key_press, height='5', width='10')
self.top_right.grid(row=0, column=2)
self.down_right = Button(frame, text=self.down_right_string, command=self.key_press, height='5', width='10')
self.down_right.grid(row=2, column=2)
self.up.bind('<Enter>', self.key_hover)
self.up.bind('<Leave>', self.key_leave_hover)
self.left.bind('<Enter>', self.key_hover)
self.left.bind('<Leave>', self.key_leave_hover)
self.right.bind('<Enter>', self.key_hover)
self.right.bind('<Leave>', self.key_leave_hover)
self.down.bind('<Enter>', self.key_hover)
self.down.bind('<Leave>', self.key_leave_hover)
self.top_left.bind('<Enter>', self.key_hover)
self.top_left.bind('<Leave>', self.key_leave_hover)
self.down_left.bind('<Enter>', self.key_hover)
self.down_left.bind('<Leave>', self.key_leave_hover)
self.top_right.bind('<Enter>', self.key_hover)
self.top_right.bind('<Leave>', self.key_leave_hover)
self.down_right.bind('<Enter>', self.key_hover)
self.down_right.bind('<Leave>', self.key_leave_hover)
def parse_keys_down(self, widget):
if widget.cget('text') == self.up_string:
KeySim.up_key_down()
elif widget.cget('text') == self.down_string:
KeySim.down_key_down()
elif widget.cget('text') == self.left_string:
KeySim.left_key_down()
elif widget.cget('text') == self.right_string:
KeySim.right_key_down()
elif widget.cget('text') == self.up_left_string:
KeySim.left_key_down()
KeySim.up_key_down()
elif widget.cget('text') == self.up_right_string:
KeySim.right_key_down()
KeySim.up_key_down()
elif widget.cget('text') == self.down_left_string:
KeySim.left_key_down()
KeySim.down_key_down()
elif widget.cget('text') == self.down_right_string:
KeySim.right_key_down()
KeySim.down_key_down()
def parse_keys_up(self, widget):
if widget.cget('text') == self.up_string:
KeySim.up_key_up()
elif widget.cget('text') == self.down_string:
KeySim.down_key_up()
elif widget.cget('text') == self.left_string:
KeySim.left_key_up()
elif widget.cget('text') == self.right_string:
KeySim.right_key_up()
elif widget.cget('text') == self.up_left_string:
KeySim.left_key_up()
KeySim.up_key_down()
elif widget.cget('text') == self.up_right_string:
KeySim.right_key_up()
KeySim.up_key_up()
elif widget.cget('text') == self.down_left_string:
KeySim.left_key_up()
KeySim.down_key_up()
elif widget.cget('text') == self.down_right_string:
KeySim.right_key_up()
KeySim.down_key_up()
def key_press(self):
print ("Test")
def key_hover(self, event):
event.widget.config(bg='green')
self.parse_keys_down(event.widget)
print ("Hover Test")
def key_leave_hover(self, event):
event.widget.config(bg='gray')
self.parse_keys_up(event.widget)
print ("Leave Hover Test")
def key_double_press(self, event):
print ("Double Click Test")
root = Tk()
root.title("CheesePad")
app = App(root)
root.attributes('-alpha', 0.3)
root.wm_attributes('-topmost', 1)
root.resizable(width=FALSE, height=FALSE)
root.mainloop()
root.destroy()