Skip to main content

pyvisauto

pyvisauto is a Python visual automation tool. Inspired by Sikuli, pyvisauto provides Python-native easy-to-use abstractions for complex interactions with on-screen visual elements by wrapping OpenCV (specifically opencv-contrib-python-headless), pyautogui, pytesseract, and numpy.

Features include:

  • OpenCV and numpy-driven image matching of on-screen elements
  • TesseractOCR support
  • Methods to find an image match (find), find all matches (find_all), check if a match exists (exists), wait until an image match occurs (wait), and wait for an image match to disappear (wait_vanish)
  • Methods to click and hover over regions and matches (click and hover, respectively) with random x and y coordinates within the region
  • Sub-region and cached matching for faster performance
  • Method to save screenshots of matches and regions to a file (screenshot)

Requirements

pyvisauto has been tested on Python 3.7. The opencv-contrib-python-headless package limits availability to Python 2.7 and 3.4 ~ 3.7. While pyvisauto should be compatible with Python 3, Python 3.8 is currently not supported.

Installation and Usage

  1. Install OS-specific dependencies:
    • Windows: No extra dependencies needed
    • Linux: python3-xlib
    • OSX: pyobjc-core and pyobjc, in that order
  2. Install pyvisauto using pip: pip install pyvisauto
  3. Import pyvisauto: import pyvisauto
  4. Read the Quick Start and API docs

Quick Start

  • Define a full-screen region and assign it to r:

    r = pyvisauto.Region()
    
  • Define a region with the upper-left corner at x: 50px and y: 100px, with a width of 500px and height of 300px and assign it to r:

    r = pyvisauto.Region(50, 100, 500, 300)
    
  • Find the image asset1.png in the defined region, with a similarity score of 0.9:

    match1 = r.find('asset1.png', 0.8)
    
  • If there has been no visual changes in the defined region, subsequent find actions can be expedited by passing in cached=True:

    match2 = r.find('asset2.png', 0.9, cached=True)
    
  • find_all and exists can be used in a similar fashion as find.

  • Hover over a random point in the first returned match:

    match1.hover()
    
  • Click a random point in the second returned match:

    match2.click()
    
  • One can use wait and vanish to wait for on-screen changes, detected by the presence or disappearance of an image on-screen, respectively:

    r.wait('wait_asset1.png', 30, 0.8)
    

    The above code will wait for wait_asset1.png in the previously defined region r, with a minimum similarity score of 0.8, waiting a maximum of 30 seconds before throwing a FindFailed exception. vanish, on the other hand, throws a VanishFailed exception. Both exceptions are defined in the pyvisauto module.

Metadata

Release files for pyvisauto 1.0.3

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

Source distribution (sdist)

Source distribution for pyvisauto 1.0.3
File Size Uploaded Provenance Actions
pyvisauto-1.0.3.tar.gz 6.3 kB Without provenance Details for pyvisauto-1.0.3.tar.gz

Built distribution (wheel)

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

Total release size: 28.4 kB

Release files / pyvisauto-1.0.3.tar.gz

Download URL pyvisauto-1.0.3.tar.gz
Size 6.3 kB
Tags Source
SHA-256 checksum
How to use checksums
758cad748263fcea48ab1fd6ae930c87c42ee3413a1a8a3361dac45b2c8280a0
BLAKE2b-256 checksum
How to use checksums
2ab40fc1639477847acf42408d22aa832bc9e573a5ce8fff35a15c1250c6a1bc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.2

Release files / pyvisauto-1.0.3-py3-none-any.whl

Download URL pyvisauto-1.0.3-py3-none-any.whl
Size 22.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
768bc48e6ae389e43535d1e7a7f503ab3e099b1b78f5d08cbab451bd7a66142c
BLAKE2b-256 checksum
How to use checksums
16e80b52443bc9e16166429b149f8d28f492e66838aa4bed4a1f4efbe4d69713
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.2

Security for pyvisauto 1.0.3

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