Skip to main content
Version: 0.3.0
Last Verified: 2025-01-27
Package: hopx-ai on PyPI

Overview

The Desktop resource provides desktop automation capabilities for sandboxes with GUI support. Use this resource for GUI automation, taking screenshots, controlling mouse/keyboard, managing windows, and accessing VNC.
Desktop features require a desktop-enabled template. Not all templates support desktop operations.

Access

VNC Methods

start_vnc

Start VNC server.
Parameters:
  • display (int, optional): Display number (default: 1)
  • password (str, optional): VNC password
Returns: VNCInfo - VNC server information with url, port, password Example:
Expected Output:

stop_vnc

Stop VNC server.
Expected Output:

get_vnc_status

Get VNC server status.
Expected Output:

get_vnc_url

Get VNC URL (convenience method).
Expected Output:

Mouse Methods

click

Click at position.
Parameters:
  • x (int): X coordinate
  • y (int): Y coordinate
  • button (str, optional): Mouse button ('left', 'right', 'middle') (default: 'left')
  • clicks (int, optional): Number of clicks (default: 1)
Expected Output:

move

Move mouse cursor to position.
Expected Output:

drag

Drag from one position to another.
Expected Output:

scroll

Scroll mouse wheel.
Parameters:
  • amount (int): Scroll amount
  • direction (str, optional): 'up' or 'down' (default: 'down')
Expected Output:

Keyboard Methods

type

Type text.
Parameters:
  • text (str): Text to type
  • delay_ms (int, optional): Delay between keystrokes in milliseconds (default: 10)
Expected Output:

press

Press a key.
Parameters:
  • key (str): Key name (e.g., 'Enter', 'Escape', 'Tab')
Expected Output:

combination

Press key combination.
Parameters:
  • modifiers (List[str]): Modifier keys (e.g., ['Ctrl', 'Alt'])
  • key (str): Key to press
Example:
Expected Output:

Clipboard Methods

set_clipboard

Set clipboard content.
Expected Output:

get_clipboard

Get clipboard content.
Expected Output:

Screenshot Methods

screenshot

Capture full screen screenshot.
Returns: bytes - Screenshot image as PNG bytes Example:
Expected Output:

screenshot_region

Capture screenshot of specific region.
Parameters:
  • x (int): X coordinate of top-left corner
  • y (int): Y coordinate of top-left corner
  • width (int): Region width
  • height (int): Region height
Expected Output:

Window Methods

get_windows

Get list of all windows.
Returns: List[WindowInfo] - List of window information objects Expected Output:

focus_window

Focus (activate) window.
Expected Output:

close_window

Close window.
Expected Output:

Examples

Example 1: Taking Screenshots

Expected Output:

Example 2: Mouse and Keyboard Automation

Expected Output:

  • Sandbox - Main sandbox class
  • Models - Data models including VNCInfo, WindowInfo

See Also

Next Steps