|
6 | 6 | import multiprocessing |
7 | 7 | multiprocessing.freeze_support() |
8 | 8 |
|
9 | | -# On Windows, give vpinfe its own app identity (separate from Explorer) |
10 | | -# and hide the console window when launched via icon. |
11 | | -if platform.system() == "Windows": |
| 9 | +# On Windows, hide the console window when launched via icon (not from terminal). |
| 10 | +# When double-clicked, the process is the sole owner of its console. |
| 11 | +# When run from cmd/powershell, multiple processes share the console - don't hide it. |
| 12 | +if platform.system() == "Windows" and getattr(sys, 'frozen', False): |
12 | 13 | import ctypes |
13 | | - ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID('vpinfe.vpinfe.1') |
14 | | - |
15 | | - if getattr(sys, 'frozen', False): |
16 | | - kernel32 = ctypes.windll.kernel32 |
17 | | - hwnd = kernel32.GetConsoleWindow() |
18 | | - if hwnd: |
19 | | - pid = ctypes.c_ulong() |
20 | | - ctypes.windll.user32.GetWindowThreadProcessId(hwnd, ctypes.byref(pid)) |
21 | | - if pid.value == os.getpid(): |
22 | | - ctypes.windll.user32.ShowWindow(hwnd, 0) # SW_HIDE |
| 14 | + kernel32 = ctypes.windll.kernel32 |
| 15 | + hwnd = kernel32.GetConsoleWindow() |
| 16 | + if hwnd: |
| 17 | + pid = ctypes.c_ulong() |
| 18 | + ctypes.windll.user32.GetWindowThreadProcessId(hwnd, ctypes.byref(pid)) |
| 19 | + if pid.value == os.getpid(): |
| 20 | + ctypes.windll.user32.ShowWindow(hwnd, 0) # SW_HIDE |
23 | 21 |
|
24 | 22 | from pathlib import Path |
25 | 23 | from frontend.customhttpserver import CustomHTTPServer |
|
0 commit comments