diff --git a/.gitignore b/.gitignore index 45367a3..e32f3a1 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -./*.png \ No newline at end of file +/*.png \ No newline at end of file diff --git a/main.py b/main.py index 5dc5481..fb3b41d 100644 --- a/main.py +++ b/main.py @@ -9,10 +9,19 @@ import pystray from PIL import Image, ImageDraw import threading import ctypes +import os # Set the title for the PowerShell window ctypes.windll.kernel32.SetConsoleTitleW("ESP32 Discord Controller") +# Set the process name for Task Manager +try: + import ctypes + ctypes.windll.kernel32.SetConsoleTitleW("ESP32 Discord Controller") + os.system("title ESP32 Discord Controller") +except: + pass + def get_serial_port(): if len(sys.argv) > 1 and sys.argv[1].startswith("-com="): return sys.argv[1].split("=")[1] @@ -85,6 +94,14 @@ def create_image(): fill="black") return image +def toggle_console(): + whnd = ctypes.windll.kernel32.GetConsoleWindow() + if whnd != 0: + if ctypes.windll.user32.IsWindowVisible(whnd): + ctypes.windll.user32.ShowWindow(whnd, 0) + else: + ctypes.windll.user32.ShowWindow(whnd, 1) + def on_quit(icon, item): icon.stop() if 'ser' in globals() and ser.is_open: @@ -102,7 +119,7 @@ def hide_in_tray(): hide_console() icon = pystray.Icon("ESP32-discord") icon.icon = create_image() - icon.menu = pystray.Menu(pystray.MenuItem('Quit', on_quit)) + icon.menu = pystray.Menu(pystray.MenuItem('Quit', on_quit), pystray.MenuItem('Toggle Console', toggle_console)) threading.Thread(target=icon.run).start() def main():