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 coordinatesclick_mouse(x, y, button="left", press=False, release=False): Click mouse at specified positionpress_mouse(x, y, button="left"): Press mouse button at specified positionrelease_mouse(x, y, button="left"): Release mouse button at specified positiondrag_mouse(source_x, source_y, target_x, target_y): Drag from source position to target positionscroll(x, y, scroll_direction="up", scroll_amount=1): Scroll mouse wheel at specified position
Keyboard Operations
press_key(key): Press specified keytype_text(text): Type specified text
Screen Operations
take_screenshot(): Take a screenshotget_cursor_position(): Get current cursor positionget_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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tool_server_client-1.0.0rc12.tar.gz.
File metadata
- Download URL: tool_server_client-1.0.0rc12.tar.gz
- Upload date:
- Size: 125.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
98844b26145f402d78c26da854fab773e1161ad10ab56fa9e10dbff211708dc8
|
|
| MD5 |
73b220e2e21c7b8376095930ae6045a9
|
|
| BLAKE2b-256 |
d5d6cae8981753a76713a33aea602c721906b29b3f5e7fa4cbe4a98c37a7c624
|
File details
Details for the file tool_server_client-1.0.0rc12-py3-none-any.whl.
File metadata
- Download URL: tool_server_client-1.0.0rc12-py3-none-any.whl
- Upload date:
- Size: 9.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0d4878baa3f84d78a8cbde24c3dd863e70d630ef646b1e5a67d65ecfbebe2a4b
|
|
| MD5 |
033b6e771d4b1e240cf987c5bf4feb98
|
|
| BLAKE2b-256 |
3a43a81bab1012600924bf5a35a8eee3226f1061ef2d032d8f1cbbe896e58887
|