• Stars
    star
    153
  • Rank 241,849 (Top 5 %)
  • Language
    Python
  • License
    GNU Affero Genera...
  • Created over 9 years ago
  • Updated about 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

πŸ“Έ Automate capturing screenshots of apps and windows on macOS

πŸ“Έ 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.

More Repositories

1

cast_control

πŸ“Ί Control Chromecasts from Linux and D-Bus
Python
468
star
2

onhold

πŸ”Š Play sounds while and after shell jobs complete
Python
156
star
3

aiopath

πŸ“ Asynchronous pathlib for Python
Python
134
star
4

mpris_server

▢️ Integrate MPRIS Media Player support into your app
Python
25
star
5

brightness

β˜€οΈ Dim your Mac's display from the command line via CoreDisplay
Python
25
star
6

limiter

⏲️ Easy rate limiting for Python using a token bucket algorithm, with async and thread-safe decorators and context managers
Python
20
star
7

parse_google_sms

πŸ“±Data forensics and recovery utility for Google Voice chats saved via Google Takeout
Python
18
star
8

save_skype

πŸ’¬ Data forensics and recovery utility for Skype chats and history
Python
13
star
9

cast_convert

πŸ“½οΈ Convert videos to Chromecast compatible formats
Python
7
star
10

ding

Python
7
star
11

play_sounds

πŸ”Š Play music and sounds in your Python scripts, synchronously and asynchronously.
Python
6
star
12

intel-gvtg

Scripts for managing Intel virtual gfx and KVM
Shell
6
star
13

strs

🧡 Easy string tools for the shell
Python
4
star
14

app_paths

πŸ“‚ Like appdirs, but with pathlib, path creation and async support.
Python
4
star
15

grub2systemd

πŸ’Ύ Convert grub.cfg to systemd-boot EFI loader entries
Python
4
star
16

unpackable

πŸ“¦ Destructure Python objects
Python
3
star
17

dreamhost-dyndns

Updates Dreamhost DNS Records via DynamicDNS (DynDNS) API
Python
3
star
18

delete_scrobbles

❌ Automatically delete scrobbles on Last.fm
JavaScript
3
star
19

alexdelorenzo

2
star
20

disjoint_set

Union find / disjoint union set
Python
2
star
21

pinterest_tools

TamperMonkey tools for Pinterest
JavaScript
2
star
22

find-ubuntu-mirrors

πŸ” Find Apt repository mirrors for Ubuntu
Shell
2
star
23

npm-user

🏠 Install npm packages as a non-root user
Shell
2
star
24

ubuntu-kernel

Download latest mainline kernel from Ubuntu's kernel PPA
Shell
2
star
25

rust-book

Code examples, tests, and responses from the Rust Book https://doc.rust-lang.org/book/
Assembly
2
star
26

transmission_user

Change the user of the transmission-daemon in Debian/Ubuntu
Shell
2
star
27

buf_stream

Rust
1
star
28

nth_py

Python
1
star
29

nth_rs

Return or exclude the nth item via stdin
Rust
1
star
30

minesweeper

minesweeper game + shoddily put together gui + a board solver
Python
1
star
31

cacheit

Caching decorator for Python callables
Python
1
star
32

buffers-rs

βŒ› A stream buffer backed by a temporary file.
Rust
1
star
33

userscripts

JavaScript
1
star
34

html_wrapper

HTML parser with lxml backend. Implements subset of BeautifulSoup API
Python
1
star
35

cheapbook

Send email/SMS notifications about Apple's refurb stock
Python
1
star
36

byte_lines

Iterate over lines of bytes from anything that implements std::io::Read
Rust
1
star
37

buffer

βŒ› A stream buffer backed by tempfile.SpooledTemporaryFile
Python
1
star
38

covid_schools

Script that puts together a COVID spreadsheet
Python
1
star
39

wordpress_menu

Drop down menu for Wordpress
JavaScript
1
star