Skip to main content

bshot

Python package to take screenshots of windows that are in background

Installation

You can install the package via pip:

pip install bshot

Usage

import cv2
import win32gui

from bshot.screenshot import get_image

hwnd = win32gui.FindWindow(None, "Untitled - Notepad")
img = get_image(hwnd, method="srccopy") # windll and srccopy methods
cv2.namedWindow("bshot", cv2.WINDOW_NORMAL)
cv2.imshow("bshot", img)
cv2.waitKey(0)

Benchmark

The speed of the capture depends on the size of the window that is being captured. It can caputre 220x160 window with 2400+ fps.

import time

import win32gui

from bshot.screenshot import get_image

hwnd = win32gui.FindWindow(None, "Untitled - Notepad")

start = time.time()
count = 0
while time.time() - start < 1:
    get_image(hwnd, method="srccopy")
    count += 1
print("fps =", count)

Limitations

  • The screenshot module uses GetClientRect which can crop some portion of the window contents.

License

This project is licensed under the terms of the MIT license.

Metadata

Release files for bshot 1.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bshot 1.0.5
File Size Uploaded Provenance
bshot-1.0.5.tar.gz 4.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for bshot 1.0.5
File Interpreter ABI Platform
bshot-1.0.5-py3-none-any.whl Python 3 none any Details

Total release size: 9.2 kB

Release files / bshot-1.0.5.tar.gz

Download URL bshot-1.0.5.tar.gz
Size 4.3 kB
Tags Source
SHA-256 checksum
How to use checksums
6d82a93d14c9d88df15b1bcd3c4cceb44bf9240c3f6b083e420ff2d74ebcf36b
BLAKE2b-256 checksum
How to use checksums
2f9081b8ca991502032ad856246db7c518486f0185889eee2487de5c46adf366
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.23

Release files / bshot-1.0.5-py3-none-any.whl

Download URL bshot-1.0.5-py3-none-any.whl
Size 4.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5d4f8f53badbc12aecc1d91a5465bd50ece8d8cf54e751a453e04f7c96eb1fb5
BLAKE2b-256 checksum
How to use checksums
4406a668423e31b3f2d746b494137246851f7495e4ba21c14fb06995fd310134
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.23

Security for bshot 1.0.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page