# Desktop Sandbox

Desktop Sandbox provides a Linux desktop environment with a graphical user interface (GUI). You can control the mouse and keyboard through the SDK, and even stream desktop screens through VNC. This is very useful for Agents that need GUI automation, browser operations, or visual tasks.

## Import

Desktop Sandbox is located in the `ucloud_sandbox.desktop` module.

```python
from ucloud_sandbox.desktop import Sandbox
```

## Quick Start

```python
from ucloud_sandbox.desktop import Sandbox

# Create a Desktop Sandbox instance
# Default resolution is 1024x768
desktop = Sandbox.create()

# Take screenshot
screenshot_bytes = desktop.screenshot()
with open("screenshot.png", "wb") as f:
    f.write(screenshot_bytes)

# Control mouse
desktop.left_click(100, 200)  # Left click at (100, 200)
desktop.write("Hello Desktop!") # Input text

# Start VNC stream (for real-time viewing)
desktop.stream.start()
print(f"VNC URL: {desktop.stream.get_url()}")

desktop.kill()
```

## Main Features

- **Mouse Control**: `move_mouse`, `left_click`, `right_click`, `double_click`, `drag`, `scroll`.
- **Keyboard Control**: `press`, `write`.
- **Screenshot**: `screenshot` supports returning bytes or streams.
- **VNC Stream**: Built-in `stream` object (`_VNCServer`) can start noVNC proxy for convenient browser viewing.
- **Window Management**: Get current window ID, title, etc. (depends on `xdotool`).

## Notes

- Desktop Sandbox startup may be slightly slower than standard Sandbox because it needs to start X Server and desktop environment (XFCE4).
