程序基本完成Tkinter转PyQt5以及修复键盘映射程序的无法退出和使用一段时间无法正常映射的问题
This commit is contained in:
parent
88ca313779
commit
6bf4202cc2
File diff suppressed because it is too large
Load Diff
|
@ -1,9 +1,9 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
#########################################
|
###############################################################
|
||||||
# 版本:1.6.1
|
# 版本:1.8.0
|
||||||
# 更新时间:2022年10月06日
|
# 更新时间:2022年07月26日
|
||||||
# Need: unix, python3-tk, python3-pip, pymouse, keyboard
|
# Need: unix, python3-tk, python3-pip, pymouse, keyboard
|
||||||
#########################################
|
###############################################################
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
@ -30,7 +30,6 @@ def Inputt(key):
|
||||||
Setting(key)
|
Setting(key)
|
||||||
else:
|
else:
|
||||||
Mouse(key)
|
Mouse(key)
|
||||||
#Mouse(key)
|
|
||||||
|
|
||||||
def Open():
|
def Open():
|
||||||
path = filedialog.askopenfilename(title="打开", filetypes=[["json 文件", "*.json"], ["全部文件", ["*.*"]]])
|
path = filedialog.askopenfilename(title="打开", filetypes=[["json 文件", "*.json"], ["全部文件", ["*.*"]]])
|
||||||
|
@ -56,13 +55,12 @@ def Mouse(key):
|
||||||
if keybo.__contains__(key.name):
|
if keybo.__contains__(key.name):
|
||||||
print(keybo[key.name]["MousePlace"])
|
print(keybo[key.name]["MousePlace"])
|
||||||
pyautogui.FAILSAFE = False
|
pyautogui.FAILSAFE = False
|
||||||
#os.system(programPath + "/mouse.py {} {}".format(keybo[key.name]["MousePlace"][0], keybo[key.name]["MousePlace"][1]))
|
|
||||||
try:
|
try:
|
||||||
|
print((keybo[key.name]["MousePlace"][0], keybo[key.name]["MousePlace"][1]))
|
||||||
pyautogui.click(keybo[key.name]["MousePlace"][0], keybo[key.name]["MousePlace"][1])
|
pyautogui.click(keybo[key.name]["MousePlace"][0], keybo[key.name]["MousePlace"][1])
|
||||||
|
|
||||||
except:
|
except:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
#pyautogui.click(1500, 800)
|
|
||||||
#m.click(keybo[key.name]["MousePlace"][0],keybo[key.name]["MousePlace"][1])
|
|
||||||
|
|
||||||
def Setting(key):
|
def Setting(key):
|
||||||
if key.event_type == 'up':
|
if key.event_type == 'up':
|
||||||
|
@ -105,11 +103,8 @@ def ShowTips():
|
||||||
def Closing():
|
def Closing():
|
||||||
global close
|
global close
|
||||||
close = True
|
close = True
|
||||||
window.destroy()
|
# 偷懒了,直接强制关闭进程
|
||||||
#key.close()
|
os.system(f"kill {os.getpid()}")
|
||||||
#stop_thread(keys)
|
|
||||||
keyboard.unhook(Inputt)
|
|
||||||
sys.exit(0)
|
|
||||||
|
|
||||||
|
|
||||||
def Key():
|
def Key():
|
||||||
|
@ -145,6 +140,20 @@ def Clean():
|
||||||
def About():
|
def About():
|
||||||
threading.Thread(target=os.system, args=["{}/uengine-runner-about".format(programPath)]).start()
|
threading.Thread(target=os.system, args=["{}/uengine-runner-about".format(programPath)]).start()
|
||||||
|
|
||||||
|
lock = False
|
||||||
|
def ThreadCheck():
|
||||||
|
global lock
|
||||||
|
lock = True
|
||||||
|
pyautogui.position()
|
||||||
|
lock = False
|
||||||
|
|
||||||
|
def RestartProgramTimer():
|
||||||
|
threading.Thread(target=ThreadCheck).start()
|
||||||
|
time.sleep(0.1)
|
||||||
|
if lock:
|
||||||
|
ReStartProgram()
|
||||||
|
RestartProgramTimer()
|
||||||
|
|
||||||
###################
|
###################
|
||||||
#
|
#
|
||||||
###################
|
###################
|
||||||
|
@ -226,16 +235,9 @@ settingMouseToKeyboard.grid(row=0, column=0)
|
||||||
settingButton.grid(row=0, column=1)
|
settingButton.grid(row=0, column=1)
|
||||||
|
|
||||||
win.pack(fill="both", expand="yes")
|
win.pack(fill="both", expand="yes")
|
||||||
#threaded.lock.allocate_lock()
|
|
||||||
keys = threading.Thread(target=Key)
|
keys = threading.Thread(target=Key)
|
||||||
keys.start()
|
keys.start()
|
||||||
threading.Thread(target=ShowTips).start()
|
threading.Thread(target=ShowTips).start()
|
||||||
pyautogui.FAILSAFE = False
|
pyautogui.FAILSAFE = False
|
||||||
'''def B(key):
|
threading.Thread(target=RestartProgramTimer).start()
|
||||||
if key.event_type == "up":
|
|
||||||
print(pyautogui.position())
|
|
||||||
print(key.name)
|
|
||||||
pyautogui.click(1500, 800)
|
|
||||||
keyboard.hook(B)
|
|
||||||
keyboard.wait()'''
|
|
||||||
window.mainloop()
|
window.mainloop()
|
Loading…
Reference in New Issue