I am trying to program an application that outputs some log messages to the console. However, this console needs to be hidden most of the time.
I have managed to hide this console using win32gui.ShowWindow(ctypes.windll.kernel32.GetConsoleWindow(), win32con.SW_HIDE).
I would like to occasionally bring the console back up through hidden icon in the system tray and review its output. Is this possible, and if so, how can it be done?
Thank you for your responses.
ia have tried som of those lines but nothing works
win32gui.ShowWindow(ctypes.windll.kernel32.GetConsoleWindow(), win32con.SW_SHOW)
win32gui.BringWindowToTop(ctypes.windll.kernel32.GetConsoleWindow())
win32api.SetForegroundWindow(ctypes.windll.kernel32.GetConsoleWindow())
___________________________________________________________________
def show_console(hwnd):
win32gui.ShowWindow(hwnd, win32con.SW_SHOW)
win32gui.BringWindowToTop(hwnd)
win32api.SetForegroundWindow(hwnd)
if __name__ == "__main__":
hwnd = get_console_window()
hide_console(hwnd)
time.sleep(5)
show_console(hwnd)
Pepa Jan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.