Drag Mouse based on variables

I am creating a macro where I need the user to select 2 different mouse locations and then have the macro drag the mouse between them.

To capture the starting and ending mouse positions I am simply prompting the user to click the OK button (of the Keyboard Maestro dialog) and move the mouse to position 1 and wait for more instructions. I then have Keyboard Maestro pause 3 seconds so the user can move the mouse. Keyboard Maestro then tells them to click OK and move the mouse to the ending position, again waiting 3 seconds for the user to do so.

With this I capture LEFT and RIGHT variables such as:
LEFT: 444, 516
RIGHT: 1074, 520

I can then “Use Variable ‘LEFT’ to set Mouse Location” to set the starting mouse position.
Where I am stuck is how can I click and drag from the LEFT variable location to the RIGHT variable location?

Hey Stephen,

That's actually fairly straightforward once you know how.

Keep in mind though that click and drag can be a bit finicky.


Click and Drag Mouse from Left Coordinate to Right Coordinate.kmmacros (2.9 KB)

1 Like

Thanks for the help Chris! … and sorry for the delay in getting back.