Skip to main content

Zelesis Neo API Python Bindings

Project description

Zelepy

PyPI License

Zelepy is a Python wrapper for the Zelesis Neo API, allowing you to communicate with the Zelesis Neo software from Python.

Installation

pip install zelepy

Features

  • Event Listening: Listen for Neo events over UDP (detections, triggerbot, etc.)
  • Command Broadcasting: Send commands to control Zelesis Neo (mouse movement, clicks, detection requests)
  • Configuration Management: Read and write Zelesis Neo configuration files
  • Helper Utilities: Get installation paths, versions, and image compression utilities

Quickstart

Zelesis Client

The Zelesis Client is used to broadcast or listen for events via UDP. It can be initialized via:

from zelepy.events import ZelesisClient
client = ZelesisClient()
client.start()

Remember when you are finished with the client to run

client.stop()

Or, you can simply use the client like a context manager, which will not require you to stpo the client once you are finished with it:

from zelepy.events import ZelesisClient
with ZelesisClient() as client:
    print(f"Client is running: {client.is_running}")

When initializing you can set options:

from zelepy.events import ZelesisClient

client = ZelesisClient(
    receive_port: int = 26512,      # Port to listen for events
    send_port: int = 26513,         # Port to send commands
    target_ip: str = "127.0.0.1",   # IP address of Zelesis Neo
    timeout: float = 2.0            # Command response timeout (seconds)
)

Event Listening

from zelepy.events import ZelesisClient
import time

def on_detection(event):
    print(f"Detection: {event}")

def on_triggerbot(event):
    print(f"Triggerbot: {event}")

def on_any_event(event):
    print(f"Recieved an event: {event}")

with ZelesisClient() as client:
    # You can subscribe to specific events
    client.subscribe("detection", on_detection)
    client.subscribe("triggerbot", on_triggerbot)

    # Or you can create a generic listener that will be called whenever ANY event is received
    client.add_event_listener(on_any_event)

    while True:
        time.sleep(0.01)

Event Broadcasting

Mouse Functions

from zelepy.events import ZelesisClient

with ZelesisClient() as client:
    # No need to run client.start() here as its being used as a context manager
    # Move mouse by x, y pixels. Note that this is relative to its current position, rather than moving to an absolute position on screen
    client.move_mouse(100, 50)
    # Left click the mouse
    client.click_mouse()

Requesting Detections

There are 2 ways to get Zelesis to run detections for you. You can either provide an image path:

from zelepy.events import ZelesisClient

with ZelesisClient() as client:
    result = client.request_detection("image.png")

or you can provide the raw image bytes:

from zelepy.events import ZelesisClient

with open("your_image.jpg", "rb") as f:
    image_bytes = f.read()

with ZelesisClient() as client:
    request_detection_raw(image_bytes)

Please NOTE that since events are sent around over UDP, the maximum file size, or image bytes size for both methods is approximately 40-50kb. There is a helpful function in zelepy.helpers to help minimise your image size to fit the constraints:

import zelepy.helpers as helpers

compressed_bytes, info = helpers.compress_image_to_target_size("image.png", target_kb=50)
print(f"Compressed from {info.original_size_kb:.1f}KB to {info.final_size_kb:.1f}KB")
print(f"Success: {info.success}, Quality: {info.quality}")

Note that compress_image_to_target_size returns the compressed bytes, and a CompressionInfo object.

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

zelepy-0.0.5.tar.gz (13.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

zelepy-0.0.5-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

File details

Details for the file zelepy-0.0.5.tar.gz.

File metadata

  • Download URL: zelepy-0.0.5.tar.gz
  • Upload date:
  • Size: 13.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.6

File hashes

Hashes for zelepy-0.0.5.tar.gz
Algorithm Hash digest
SHA256 0376ff21b9621b49c091df272413eecd467618cc005bf1904eb21f21088297f9
MD5 88104265802153d08862d4edbcdc40d6
BLAKE2b-256 00ec395826112b39864f2b8b60d40206bdfca8ccf8bdf38da9a2c96026a96862

See more details on using hashes here.

File details

Details for the file zelepy-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: zelepy-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 13.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.6

File hashes

Hashes for zelepy-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 4e414143d26d6c2970c57459a5cb0cb8bcbda8e251bdc5021ff438eac69315e1
MD5 4587bf29fb6ea25979562ebc9f04c8de
BLAKE2b-256 679faf5afdccd04492cc231421a40089ab2edd56724b4ed9566692fc019ca25f

See more details on using hashes here.

Supported by

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