Reference
https://stackoverflow.com/questions/24370228/python-imaging-library-fails-to-grab-whole-screen
Envirionment
macOS BigSur
Visual Studio Code
Python 3.8.5 64bit
Prerequisites
$ pip install pillow
Add permission to the application which run this code. In this case, the code is running under the Code (Visual Studio code), and the Code has to be checked for capturing screens as follows.
Code
from PIL import ImageGrab import os import time def screenGrab(): box = (0, 0, 1920, 1080) im = ImageGrab.grab(box) im.save(os.getcwd() + '\\screenshot_' + str(int(time.time())) + '.png', 'PNG') def main(): screenGrab() if __name__ == '__main__': main()