pygetwindow Error, AttributeError: 'list' object has no attribute 'topleft'

I am trying to get a screenshot of a specific window, but I get the following Error: AttributeError: ‘list’ object has no attribute ‘topleft’. How can I solve it ?

import pygetwindow
import pyautogui
from PIL import Image
import platform

path = 'report/result.png'
titles = pygetwindow .getAllTitles()

if platform.system() == 'Windows':
    window = pygetwindow.getWindowsWithTitle('bachelor-project-vision-based-traffic-scene-surveillance –')
    left, top = window.topleft
    right, bottom = window.bottomright
    im =
    im = im.crop((left, top, right, bottom))
    im =

elif platform.system() == 'Darwin':
    x1, y1, width, height = pygetwindow .getWindowGeometry('Chrome')
    x2 = x1 + width
    y2 = y1 + height
    im =
    # im = im.crop((x1, y1, x2, y2+10))

>Solution :

getWindowsWithTitle returns a list , try to access its member

window[0] and try to extract top and left from that

Leave a Reply