Synthesize pointer, touch, and gesture events on any page.
npx github:TheProfs/pointerdriverNote
LLM Agents must read the pointerdriver skill first.
Ask your LLM to run: pointerdriver --skill and study it carefully.
- Run your project however you want.
We're assuming it's running on
localhost:3000 - Run a pointerdriver server with
npx github:TheProfs/pointerdriver - Go in your browser console and run:
const {
DragMotion, GlideMotion, StrokeMotion,
PinchMotion, TwistMotion, SwipeMotion
} = await import('http://127.0.0.1:5619/pointerdriver.js')This loads pointerdriver and allows executing any of the following motions:
Create a motion by running: new Motion(arguments).perform().
A motion is a human-maneuver;
Regardless of the arguments you use for it, a motion eventually
generates the exact sequence of events that would be generated
from a real device.
Mouse drag across a surface.
| Param | Description |
|---|---|
el |
target element |
points |
[x, y, ms][]; ms monotonic and >= 0 |
await new DragMotion(document.querySelector('#el'), [
[30, 50, 0],
[60, 80, 16],
]).perform()Finger draw on a surface.
| Param | Description |
|---|---|
el |
target element |
points |
[x, y, ms][]; ms monotonic and >= 0 |
await new GlideMotion(document.querySelector('#el'), [
[30, 50, 0],
[60, 80, 16],
]).perform()Pen stylus stroke on a surface.
| Param | Description |
|---|---|
el |
target element |
points |
[x, y, ms][]; ms monotonic and >= 0 |
await new StrokeMotion(document.querySelector('#el'), [
[30, 50, 0],
[60, 80, 16],
]).perform()Two-finger pinch together or apart.
| Param | Default | Description |
|---|---|---|
el |
target element | |
scale |
target scale factor | |
x, y |
gesture center | |
distance |
100 |
initial finger gap in px |
steps |
20 |
interpolation frames |
await new PinchMotion(document.querySelector('#el'), 2, {
x: 60, y: 80
}).perform()Two-finger rotation around a center point.
| Param | Default | Description |
|---|---|---|
el |
target element | |
degrees |
45 |
rotation angle |
x, y |
gesture center | |
radius |
80 |
finger distance from center |
steps |
20 |
interpolation frames |
await new TwistMotion(document.querySelector('#el'), 45, {
x: 60, y: 80
}).perform()Two-finger parallel drag.
| Param | Default | Description |
|---|---|---|
el |
target element | |
distance |
travel distance in px | |
x, y |
gesture center | |
angle |
0 |
direction in degrees |
separation |
40 |
gap between fingers in px |
steps |
20 |
interpolation frames |
await new SwipeMotion(document.querySelector('#el'), 200, {
x: 60, y: 80
}).perform()- The module server only serves
/pointerdriver.jsand/src/*/index.js. - It sets permissive CORS headers so you can import it from any page.
If the target page is HTTPS,
importing pointerdriver from HTTP is blocked as mixed content.
Serve pointerdriver over HTTPS (see bin/skill.md for one approach).
npm test