Skip to content

Commit 4ce0cce

Browse files
committed
revert last. Add a new .bat for windows users to click on. This avoids the focus issue when clicking directly on the vpinfe.exe with explorer.
1 parent 7bd8607 commit 4ce0cce

3 files changed

Lines changed: 21 additions & 14 deletions

File tree

.github/workflows/build.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,13 @@ jobs:
100100
fi
101101
shell: bash
102102

103-
# 9. Upload artifact per OS
103+
# 9. Copy Windows launcher bat file
104+
- name: Copy Windows launcher
105+
if: runner.os == 'Windows'
106+
run: cp vpinfe.bat dist/vpinfe/
107+
shell: bash
108+
109+
# 10. Upload artifact per OS
104110
- name: Upload build artifact
105111
uses: actions/upload-artifact@v4
106112
with:

main.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,18 @@
66
import multiprocessing
77
multiprocessing.freeze_support()
88

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):
1213
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
2321

2422
from pathlib import Path
2523
from frontend.customhttpserver import CustomHTTPServer

vpinfe.bat

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@echo off
2+
cd /d "%~dp0"
3+
vpinfe.exe %*

0 commit comments

Comments
 (0)