mirror of
https://github.com/netinvent/npbackup.git
synced 2025-09-14 17:04:55 +08:00
GUI: Add some more debugging for non hidden console windows
This commit is contained in:
parent
524cfca026
commit
9b931847ac
1 changed files with 13 additions and 1 deletions
|
@ -7,11 +7,14 @@ __intname__ = "npbackup.gui.windows_gui_helper"
|
||||||
__author__ = "Orsiris de Jong"
|
__author__ = "Orsiris de Jong"
|
||||||
__copyright__ = "Copyright (C) 2022-2025 NetInvent"
|
__copyright__ = "Copyright (C) 2022-2025 NetInvent"
|
||||||
__license__ = "GPL-3.0-only"
|
__license__ = "GPL-3.0-only"
|
||||||
__build__ = "2023020601"
|
__build__ = "2025061201"
|
||||||
|
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
from logging import getLogger
|
||||||
|
|
||||||
|
logger = getLogger()
|
||||||
|
|
||||||
|
|
||||||
def handle_current_window(action: str = "minimize") -> None:
|
def handle_current_window(action: str = "minimize") -> None:
|
||||||
|
@ -29,6 +32,11 @@ def handle_current_window(action: str = "minimize") -> None:
|
||||||
current_executable = os.path.abspath(sys.argv[0])
|
current_executable = os.path.abspath(sys.argv[0])
|
||||||
# console window will have the name of current executable
|
# console window will have the name of current executable
|
||||||
hwndMain = win32gui.FindWindow(None, current_executable)
|
hwndMain = win32gui.FindWindow(None, current_executable)
|
||||||
|
if not hwndMain:
|
||||||
|
logger.debug(
|
||||||
|
"No hwndmain found for current executable, trying foreground window"
|
||||||
|
)
|
||||||
|
hwndMain = win32gui.GetForegroundWindow()
|
||||||
if hwndMain:
|
if hwndMain:
|
||||||
if action == "minimize":
|
if action == "minimize":
|
||||||
win32gui.ShowWindow(hwndMain, win32con.SW_MINIMIZE)
|
win32gui.ShowWindow(hwndMain, win32con.SW_MINIMIZE)
|
||||||
|
@ -38,3 +46,7 @@ def handle_current_window(action: str = "minimize") -> None:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
f"Bad action parameter for handling current window: {action}"
|
f"Bad action parameter for handling current window: {action}"
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
logger.debug(
|
||||||
|
f"No window found for current executable {current_executable}, cannot minimize/hide"
|
||||||
|
)
|
||||||
|
|
Loading…
Add table
Reference in a new issue