# Desktop

Every computer has a desktop with windows, a mouse and a keyboard. You reach it through `display()`: screenshots show the screen, input acts on it, and a link lets a person watch it live.

## See the screen

`screenshot(options)` captures one of these targets:

| Target         | What it captures                       |
| -------------- | -------------------------------------- |
| `Desktop`      | The whole screen.                      |
| `ActiveWindow` | The window in front.                   |
| `Window`       | One window, by its id.                 |
| `Region`       | A rectangle, by its position and size. |

It returns the image as PNG, JPEG or WebP, or writes it to a path on the computer's disk.

## Use the mouse and keyboard

`input(request)` runs a list of steps in order:

| Step      | What it does                                              |
| --------- | --------------------------------------------------------- |
| `Move`    | Moves the pointer to a point, at once or over time.       |
| `Click`   | Clicks a button once or more, here or at a point.         |
| `Press`   | Holds a button down.                                      |
| `Release` | Lets a held button go.                                    |
| `Drag`    | Drags from one point to another.                          |
| `Scroll`  | Scrolls by an amount, here or at a point.                 |
| `Type`    | Types text, all at once or in chunks with a delay.        |
| `Key`     | Presses a chord of keys in order, such as `Ctrl+Shift+T`. |
| `Wait`    | Waits a number of milliseconds.                           |

Any step can take a screenshot when it is done, so one request shows the result of every action. A request has a limit on its steps, its waits and its length.

## Windows

`windows()` lists the open windows, returns one by its id and brings one to the front. A screenshot or a recording can capture a single window.

## Share a live view

`stream_url` returns a link to the desktop that expires after the time you give it. Open it in any browser:

```rust
let stream = client
    .computer(id)
    .display()
    .stream_url(Duration::from_secs(3600), StreamMode::Interactive)
    .await?;

println!("{}", stream.viewer_url);
```

| Mode          | What the viewer can do                                   |
| ------------- | -------------------------------------------------------- |
| `ViewOnly`    | Watches the desktop as it changes.                       |
| `Interactive` | Watches, and can take control of the mouse and keyboard. |

## Record

`recordings().start(options)` records the desktop, a window or a region to a video on the computer's disk, in H.264, H.265, VP9 or AV1. Stop it with `stop`, or end it after a duration you set. A recording is `Recording`, then `Rendering`, then `Complete`, unless it fails or you cancel it. Read and delete the video through `fs()`, like any other file.

Screenshots and recordings share a render setting for the canvas, content and cursor they show.

## Limits

The desktop is always on, so there is nothing to start or stop. It has no audio.

## Next steps

* [Commands](/computer/concepts/commands): shell commands on the same computer
* [Run an agent](/computer/guides/run-an-agent): a full task from start to finish
