# pointer_drag

Press, drag along a path of image pixels (or between two elements) and release. The button is released even when the call fails or the link drops.

**In short:** Risk class [`control`](https://docs.cmdop.ai/reference/tools.md#risk-classes). Over MCP call `pointer_drag`; over HTTP send `"tool": "pointer_drag"` to [`POST /api/v1/call`](https://docs.cmdop.ai/reference/http/post-call.md).

## Arguments

Over MCP every tool also takes `machine`: the machine's name or id, optional when only one machine is online.

| Name | Type | Required | Meaning |
| --- | --- | --- | --- |
| `button` | `"left" | "right" | "middle"` | no |  Default: `"left"`. |
| `display` | `integer` | no |  |
| `duration_ms` | `integer` | no | Total time of the drag (default 400, at most 10000). |
| `from_element` | `string` | no | Or two elements: from and to. |
| `modifiers` | `"shift" | "ctrl" | "alt" | "meta"[]` | no |  Default: `[]`. |
| `observe` | `"none" | "ui" | "image"` | no |  Default: `"none"`. |
| `path` | `object[]` | no | Points to follow, in image pixels, at least two. The button goes down at the first and up at the last. Default: `[]`. |
| `to_element` | `string` | no |  |

## Result

| Name | Type | Required | Meaning |
| --- | --- | --- | --- |
| `audit_id` | `string` | yes | Id of the audit line on the machine. |
| `dispatched` | `boolean` | yes |  |
| `foreground_changed` | `boolean` | yes | The frontmost app or window changed because of the action. |
| `observation` | `object` | no |  |
| `settled_ms` | `integer` | yes | How long the screen took to go quiet after the action, in milliseconds. |

## Examples

**MCP**

```json
{
  "name": "pointer_drag",
  "arguments": {
    "machine": "<machine>"
  }
}
```

**HTTP**

```bash
curl -sS -X POST "https://<contour>.cmdop.ai/api/v1/call" \
  -H "Authorization: Bearer $CMDOP_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"machine":"<machine>","tool":"pointer_drag","args":{}}'
```

## Limits

The call times out after 30 s (`timed_out`). Available since version 0.0.2. A refused or failed call returns one of the [error codes](https://docs.cmdop.ai/reference/errors.md).
