is it possible to un-minimize a minimized window using python on windows 10? (I'm using python 3.8)
I would add more detail but that's really all I need to say.
is it possible to un-minimize a minimized window using python on windows 10? (I'm using python 3.8)
I would add more detail but that's really all I need to say.
I combined information from multiple sources and got this to work (Miniconda Python 3.6, Windows 10)
import win32gui
import win32con
def windowEnumHandler(hwnd, top_windows):
top_windows.append((hwnd, win32gui.GetWindowText(hwnd)))
def bringToFront(window_name):
top_windows = []
win32gui.EnumWindows(windowEnumHandler, top_windows)
for i in top_windows:
# print(i[1])
if window_name.lower() in i[1].lower():
# print("found", window_name)
win32gui.ShowWindow(i[0], win32con.SW_SHOWNORMAL)
win32gui.SetForegroundWindow(i[0])
break
# Test with notepad
if __name__ == "__main__":
winname = "notepad"
bringToFront(winname)
The Handler is not optimal; it spits out various processes that are not the windows in the taskbar. However, as long as your window_name
is specific I don't think you'll run into problems. If you remove the break
, all matches will be "opened".
Sources: Mouse and Python Blog