问题
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