Update .gitignore and enhance console visibility controls in main.py
This commit is contained in:
parent
814b7c9d36
commit
b3afc9f785
2
.gitignore
vendored
2
.gitignore
vendored
@ -1 +1 @@
|
||||
./*.png
|
||||
/*.png
|
||||
19
main.py
19
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():
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user