How to know if a window is maximized using pywin32?

不打扰是莪最后的温柔 提交于 2021-01-28 11:09:17

问题


I need to check if a window is maximized using pywin32. I'm on a windows 10 machine.

I have looked through the documentation but can't find a straight solution, any leads?


回答1:


Use GetWindowPlacement API.

In pywin32, win32gui.GetWindowPlacement will return a tuple which can be tested as follows:

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


来源:https://stackoverflow.com/questions/56387889/how-to-know-if-a-window-is-maximized-using-pywin32

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!