> ## Documentation Index
> Fetch the complete documentation index at: https://docs.e2b.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Desktop

## Sandbox

```python theme={"theme":"css-variables"}
class Sandbox(SandboxBase)
```

### create

```python theme={"theme":"css-variables"}
@classmethod
def create(cls,
           template: Optional[str] = None,
           resolution: Optional[Tuple[int, int]] = None,
           dpi: Optional[int] = None,
           display: Optional[str] = None,
           timeout: Optional[int] = None,
           metadata: Optional[Dict[str, str]] = None,
           envs: Optional[Dict[str, str]] = None,
           secure: Optional[bool] = None,
           allow_internet_access: Optional[bool] = None,
           network: Optional[SandboxNetworkOpts] = None,
           iam: Optional[SandboxIamOpts] = None,
           lifecycle: Optional[SandboxLifecycle] = None,
           volume_mounts: Optional[Dict[str, Union[Volume, str]]] = None,
           logger: Optional[logging.Logger] = None,
           **opts: Unpack[ApiParams]) -> Self
```

Create a new sandbox.

By default, the sandbox is created from the default `desktop` sandbox template.

**Arguments**:

* `template`: Sandbox template name or ID
* `resolution`: Startup the desktop with custom screen resolution. Defaults to (1024, 768)
* `dpi`: Startup the desktop with custom DPI. Defaults to 96
* `display`: Startup the desktop with custom display. Defaults to ":0"
* `timeout`: Timeout for the sandbox in **seconds**, default to 300 seconds. The maximum time a sandbox can be kept alive is 24 hours (86\_400 seconds) for Pro users and 1 hour (3\_600 seconds) for Hobby users.
* `metadata`: Custom metadata for the sandbox
* `envs`: Custom environment variables for the sandbox
* `secure`: Deprecated — every sandbox secures envd access; accepted for backward compatibility and ignored
* `allow_internet_access`: Allow sandbox to access the internet

**Returns**:

A Sandbox instance for the new sandbox
Use this method instead of using the constructor to create a new sandbox.

### screenshot

```python theme={"theme":"css-variables"}
@overload
def screenshot(format: Literal["stream"]) -> Iterator[bytes]
```

Take a screenshot and return it as a stream of bytes.

### screenshot

```python theme={"theme":"css-variables"}
@overload
def screenshot(format: Literal["bytes"] = "bytes") -> bytearray
```

Take a screenshot and return it as a bytearray.

### screenshot

```python theme={"theme":"css-variables"}
def screenshot(format: Literal["bytes", "stream"] = "bytes")
```

Take a screenshot and return it in the specified format.

**Arguments**:

* `format`: The format of the screenshot. Can be 'bytes', 'blob', or 'stream'.

**Returns**:

The screenshot in the specified format.

### left\_click

```python theme={"theme":"css-variables"}
def left_click(x: Optional[int] = None, y: Optional[int] = None)
```

Left click on the mouse position.

### double\_click

```python theme={"theme":"css-variables"}
def double_click(x: Optional[int] = None, y: Optional[int] = None)
```

Double left click on the mouse position.

### middle\_click

```python theme={"theme":"css-variables"}
def middle_click(x: Optional[int] = None, y: Optional[int] = None)
```

Middle click on the mouse position.

### scroll

```python theme={"theme":"css-variables"}
def scroll(direction: Literal["up", "down"] = "down", amount: int = 1)
```

Scroll the mouse wheel by the given amount.

**Arguments**:

* `direction`: The direction to scroll. Can be "up" or "down".
* `amount`: The amount to scroll.

### move\_mouse

```python theme={"theme":"css-variables"}
def move_mouse(x: int, y: int)
```

Move the mouse to the given coordinates.

**Arguments**:

* `x`: The x coordinate.
* `y`: The y coordinate.

### mouse\_press

```python theme={"theme":"css-variables"}
def mouse_press(button: Literal["left", "right", "middle"] = "left")
```

Press the mouse button.

### mouse\_release

```python theme={"theme":"css-variables"}
def mouse_release(button: Literal["left", "right", "middle"] = "left")
```

Release the mouse button.

### get\_cursor\_position

```python theme={"theme":"css-variables"}
def get_cursor_position() -> tuple[int, int]
```

Get the current cursor position.

**Raises**:

* `RuntimeError`: If the cursor position cannot be determined

**Returns**:

A tuple with the x and y coordinates

### get\_screen\_size

```python theme={"theme":"css-variables"}
def get_screen_size() -> tuple[int, int]
```

Get the current screen size.

**Raises**:

* `RuntimeError`: If the screen size cannot be determined

**Returns**:

A tuple with the width and height

### write

```python theme={"theme":"css-variables"}
def write(text: str, *, chunk_size: int = 25, delay_in_ms: int = 75) -> None
```

Write the given text at the current cursor position.

**Arguments**:

* `text`: The text to write.
* `chunk_size`: The size of each chunk of text to write.
* `delay_in_ms`: The delay between each chunk of text.

### press

```python theme={"theme":"css-variables"}
def press(key: Union[str, list[str]])
```

Press a key.

**Arguments**:

* `key`: The key to press (e.g. "enter", "space", "backspace", etc.).

### drag

```python theme={"theme":"css-variables"}
def drag(fr: tuple[int, int], to: tuple[int, int])
```

Drag the mouse from the given position to the given position.

**Arguments**:

* `from`: The starting position.
* `to`: The ending position.

### wait

```python theme={"theme":"css-variables"}
def wait(ms: int)
```

Wait for the given amount of time.

**Arguments**:

* `ms`: The amount of time to wait in milliseconds.

### open

```python theme={"theme":"css-variables"}
def open(file_or_url: str)
```

Open a file or a URL in the default application.

**Arguments**:

* `file_or_url`: The file or URL to open.

### get\_current\_window\_id

```python theme={"theme":"css-variables"}
def get_current_window_id() -> str
```

Get the current window ID.

### get\_application\_windows

```python theme={"theme":"css-variables"}
def get_application_windows(application: str) -> list[str]
```

Get the window IDs of all windows for the given application.

### get\_window\_title

```python theme={"theme":"css-variables"}
def get_window_title(window_id: str) -> str
```

Get the title of the window with the given ID.

### launch

```python theme={"theme":"css-variables"}
def launch(application: str, uri: Optional[str] = None)
```

Launch an application.

## E2B

```python theme={"theme":"css-variables"}
class E2B()
```

E2B client with an explicitly bound connection configuration.

The resource classes exposed by the client (`Sandbox`, `Volume`,
`AsyncVolume`, `Template`, `AsyncTemplate`, `Secret`, `AsyncSecret`) behave
exactly like the top-level exports of the same name, except the params
passed to the client are used as the defaults instead of the environment
variables.
Per-call params still take precedence over the client's params.

Multiple clients are fully isolated from each other and from the top-level
env-configured exports.

**Example**:

```python theme={"theme":"css-variables"}
from e2b_desktop import E2B

client = E2B(api_key="e2b_...", domain="e2b.dev")

desktop = client.Sandbox.create()
desktop.stream.start()
```

### \_\_init\_\_

```python theme={"theme":"css-variables"}
def __init__(**opts: Unpack[E2BClientParams])
```

Create a new client with the API params bound to it.

**Arguments**:

* `opts`: API params used as the defaults for every call made
  through this client's resource classes.
