Skip to main content

Take screenshots on macOS

Reason this release was yanked:

Issue running on macOS

Project description

📸 screenshot: Better macOS screenshots via the Terminal

screenshot is a command line utility that lets you specify an application name and window title in order to take a screenshot of a specific window.

Using screenshot, you can capture windows belonging to an application, or only an application's windows with certain titles.

Justification and Use Case

The macOS screencapture utility is not developer friendly.

To programmatically take a screenshot of an application, or a specific window, you must supply a window ID to screencapture. In order to find a window's window ID, you'll need call out to Quartz.

In newer versions of macOS, the screencapture utility improves the user experience slightly: you can run the command and then click on the window you'd like to capture.

However, that necessitates that the user clicks a window each time. You cannot include this as part of an automated pipeline.

To that end, I use this utility to automatically generate screenshots of web, mobile and desktop applications.

Example

Take a screenshot of the current Terminal window and view it with Preview.app:

open "`screenshot Terminal`"

Take a screenshot of the Pycharm application with the window title containing "screenshot":

screenshot Pycharm -t screenshot

Installation

You will need Python 3.6+. Please install it with brew or ports if you do not have it already.

PyPI

pip3 install screenshot

Github Source

Grab the source, run the following in the source dir:

pip3 install -r requirements.txt

then run

python3 setup.py install

Usage

screenshot --help

Usage: screenshot [OPTIONS] APPLICATION_NAME

Options:
  -w, --window_selection_options TEXT
                                  Options: all_windows, on_screen_only,
                                  above_window, below_window, include_window,
                                  exclude_desktop
                                  Default: exclude_desktop
                                  on_screen_only
  -t, --title TEXT                Title of window from APPLICATION_NAME to
                                  capture.
  -f, --filename TEXT             Filename to save the captured PNG as.
  -a, --all_windows               Capture all windows matching parameters.
  -o, --output TEXT               Image format to create, default is png
                                  (other options include pdf, jpg, tiff)
  -s, --shadow                    Capture the shadow of the window.
  --help                          Show this message and exit.

License

See LICENSE. Message me if you'd like to use this project with a different license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

screenshot-1.0.1-py2.py3-none-any.whl (15.2 kB view details)

Uploaded Python 2Python 3

File details

Details for the file screenshot-1.0.1-py2.py3-none-any.whl.

File metadata

  • Download URL: screenshot-1.0.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 15.2 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.6

File hashes

Hashes for screenshot-1.0.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 48122165c26ad5ad7177068e98b7ad187d08b56060b87ea4c2c31d0382c23f96
MD5 270385b63dfbbda3bbcec1d58c868610
BLAKE2b-256 262e383b54c8b37892e5c77fd53238ae314303b647d936c49aaf0621299ed836

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page