1

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.

6
  • 1
    Microsoft Windows? Commented May 29, 2020 at 18:34
  • @Heitor Chang yeah Commented May 29, 2020 at 18:35
  • I'm investigating, a promising lead is pywin32 and win32gui, unfortunately these do not run on Python 3.7 or 3.8. Is downgrading your Python (or using a virtualenv) a possibility? if everything fails you should look at AutoIt Commented May 29, 2020 at 18:43
  • A minimized window belonging to your application (in which case the GUI toolkit you're using will almost certainly be relevant), or belonging to another application? Commented May 29, 2020 at 18:45
  • @Heitor Chang yeah, i can downgrade a bit Commented May 29, 2020 at 18:46

1 Answer 1

5

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

Another StackOverflow question

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.