screen size python code example

Example 1: get screen size python

>>> import pyautogui

>>> width, height= pyautogui.size()

>>> print(width)
1366

>>> print(height)
768

Example 2: python get screen size

from win32api import GetSystemMetrics

print("Width =", GetSystemMetrics(0))
print("Height =", GetSystemMetrics(1))

Example 3: screen size python

from screeninfo import get_monitors
screen = get_monitors()[0]

# if that raises an error, try using this first
# from os import environ
# environ['DISPLAY'] = ':0.0'

print(screen)

Tags:

Misc Example