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

Computer Use SDK

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

Installation

# Install using pip
pip install computer-use-sdk

# Or install from source code
git clone [repository-url]
cd computer-use-tool-server
pip install -e .

Usage

Basic Usage

from sdk.client import ComputerUseClient

# Initialize the client
client = ComputerUseClient(base_url="http://localhost:8000")

# 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 List

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

See examples.py for more usage examples.

Advanced Usage

Custom API Version

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

Handling Responses

Most API calls return a dictionary containing the operation result. You can check these responses to see if the operation was successful:

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

Error Handling

The SDK automatically handles HTTP errors and raises exceptions when API calls fail. You can use try/except blocks to catch these exceptions:

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-0.0.1.tar.gz (15.0 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-0.0.1-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file tool_server_client-0.0.1.tar.gz.

File metadata

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

File hashes

Hashes for tool_server_client-0.0.1.tar.gz
Algorithm Hash digest
SHA256 420b38331b99ebfbf2df69e8732f3be9473feb9c9263db4b3cbd6234bd45def3
MD5 3bf8a98275b218e80eb6ebb9d83b9956
BLAKE2b-256 b4a26ec45095b5e2ecaa9e2e33dd4f2981a0bfa7dc1e0a523f5a4bfe41209f13

See more details on using hashes here.

File details

Details for the file tool_server_client-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for tool_server_client-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f38ac800da7fa4c01ba2ab9861c22b9a82a7b0fb52c780a406ea05955482aacd
MD5 ea52c971562f65eb852f94831215c3cb
BLAKE2b-256 ca9dbf5006038f82dff63b7f4b8a734a5dd3b5a168946f6efee1749bb4b9bfcd

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