def capture_screen():
    """
    Captures the screen to a Pillow Image object
    """
    from PIL import Image
    import mss
    with mss.mss() as sct:
        for monitor in sct.monitors:
            if monitor['left'] == 0 and monitor['top'] == 0:
                break
        sct_img = sct.grab(monitor)
    img = Image.frombytes('RGB', sct_img.size, sct_img.bgra, 'raw', 'BGRX')
    return img
