Python Get Computer Screen Size Using PyAutoGUI: A Beginner Guide – Python Tutorial

By | November 3, 2019

Sometimes, we have to get computer screen size using python, especially, when you want to take the screenshot of computer. In this tutorial, we will write an simple example to show you how to do?

python get computer screen size

There are some python libraries which can get computer screen size, such as gtk, wxPython, Tkinter, PySide or PyAutoGUI. In this tutorial, we will use python pyautogui library.

Install pyautogui

You can use python pip install command to install python pyautogui in your computer.

pip install pyautogui

Get screen width and height

import pyautogui
size = pyautogui.size()

Run this python script, you can get the size of screen.

Size(width=1366, height=768)

You also can do like this:

width, height = pyautogui.size()

The width and height is:


Notice: the width and height is the screen resolution.

Leave a Reply

Your email address will not be published. Required fields are marked *