-
Notifications
You must be signed in to change notification settings - Fork 0
/
VBox.py
84 lines (50 loc) · 1.7 KB
/
VBox.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
import os
import time
# import win32api
# import win32con
import pyautogui
word = None
def CorrectFileDir(name_of_file):
current_dir = os.path.dirname(os.path.abspath(__file__))
new_file_name = name_of_file
return os.path.join(current_dir, new_file_name)
# 1 - input
# 0 - output
def ioFile(switcher, filename):
global word
if switcher == "i":
try:
with open(CorrectFileDir(filename), 'w') as file:
file.write(word)
return word
except FileNotFoundError:
return None
elif switcher == "o":
try:
with open(CorrectFileDir(filename), 'r+') as file:
word = file.read()
return word
except FileNotFoundError:
return None
while True:
time.sleep(0.1)
writeIt = ioFile("o", "data.txt")
if writeIt != None:
print(writeIt)
pyautogui.write(writeIt)
time.sleep(1)
pyautogui.keyDown("enter")
os.remove(CorrectFileDir("data.txt"))
# try:
# word = ioFile("o", "data.txt")
# if word:
# print(word)
# #converter(ioFile("o", "data.txt"))
# print(ord(word[0]))
# win32api.keybd_event(ord(ioFile("o", "data.txt")[0]), 0, 0, 0) # Зажать клавишу 'A'
# win32api.keybd_event(ord(ioFile("o", "data.txt")[0]), 0, win32con.KEYEVENTF_KEYUP, 0) # Отжать клавишу 'A'
# os.remove("data.txt")
# word = None
# ioFile("o", None)
# except FileNotFoundError:
# pass