Python package to take screenshots of windows that are in background
Project description
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.
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 bshot-1.0.5.tar.gz.
File metadata
- Download URL: bshot-1.0.5.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6d82a93d14c9d88df15b1bcd3c4cceb44bf9240c3f6b083e420ff2d74ebcf36b
|
|
| MD5 |
2a4f00fb8de08ba6762b7cdee448323c
|
|
| BLAKE2b-256 |
2f9081b8ca991502032ad856246db7c518486f0185889eee2487de5c46adf366
|
File details
Details for the file bshot-1.0.5-py3-none-any.whl.
File metadata
- Download URL: bshot-1.0.5-py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5d4f8f53badbc12aecc1d91a5465bd50ece8d8cf54e751a453e04f7c96eb1fb5
|
|
| MD5 |
70dc53f61fdcecb11b65e6c25d9239f1
|
|
| BLAKE2b-256 |
4406a668423e31b3f2d746b494137246851f7495e4ba21c14fb06995fd310134
|