From e0be168779c918f97cf5589202b36a2276f29ab9 Mon Sep 17 00:00:00 2001 From: Ozzie Isaacs Date: Sun, 9 Jun 2024 10:34:20 +0200 Subject: [PATCH] Fix --- cps.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/cps.py b/cps.py index f97d0f5a..8af6cef1 100755 --- a/cps.py +++ b/cps.py @@ -27,7 +27,27 @@ sys.path.insert(0, path) 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') + + if __name__ == '__main__': + if os.name == "nt": + hide_console_windows() main()