Skip to main content

Screenshots - ctypes

Project description

Screenshot with ctypes

Tested against Windows 10 / Python 3.11 / Anaconda

pip install screenshotct

import cv2
from screenshotct import take_screenshot
import time
from ctypes_window_info import get_window_infos

for q in get_window_infos():
    print(q)

# hwnd
ir = take_screenshot(
    hwnd=2100816,
    crop=(0, 0, 0, 100),
    show_fps=True,
    brg_to_rgb=False,
    ignore_exceptions=True,
    client=True,
)

# first screen
# ir = take_screenshot(
#     hwnd='0',
#     crop=(0, 0, 0, 100),
#     show_fps=True,
#     brg_to_rgb=False,
#     ignore_exceptions=True,
#     client=True,
# )

# all screens
# ir = take_screenshot(
#     hwnd="all",
#     crop=(0, 0, 0, 100),
#     show_fps=True,
#     brg_to_rgb=False,
#     ignore_exceptions=True,
#     client=True,
# )

fps = 0
last_time = time.time()
for _ in range(1000):
    try:
        pic = next(ir)
        fps += 1
        cv2.imshow("pic", pic[0])
        if cv2.waitKey(1) & 0xFF == ord("q"):
            break
    except Exception as e:
        print(e)
print(f"\n\n\n{fps / (time.time() - last_time)}\n")
cv2.destroyAllWindows()

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

screenshotct-0.11.tar.gz (22.3 kB view hashes)

Uploaded Source

Built Distribution

screenshotct-0.11-py3-none-any.whl (22.7 kB view hashes)

Uploaded Python 3

Supported by

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