Skip to content

Commit 2acc8ea

Browse files
docs: replace Python demo with CLI one-liner for smooth movement
Swap the Python smooth_demo.py script in the Tip with a pure bash snippet using the kernel CLI. Users can copy-paste and run immediately without creating any files. Made-with: Cursor
1 parent 6c94c1c commit 2acc8ea

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

browsers/computer-controls.mdx

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,25 @@ description: "Control the computer's mouse, keyboard, and screen"
66
Use OS-level controls to move and click the mouse, type and press keys, scroll, drag, and capture screenshots from a running browser session.
77

88
<Tip>
9-
Smooth movement is enabled by default — every `moveMouse` and `dragMouse` call already uses [Bézier curves](https://en.wikipedia.org/wiki/B%C3%A9zier_curve). Run this script and open the [live view](/browsers/live-view) link to watch it in action:
10-
11-
```python smooth_demo.py
12-
from kernel import Kernel
13-
import time, urllib.request
14-
15-
k = Kernel()
16-
b = k.browsers.create()
17-
print(f"\n Watch live: {b.live_view_url}\n")
18-
19-
html = urllib.request.urlopen(
20-
"https://gist.githubusercontent.com/ulziibay-kernel/f6d8063ba223a81293cfe1fde06d8624/raw/cursor-trail-demo.html"
21-
).read().decode()
22-
k.browsers.playwright.execute(id=b.session_id, code="await page.setContent(" + repr(html) + ");")
23-
input("Press Enter when live view is open...")
24-
25-
for x, y in [(200, 200), (900, 150), (1700, 250), (1700, 700), (960, 800), (200, 750), (500, 480), (1400, 480)]:
26-
k.browsers.computer.move_mouse(id=b.session_id, x=x, y=y, duration_ms=1200)
27-
time.sleep(0.3)
9+
Smooth movement is enabled by default — every `moveMouse` and `dragMouse` call already uses [Bézier curves](https://en.wikipedia.org/wiki/B%C3%A9zier_curve). Open [live view](/browsers/live-view) and paste this to see the difference:
10+
11+
```bash
12+
kernel upgrade # requires CLI v0.15.4+
13+
ID=$(kernel browsers create --json | jq -r '.session_id')
14+
echo "Open live view: https://dashboard.onkernel.com/browsers/$ID"
15+
sleep 3
16+
17+
echo "=== Smooth (Bezier curves) ==="
18+
for coords in "200 200" "900 150" "1700 250" "1700 700" "960 800" "200 750"; do
19+
kernel browsers computer move-mouse $ID --x ${coords% *} --y ${coords#* } --duration-ms 1200
20+
sleep 0.3
21+
done
22+
23+
echo "=== Instant (teleport) ==="
24+
for coords in "200 200" "900 150" "1700 250" "1700 700" "960 800" "200 750"; do
25+
kernel browsers computer move-mouse $ID --x ${coords% *} --y ${coords#* } --smooth=false
26+
sleep 0.5
27+
done
2828
```
2929
</Tip>
3030

0 commit comments

Comments
 (0)