Search code examples
macosscreen-capture

Using built-in screen capture functions in OSX and receive output?


As most advanced mac users know there is a simple way to take a screenshot. Just using command-shift-4 to take part of a screen as an example. But is there a possibility to use this functionality from say, a python script?

I've seen other threads about taking a screen capture from python (or other languages) but is there any way to use the built in functionality from a script and then use the output as you will?


Solution

  • You can call the terminal command screencapture

    This can be invoked from a python script (or other script):

    import os;
    os.system("screencapture /tmp/test.jpg");
    #### do your stuff with the file