1
0
mirror of https://github.com/janeczku/calibre-web synced 2024-12-18 06:00:32 +00:00

Fix hiding console window on windows

This commit is contained in:
Ozzie Isaacs 2024-07-18 20:32:47 +02:00
parent 02d2c2bbf8
commit 7367e96d2b
2 changed files with 8 additions and 15 deletions

20
cps.py
View File

@ -30,19 +30,15 @@ from cps.main import main
def hide_console_windows(): def hide_console_windows():
import ctypes import ctypes
import os
hwnd = ctypes.windll.kernel32.GetConsoleWindow() kernel32 = ctypes.WinDLL('kernel32')
if hwnd != 0: user32 = ctypes.WinDLL('user32')
try:
import win32process SW_HIDE = 0
except ImportError:
print("To hide console window install 'pywin32' using 'pip install pywin32'") hWnd = kernel32.GetConsoleWindow()
return if hWnd:
ctypes.windll.user32.ShowWindow(hwnd, 0) user32.ShowWindow(hWnd, SW_HIDE)
ctypes.windll.kernel32.CloseHandle(hwnd)
_, pid = win32process.GetWindowThreadProcessId(hwnd)
os.system('taskkill /PID ' + str(pid) + ' /f')
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -43,6 +43,3 @@ comicapi>=2.2.0,<3.3.0
# Kobo integration # Kobo integration
jsonschema>=3.2.0,<4.24.0 jsonschema>=3.2.0,<4.24.0
# Hide console Window on Windows
pywin32>=220,<310 ; sys_platform == 'win32'