Skip to main content

Fast Bluestacks screenshots with pywin32

Project description

Fast Bluestacks screenshots with pywin32

pip install nescree32

Tested against Windows 10 / Python 3.11 / Anaconda / BlueStacks

# pywin32 is not listed in requirements.txt
# install it using: pip install pywin32

from nescree32 import get_screenshots_from_bluestacks
import cv2

# INTER_NEAREST: int
# INTER_LINEAR: int
# INTER_CUBIC: int
# INTER_AREA: int
# INTER_LANCZOS4: int
# INTER_LINEAR_EXACT: int
# INTER_NEAREST_EXACT: int
# INTER_MAX: int
# WARP_FILL_OUTLIERS: int
# WARP_INVERSE_MAP: int

interpolation = cv2.INTER_AREA
show_original_android_size = True
bst_instance = "Rvc64_37"
adb_path = r"C:\ProgramData\chocolatey\lib\adb\tools\platform-tools\adb.exe"
printresults = False
show_fps = True
for (
    image,
    original_rect,
    start_x,
    start_y,
    width,
    height,
    end_x,
    end_y,
    adb_width,
    adb_height,
) in get_screenshots_from_bluestacks(
    instance_to_automate=bst_instance,
    adb_path=adb_path,
    show_fps=show_fps,
):
    if printresults:
        print(
            image.shape,
            original_rect,
            start_x,
            start_y,
            width,
            height,
            end_x,
            end_y,
            adb_width,
            adb_height,
        )
    if not show_original_android_size:
        # use this to automate via win32
        cv2.imshow(bst_instance, image)
    else:
        # use this to automate via adb.exe
        if adb_width == -1:
            adb_width = 900
        if adb_height == -1:
            adb_height = 1600
        image_original_adb = cv2.resize(
            image, (adb_width, adb_height), interpolation=interpolation
        )
        cv2.imshow(bst_instance, image_original_adb)

    if cv2.waitKey(1) & 0xFF == ord("q"):
        break
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

nescree32-0.10.tar.gz (22.0 kB view hashes)

Uploaded Source

Built Distribution

nescree32-0.10-py3-none-any.whl (22.3 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