def background_task():
conn = sqlite3.connect('Hotkey_Editor.db')
cur = conn.cursor()
def load_hotkeys():
global app_name, primary_key
cur.execute("SELECT path, keys FROM hotkeys")
hotkeys = cur.fetchall()
for hotkey in hotkeys:
app_name = hotkey[0]
keys = hotkey[1]
primary_key, secondary_key = keys.split("+")
keyboard.add_hotkey(keys, run, args=(app_name,))
cur.close()
conn.close()
load_hotkeys()
# while True:
# keyboard.wait()
thread = threading.Thread(target=background_task)
thread.start()
def open_gui():
subprocess.Popen(r"C:\Users\serda\PycharmProjects\hotkey\dist\Hotkey_Editor.exe", shell=True)
def destroy():
subprocess.call("taskkill /f /im Hotkey_Editor.exe")
icon = pystray.Icon("Hotkey Editor")
icon.menu = pystray.Menu(pystray.MenuItem("Hotkey Editor'ü aç", action=open_gui),
pystray.MenuItem("Çıkış", action=destroy))
icon.icon = Image.open("logo.ico")
icon.run()