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

# Sandbox

### Sandbox

#### Methods

### doubleClick()

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
doubleClick(): Promise<CommandResult>
```

Double left click on the current mouse position.

###### Returns

`Promise`\<`CommandResult`>

### getCursorPosition()

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
getCursorPosition(): Promise<object>
```

Get the current mouse position.

###### Returns

`Promise`\<`object`>

An object with `x` and `y` coordinates.

| Name | Type     |
| ---- | -------- |
| `x`  | `number` |
| `y`  | `number` |

### getScreenSize()

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
getScreenSize(): Promise<object>
```

Get the current screen size.

###### Returns

`Promise`\<`object`>

An object with `width` and `height` properties.

| Name     | Type     |
| -------- | -------- |
| `height` | `number` |
| `width`  | `number` |

### getVideoStreamUrl()

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
getVideoStreamUrl(): Promise<string>
```

###### Returns

`Promise`\<`string`>

### hotkey()

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
hotkey(...keys: string[]): Promise<CommandResult>
```

Press a hotkey.

###### Parameters

| Parameter | Type        | Description                                                       |
| --------- | ----------- | ----------------------------------------------------------------- |
| ...`keys` | `string`\[] | The keys to press (e.g. `hotkey("ctrl", "c")` will press Ctrl+C). |

###### Returns

`Promise`\<`CommandResult`>

### leftClick()

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
leftClick(): Promise<CommandResult>
```

Left click on the current mouse position.

###### Returns

`Promise`\<`CommandResult`>

### middleClick()

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
middleClick(): Promise<CommandResult>
```

Middle click on the current mouse position.

###### Returns

`Promise`\<`CommandResult`>

### moveMouse()

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
moveMouse(x: number, y: number): Promise<CommandResult>
```

Move the mouse to the given coordinates.

###### Parameters

| Parameter | Type     | Description       |
| --------- | -------- | ----------------- |
| `x`       | `number` | The x coordinate. |
| `y`       | `number` | The y coordinate. |

###### Returns

`Promise`\<`CommandResult`>

### open()

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
open(fileOrUrl: string): Promise<CommandHandle>
```

Open a file or a URL in the default application.
Note that you'll need to wait for the application to be opened.

###### Parameters

| Parameter   | Type     | Description              |
| ----------- | -------- | ------------------------ |
| `fileOrUrl` | `string` | The file or URL to open. |

###### Returns

`Promise`\<`CommandHandle`>

### press()

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
press(key: string): Promise<CommandResult>
```

Press a key.

###### Parameters

| Parameter | Type     | Description                                                  |
| --------- | -------- | ------------------------------------------------------------ |
| `key`     | `string` | The key to press (e.g. "enter", "space", "backspace", etc.). |

###### Returns

`Promise`\<`CommandResult`>

### rightClick()

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
rightClick(): Promise<CommandResult>
```

Right click on the current mouse position.

###### Returns

`Promise`\<`CommandResult`>

### runPyautoguiCode()

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
runPyautoguiCode(code: string, opts: object): Promise<CommandResult>
```

Run the given Python code that uses pyautogui.

###### Parameters

| Parameter        | Type                         |
| ---------------- | ---------------------------- |
| `code`           | `string`                     |
| `opts`           | `object`                     |
| `opts.onStderr`? | (`data`: `string`) => `void` |
| `opts.onStdout`? | (`data`: `string`) => `void` |

###### Returns

`Promise`\<`CommandResult`>

### scroll()

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
scroll(amount: number): Promise<CommandResult>
```

Scroll the mouse wheel by the given amount.

###### Parameters

| Parameter | Type     | Description           |
| --------- | -------- | --------------------- |
| `amount`  | `number` | The amount to scroll. |

###### Returns

`Promise`\<`CommandResult`>

### takeScreenshot()

###### takeScreenshot()

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
takeScreenshot(): Promise<Uint8Array>
```

Take a screenshot and save it to the given name.

###### Returns

`Promise`\<`Uint8Array`>

A Uint8Array bytes representation of the screenshot.

###### takeScreenshot(format)

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
takeScreenshot(format: "bytes"): Promise<Uint8Array>
```

Take a screenshot and save it to the given name.

###### Parameters

| Parameter | Type      | Description                   |
| --------- | --------- | ----------------------------- |
| `format`  | `"bytes"` | The format of the screenshot. |

###### Returns

`Promise`\<`Uint8Array`>

A Uint8Array bytes representation of the screenshot.

###### takeScreenshot(format)

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
takeScreenshot(format: "blob"): Promise<Blob>
```

Take a screenshot and save it to the given name.

###### Parameters

| Parameter | Type     |
| --------- | -------- |
| `format`  | `"blob"` |

###### Returns

`Promise`\<`Blob`>

A Blob representation of the screenshot.

###### takeScreenshot(format)

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
takeScreenshot(format: "stream"): Promise<ReadableStream<Uint8Array>>
```

Take a screenshot and save it to the given name.

###### Parameters

| Parameter | Type       |
| --------- | ---------- |
| `format`  | `"stream"` |

###### Returns

`Promise`\<`ReadableStream`\<`Uint8Array`>>

A ReadableStream of bytes representation of the screenshot.

### write()

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
write(text: string): Promise<CommandResult>
```

Write the given text at the current cursor position.

###### Parameters

| Parameter | Type     | Description        |
| --------- | -------- | ------------------ |
| `text`    | `string` | The text to write. |

###### Returns

`Promise`\<`CommandResult`>

### create()

###### create(this, opts)

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
static create<S>(this: S, opts?: SandboxOpts): Promise<InstanceType<S>>
```

Create a new sandbox from the default `desktop` sandbox template.

###### Type Parameters

| Type Parameter                   |
| -------------------------------- |
| `S` *extends* *typeof* `Sandbox` |

###### Parameters

| Parameter | Type          | Description         |
| --------- | ------------- | ------------------- |
| `this`    | `S`           | -                   |
| `opts`?   | `SandboxOpts` | connection options. |

###### Returns

`Promise`\<`InstanceType`\<`S`>>

sandbox instance for the new sandbox.

###### Example

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
const sandbox = await Sandbox.create()
```

###### Constructs

Sandbox

###### create(this, template, opts)

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
static create<S>(
   this: S, 
   template: string, 
opts?: SandboxOpts): Promise<InstanceType<S>>
```

Create a new sandbox from the specified sandbox template.

###### Type Parameters

| Type Parameter                   |
| -------------------------------- |
| `S` *extends* *typeof* `Sandbox` |

###### Parameters

| Parameter  | Type          | Description                  |
| ---------- | ------------- | ---------------------------- |
| `this`     | `S`           | -                            |
| `template` | `string`      | sandbox template name or ID. |
| `opts`?    | `SandboxOpts` | connection options.          |

###### Returns

`Promise`\<`InstanceType`\<`S`>>

sandbox instance for the new sandbox.

###### Example

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
const sandbox = await Sandbox.create('<template-name-or-id>')
```

###### Constructs

Sandbox

## Interfaces

### SandboxOpts

#### Properties

### onVideoStreamStart()?

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
optional onVideoStreamStart: (url: string) => void;
```

###### Parameters

| Parameter | Type     |
| --------- | -------- |
| `url`     | `string` |

###### Returns

`void`

### videoStream?

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
optional videoStream: boolean;
```
