-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathversion 2
333 lines (311 loc) · 9.43 KB
/
version 2
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
#errors:
#in the there those them them list the is always chosen since it is sorter I think
#these files are the necessary imports
import pynput
import random
from pynput import keyboard
from pynput.keyboard import Key, Listener, Controller
#setting up key variables
variable = 0
yesno = 0
#lits used
letters = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
word = []
word_number = []
clearlist = []
order = [0,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]
order2 = [3,4]
list1 = []
previous = 0
letterwordsa = []
letterwordsb = []
letterwordsc = []
letterwordsd = []
letterwordse = []
letterwordsf = []
letterwordsg = []
letterwordsh = []
letterwordsi = []
letterwordsj = []
letterwordsk = []
letterwordsl = []
letterwordsm = []
letterwordsn = []
letterwordso = []
letterwordsp = []
letterwordsq = []
letterwordsr = []
letterwordss = []
letterwordst = []
letterwordsu = []
letterwordsv = []
letterwordsw = []
letterwordsx = []
letterwordsy = []
letterwordsz = []
letterwords = [['a',0,letterwordsa],['b',0,letterwordsb],['c',0,letterwordsc],['d',0,letterwordsd],['e',0,letterwordse],['f',0,letterwordsf],['g',0,letterwordsg],['h',0,letterwordsh],['i',0,letterwordsi],['j',0,letterwordsj],['k',0,letterwordsk],['l',0,letterwordsl],['m',0,letterwordsm],['n',0,letterwordsn],['o',0,letterwordso],['p',0,letterwordsp],['q',0,letterwordsq],['r',0,letterwordsr],['s',0,letterwordss],['t',0,letterwordst],['u',0,letterwordsu],['v',0,letterwordsv],['w',0,letterwordsw],['x',0,letterwordsy],['y',0,letterwordsy],['z',0,letterwordsz]]
def shift():
global list5
global list6
global arbitrary
global arbitrary2
global arbitrary3
arbitrary = 0
arbitrary2 = 0
arbitrary3 = 0
value = len(word_number)
print('value',value)
list5 = []
list6 = []
print(word_number)
for i in letterwords[word_number[0]][2]:
print(i)
while value > arbitrary:
if word_number[arbitrary2] == i[(arbitrary2+1)*2]:
print(word_number[arbitrary2])
print(i[(arbitrary2+1)*2])
arbitrary3 = arbitrary3 + 1
print(arbitrary3)
arbitrary = arbitrary + 1
arbitrary2 = arbitrary2 + 1
if arbitrary3 == value:
list5.append(i)
arbitrary = 0
arbitrary2 = 0
arbitrary3 = 0
print(list5)
#Controller().release(Key.shift)
#Controller().press('a')
for i in list5:
print(list5)
a = len(list5)
print(a)
x = 0
y = 1
while y < a:
if list5[x][0] >= list5[y][0]:
y = y + 1
elif list5[x][0] < list5[y][0]:
x = y
y = y + 1
else:
print('error')
return False
list6.append(list5[x])
list5.pop(x)
a = a - 1
list6.append(list5[0])
#list5.pop(x)
list5 = []
print('list6',list6)
Controller().release(Key.shift)
value2 = (len(list6[0])-1)/2
value3 = 0
while value3 < value2:
value3 = value3 + 1
print('value2',value2)
print('value3', value3)
print('value', value)
print('while')
if value3 > value:
Controller().press(keyboard.KeyCode.from_char(list6[0][value3*2-1]))
print(list6[0][value3*2])
def sort_rest(word_number):
global ticker
global b
global x
global y
global list3
global list4
global alpha
global base
for a in order2:
print('a',a)
ticker = 0
ticker2 = 0
ticker3 = 0
list3 = []
for i in letterwords[word_number[0]][2]:
print(len(i))
print(i)
print(word_number)
ticker2 = ticker2 + 1
if len(i) >= ((a-2)*2+4):
list3.append(i)
ticker = ticker + 1
print('ticker',ticker)
if ticker3 == 0:
ticker3 = ticker2 - 1
print('ticker3',ticker3)
print('list3')
print(list3)
list4 = []
base = len(list3)
while len(list4)<base:
print('a')
alpha = len(list3) - 1
while alpha > 0:
print('b')
y = 1
x = 0
while y <= alpha:
print('c')
print('x',x)
print('y',y)
if list3[x][(a-2)*2+3] <= list3[y][(a-2)*2+3]:
y = y+1
elif list3[x][(a-2)*2+3] > list3[y][(a-2)*2+3]:
x = y
y = y + 1
else:
print('error')
return False
list4.append(list3[x])
list3.pop(x)
print('list4', list4)
print('list3', list3)
base = base - 1
alpha = alpha - 1
if base == 1:
list4.append(list3[0])
list3 = []
base = 0
alpha = 0
if base == 1:
list4.append(list3[0])
list3 = []
base = 0
alpha = 0
for i in list4:
letterwords[word_number[0]][2].remove(i)
print('i',i)
print(letterwords[word_number[0]][2])
for i in list4:
letterwords[word_number[0]][2].insert(ticker3, i)
ticker3 = ticker3 + 1
print(letterwords[word_number[0]][2])
def sort(word_number):
global letterwords
global a
global b
global x
global y
value = word_number[0]
list2 = []
b = len(letterwords[word_number[0]][2])
while len(list2) < b:
a = len(letterwords[word_number[0]][2]) - 1
while a > 0:
y = 1
x = 0
while y <= a:
if letterwords[word_number[0]][2][x][3] <= letterwords[word_number[0]][2][y][3]:
y = y + 1
elif letterwords[word_number[0]][2][x][3] > letterwords[word_number[0]][2][y][3]:
x = y
y = y + 1
else:
print('error')
return False
list2.append(letterwords[word_number[0]][2][x])
letterwords[word_number[0]][2].pop(x)
print('ho')
print(list2)
b = b - 1
a = a - 1
if b == 1:
list2.append(letterwords[word_number[0]][2][0])
letterwords[word_number[0]][2] = []
b = 0
a = 0
if b == 1:
list2 = (letterwords[word_number[0]][2])
letterwords[word_number[0]][2] = []
b = 0
a = 0
letterwords[word_number[0]][2] = list2
sort_rest(word_number)
def word_print():
for i in order:
print(letterwords[i][2])
def word_insertion(word,word_number):
print('word_insertion')
global yesno
global letterwords
global yesno
global list1
yesno = 0
y = 0
x = len(word)
list1.append(1)
while x > y:
list1.append(word[y])
list1.append(word_number[y])
y = y + 1
for i in letterwords[word_number[0]][2]:
if list1[1:] == i[1:]:
yesno = yesno + 1
i[0] = i[0] + 1
else:
yesno = yesno
if yesno == 1:
print('yesno', yesno)
else:
if len(list1) > 2:
letterwords[word_number[0]][2].append(list1)
sort(word_number)
elif len(list1) < 2:
letterwords[word_number[0]][2].insert(1,list1)
list1 = []
def termination():
for i in order:
print(letterwords[i][0],letterwords[i][1])
def word_appender(i,variable):
global word
global word_number
word.append(i)
word_number.append(variable)
letterwords[variable][1] = letterwords[variable][1] + 1
def word_clear():
global word
global word_number
if len(word) != 0:
word_insertion(word,word_number)
word_print()
word = []
word_number = []
def noshift():
print('under current circumstances shift cannot be used to autofil')
def letter(key):
global variable
global previous
variable = 0
for i in letters:
if key == keyboard.KeyCode.from_char(i):
print(i)
word_appender(i,variable)
previous = 1
if key == Key.space:
word_clear()
if key == Key.shift:
if len(word) > 0:
if previous != 0:
print(previous)
if (letterwords[previous][1] > 0 and len(word) == 1) or (len(word) > 1 and len(letterwords[word_number[0]][2]) > 0):
shift()
else:
noshift()
previous = 0
else:
print('no letters to autocomplete')
noshift()
variable = variable + 1
def on_press(key): #everything that happens after a key was pressed
print("{0} pressed".format(key))
letter(key)
def on_release(key): #everythin that happens once a key was released
if key == Key.esc: #termination sequence and presentation of data
termination()
return False
with Listener(on_press = on_press, on_release = on_release) as listener:
listener.join()