diff --git a/cps.py b/cps.py index 8af6cef1..039c2a5e 100755 --- a/cps.py +++ b/cps.py @@ -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__': diff --git a/optional-requirements.txt b/optional-requirements.txt index 3f6b6e37..d63bc41c 100644 --- a/optional-requirements.txt +++ b/optional-requirements.txt @@ -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'