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():
import ctypes
import os
hwnd = ctypes.windll.kernel32.GetConsoleWindow()
if hwnd != 0:
try:
import win32process
except ImportError:
print("To hide console window install 'pywin32' using 'pip install pywin32'")
return
ctypes.windll.user32.ShowWindow(hwnd, 0)
ctypes.windll.kernel32.CloseHandle(hwnd)
_, pid = win32process.GetWindowThreadProcessId(hwnd)
os.system('taskkill /PID ' + str(pid) + ' /f')
kernel32 = ctypes.WinDLL('kernel32')
user32 = ctypes.WinDLL('user32')
SW_HIDE = 0
hWnd = kernel32.GetConsoleWindow()
if hWnd:
user32.ShowWindow(hWnd, SW_HIDE)
if __name__ == '__main__':

View File

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