pythonscreenresolution

How do I get monitor resolution in Python?


What is the simplest way to get monitor resolution (preferably in a tuple)?


Solution

  • On Windows:

    from win32api import GetSystemMetrics
    
    print("Width =", GetSystemMetrics(0))
    print("Height =", GetSystemMetrics(1))
    

    If you are working with high resolution screen, make sure your python interpreter is HIGHDPIAWARE.

    Based on this post.