I have a console application written in python using pyinstaller
. I need the program window to be hidden (if the user specified it), but at the same time it continued to work in the background, and when you click on the icon again, the previously hidden window just showed.
Usually such applications are displayed on the taskbar when you click on the arrow with the text - show hidden icons.
import win32gui
import win32con
def main():
while True:
c_out = input(f"Enter command: ")
if c_out.lower() == 'hide':
window('hide')
def window(mode: str):
the_program_to_hide = win32gui.GetForegroundWindow()
if mode == 'show':
win32gui.ShowWindow(the_program_to_hide, win32con.SW_SHOW)
else:
win32gui.ShowWindow(the_program_to_hide, win32con.SW_HIDE)
main()