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.

-Chris


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.

I was looking for a way to set the dragging of the mouse with a variable, as the area I need to capture varies. Getting the mouse begin and end coordinates is easy, but I cannot find the above action to implement it. Has is been removed? If so, how do I enter mouse coordinates for the destination using variables?

No it hasn't. This is a feature that has often caught out users. Just click in the field and type something - the field will immediately expand and allow you to type your variable name.

Brilliant, works exactly like you said. Thx a bunch

1 Like