Background tray utility that screenshots and OCRs in one hotkey press.
Project description
Snap OCR
Snap OCR is a cross-platform tray utility that grabs a screenshot in the background, runs Tesseract OCR, and saves both PNG and TXT outputs. The app stays out of the way: press the global hotkey, capture happens, and you keep working.
For a fully detailed reference (including troubleshooting matrices) see src/snap_ocr/__main__.py. The highlights below cover the essentials.
Features
- Global hotkey capture using
pynput(default<ctrl>+<shift>+s, configurable). - Full screen, fixed region, Windows FancyZones, or macOS MacsyZones capture modes.
- Timestamped filenames with optional overwrite mode that keeps only the most recent capture.
- Background OCR via
pytesseract, atomic writes, and user-configurable save locations. - Tray controls for quick actions (Take Screenshot, Toggle Overwrite, open folders, reload config, view logs, quit).
- Zero network access; outputs and logs stay on your machine.
Prerequisites
- Python 3.10 or newer.
- Tesseract OCR installed and on your
PATH, or settesseract_cmdin the config file. - macOS users must grant Screen Recording + Accessibility rights; Windows users just need Tesseract.
Installation
pipx (recommended)
- Download or clone this repository.
- In the project root run:
pipx install .
- Launch with
snap-ocr(no terminal needs to remain open; the app continues from the tray).
pipx isolates the app in its own virtual environment and drops a snap-ocr command on your PATH. On Windows the shim is placed in %USERPROFILE%\.local\bin.
From a virtual environment
python -m venv .venv
source .venv/bin/activate # or .venv\Scripts\activate on Windows
python -m pip install -r requirements.txt
python -m pip install -e .
python -m snap_ocr
To run a one-off capture without starting the tray: snap-ocr --capture-once.
Usage Overview
- Start the tray app:
snap-ocr - Global hotkey:
<ctrl>+<shift>+s(customize viaconfig.yaml). - CLI helpers:
snap-ocr --capture-once– Immediate capture then exit.snap-ocr --show-config-path– Print the active config file path.snap-ocr --open-config– Open the config in your default editor/finder.
The tray icon exposes menu items for the capture mode, overwrite toggle, reloading the config, opening output directories, viewing logs, and quitting.
Configuration
The first launch writes config.yaml to the OS-specific config directory (~/Library/Application Support/snap-ocr/config.yaml on macOS, %APPDATA%\snap-ocr\config.yaml on Windows).
Key fields:
| Setting | Description |
|---|---|
hotkey |
pynput syntax string for the global hotkey ("<option>+<shift>+s", etc.). |
save_dir_images, save_dir_text |
Output folders for PNG and text files. |
filename_pattern |
Naming template; supports {base} and {timestamp} placeholders. |
overwrite_mode |
If true, the previous capture files are deleted after each successful save. |
capture_mode |
One of full, region, fancyzones, or macsyzones. |
region |
Coordinates used when capture_mode: region. |
macsyzones_* / fancyzones_* |
Options for their respective zone integrations. |
Validation errors surface immediately with the file path and a suggested fix. After editing, choose Reload Config from the tray or restart the app.
Platform Notes
macOS
- Grant Screen Recording + Accessibility (and Input Monitoring if prompted) to the Python host or packaged app.
- Optional auto-start: place a
LaunchAgentpointing to yourpipxinterpreter, thenlaunchctl loadit. - MacsyZones capture maps to layouts created by the third-party MacsyZones utility, matching the zone under the current cursor.
Windows
- Installing Tesseract (UB Mannheim build recommended) is the only prerequisite; no special capture permissions are required.
- FancyZones mode reads Windows PowerToys configuration to align screenshots with zone layouts.
- You can pin
snap-ocr.exe(from%USERPROFILE%\.local\bin) to the Start menu or drop a shortcut inshell:startupfor launch-at-login.
Packaging (macOS)
pipx install pyinstaller(orpython -m pip install pyinstaller).- Run
scripts/build_mac_app.shto generatedist/Snap OCR.app(automatically converts the icon to.icns). - Update
scripts/sign_and_notarize.shwith your Developer ID and notarytool profile, then execute it to sign/notarize/staple the bundle. - Launch the notarised app once to trigger the permission prompts.
Troubleshooting Quick Hits
- Hotkey doesn’t fire (macOS): reopen System Settings → Privacy & Security to confirm Accessibility permission.
- Black screenshots (macOS): Screen Recording access missing or revoked.
- No text output: verify Tesseract path/language packs and that the captured region contains legible text.
- Audible “bonk” sound on hotkey: change
hotkeyto avoid combinations that the focused app doesn’t recognize. - Files not overwritten: confirm
overwrite_mode: true; the tool deletes the previous PNG/TXT pair immediately before writing the next capture.
If you plan to distribute Snap OCR, consider publishing to PyPI so others can install with pip install snap-ocr. Until then, installing from this repository via pipx install . remains the quickest path.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file snap_ocr-0.2.0.tar.gz.
File metadata
- Download URL: snap_ocr-0.2.0.tar.gz
- Upload date:
- Size: 59.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c8f68e3012977c3316f9ac64f990ba85ce0d5713ab724a7a56a4f33738586ddb
|
|
| MD5 |
a6af595a9a3844fbbac5edd425b8b4ef
|
|
| BLAKE2b-256 |
92f89ad1879df7ee68c0e159f4647ec951b069844061f359e374b1bdbd260a33
|
File details
Details for the file snap_ocr-0.2.0-py3-none-any.whl.
File metadata
- Download URL: snap_ocr-0.2.0-py3-none-any.whl
- Upload date:
- Size: 58.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c297552bd7f9bdb404515d0512b6acdfd5d3272c3018b17ef56581e2f16bc0c
|
|
| MD5 |
ada2f90af35f0e0eceeed1e67efad58d
|
|
| BLAKE2b-256 |
40fc06bd8b2cf30ada00bbd75a11fe0a0777223a8c078077cd6dffbdde60a4c4
|