Skip to main content

This is the Python SDK for Computer Use Tool Server, allowing you to easily control the computer desktop environment from your applications.

Project description

Tool Server SDK

A Python SDK for Tool Server that allows seamless control of computer desktop environments from your applications.

Installation

# Install using pip
pip install tool-server-client

Usage

Basic Usage

from tool_server_client.client import new_computer_use_client

# Initialize the client
client = new_computer_use_client("http://localhost:8102")

# Get screen size
width, height = client.get_screen_size()
print(f"Screen size: {width}x{height}")

# Move mouse to screen center
client.move_mouse(width // 2, height // 2)

# Click mouse
client.click_mouse(width // 2, height // 2)

# Type text
client.type_text("Hello, World!")

# Press Enter key
client.press_key("enter")

Features

The SDK provides the following operations:

Mouse Operations

  • move_mouse(x, y): Move mouse to specified coordinates
  • click_mouse(x, y, button="left", press=False, release=False): Click mouse at specified position
  • press_mouse(x, y, button="left"): Press mouse button at specified position
  • release_mouse(x, y, button="left"): Release mouse button at specified position
  • drag_mouse(source_x, source_y, target_x, target_y): Drag from source position to target position
  • scroll(x, y, scroll_direction="up", scroll_amount=1): Scroll mouse wheel at specified position

Keyboard Operations

  • press_key(key): Press specified key
  • type_text(text): Type specified text

Screen Operations

  • take_screenshot(): Take a screenshot
  • get_cursor_position(): Get current cursor position
  • get_screen_size(): Get screen size

System Operations

  • wait(duration): Wait for specified duration (milliseconds)
  • change_password(username, new_password): Change user password

Examples

For more usage examples, see examples.py.

Advanced Usage

Custom API Version

from tool_server_client.client import ComputerUseClient

client = ComputerUseClient(base_url="http://your-server.com", api_version="2020-04-01")

Handling Responses

API calls return a dictionary containing operation results that can be checked for success:

response = client.move_mouse(100, 100)
if response.success:
    print("Mouse moved successfully")
else:
    print(f"Error: {response.error}")

Error Handling

The SDK handles HTTP errors and raises exceptions when API calls fail:

try:
    client.move_mouse(100, 100)
except Exception as e:
    print(f"Operation failed: {e}")

Contributing

Contributions are welcome! Please feel free to submit issues or pull requests.

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

tool_server_client-1.0.0rc9.tar.gz (36.6 kB view details)

Uploaded Source

Built Distribution

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

tool_server_client-1.0.0rc9-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file tool_server_client-1.0.0rc9.tar.gz.

File metadata

  • Download URL: tool_server_client-1.0.0rc9.tar.gz
  • Upload date:
  • Size: 36.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.28.1

File hashes

Hashes for tool_server_client-1.0.0rc9.tar.gz
Algorithm Hash digest
SHA256 7af95a446da7a9788ad5278f89b8448352d8340c86b25b2845f581ed66fe9692
MD5 f2277164e91a47725fe55e01625a0fe9
BLAKE2b-256 ef4ed2a8a8f81cfeb44baf4b88214a2cd19bf5ee995a4609610c30aa447a513f

See more details on using hashes here.

File details

Details for the file tool_server_client-1.0.0rc9-py3-none-any.whl.

File metadata

File hashes

Hashes for tool_server_client-1.0.0rc9-py3-none-any.whl
Algorithm Hash digest
SHA256 fad7ecf2c0cb1b1e46d111b16a6e05dd0a60134b09b991ec462645c1b9b0cabe
MD5 153a654e4935c78b0d4d8bf16c015ef2
BLAKE2b-256 b4c5d8eeb0c2882044ffa44cd9d894b0f466e51c8f59a2ec4b7bf30e9d74dca1

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