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 details)

Uploaded Source

Built Distribution

nescree32-0.10-py3-none-any.whl (22.3 kB view details)

Uploaded Python 3

File details

Details for the file nescree32-0.10.tar.gz.

File metadata

  • Download URL: nescree32-0.10.tar.gz
  • Upload date:
  • Size: 22.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for nescree32-0.10.tar.gz
Algorithm Hash digest
SHA256 ca8ef09fe94c3e043bc1d6dfcfebd629564537a80ba73fb5b87bab51a8ec4f02
MD5 bb3b92e9393439c122f70426ddd4a8f1
BLAKE2b-256 1998411debfe901238b47efafd2329135f0ef94f652f01c115b8d6cc24d179dc

See more details on using hashes here.

File details

Details for the file nescree32-0.10-py3-none-any.whl.

File metadata

  • Download URL: nescree32-0.10-py3-none-any.whl
  • Upload date:
  • Size: 22.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for nescree32-0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 530f64e9b419f06833c19c702befa9657c2081b25d06381a7311e8ea7ba2127b
MD5 a1b12f765772e608c68b2e8831da2b2e
BLAKE2b-256 80ee48f2c1f9afcb4178758e0221b1325e9b5510af6aa5f63444940a04bdbb8a

See more details on using hashes here.

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