Drag mouse
Presses the mouse button, drags the pointer to another place, and releases it.
Drag the mouse from from to to
Keyboard Maestro: MouseMoveAndClick
Details #
Presses the button at the start point, moves the pointer in a smooth line, and releases it at the end. The whole drag takes a little over a tenth of a second.
The start is from. Without it, the drag starts from where the pointer is now. The end is either to (a position on screen) or by (a distance from the start). One of them is required.
Positions are screen points from the top left.
The output holds the start and end as fromX, fromY, toX and toY.
Parameters #
| Parameter | Type | Required | Values | What it does |
|---|---|---|---|---|
button | one of | left right middle | left (default) or right. | |
by | record | dx dy | Distance { "dx": 300, "dy": 0 } from the start, as an alternative to to. | |
from | record | x y | Start position { "x": 100, "y": 200 }. Defaults to the current pointer. | |
modifiers | list of | cmd ctrl opt shift fn hyper | Keys held during the drag, from cmd, ctrl, opt, shift, fn, hyper. | |
to | record | x y | End position { "x": 400, "y": 200 }. |
Every step also accepts label, onFailure, timeout and dryRunSafe.
Examples #
- Drag by (200, 0)
- Drag from (300, 300) to (700, 300)
Gotchas #
Fixed coordinates break when windows move. To start the drag on an element, use Click with
count0 and a locator to move the pointer there, then dragbya distance.Some apps need a slower drag than this one. If a drag-and-drop does nothing, try it by hand first to be sure the app supports it.
With no
toand noby, the step fails.Switchboard needs the Accessibility permission.