-1

I am trying to detect if a window is open using win32gui.IsIconic(hWnd). What exactly do I put in to substitute hWnd?

My goal is pretty simple: If a program, for example Notepad, is maximized, I want a boolean to be true, and if not, it's false.

I am not 100% familiar with programming terms as I am a bit on the newer side of programming, so examples/specifics help tops.

  • Does this answer your question? [How to know if a window is maximized using pywin32?](https://stackoverflow.com/questions/56387889/how-to-know-if-a-window-is-maximized-using-pywin32) – Filip Mar 01 '20 at 02:45

1 Answers1

2

This would probably work.

window = win32gui.FindWindow("Notepad", None)
if window:
    tup = win32gui.GetWindowPlacement(window)
    if tup[1] == win32con.SW_SHOWMAXIMIZED:
        minimized = False
    elif tup[1] == win32con.SW_SHOWMINIMIZED:
        minimized = True
    elif tup[1] == win32con.SW_SHOWNORMAL:
        normal = True

The code is from this answer: Duplicate

Filip
  • 898
  • 1
  • 8
  • 24