"Move one click and drag" option for duration

https://forum.keyboardmaestro.com/uploads/default/original/3X/b/9/b9dd3096a28c0619b6808094a509f3279d843fdd.jpeg

Nige_S helped with this macro. Works well enough for my current use case, but would be easier and better if duration for a "Move and Click and Drag" could be set. As it is now, the drag is "instantaneous." I wanted it to be faster but each repeat took a certain amount of time, but I wanted the time resolution.

One use case: QuickTime Screen Recording with smooth click and drag. Basically trying to drag a scrubber bar at a certain rate or in a set time while recording a (screenshot) video. (In response to an answer.)

But I can see adding more options to this action is fraught with difficulties.

It's hard to know what the solution is when I'm not sure what the purpose is, but how about this?

Drag by Timed Increments.kmmacros (26 KB)

Macro screenshot


Initial Setup:

  • Enter the desired drag distance (in pixels) into the first green action. (See TIPS, below.)
  • Enter the desired duration (in seconds) into the second green action.

Fine-Tuning Options:

  • Adjust the number of pixels each step will move by in the first blue action. The smaller the number, the smoother the movement. The smallest possible number is 1 pixel.
  • Adjust the step pause length (in seconds) in the second blue action. The smaller the number, the smoother the movement. The smallest possible number is 0.01 seconds.

In use:

With your mouse at the start position, trigger this macro. The number of steps required to cover the desired distance will be automatically calculated and the click and drag will begin. At the end of the drag, the mouse button will be released.


TIPS:


1. Working out the desired distance in pixels:

  • One way to acquire the desired drag distance in pixels is to use the screenshot tool. Click and drag from the start point to the end point and make a mental note of the X/Y-axis pixel numbers beside the crosshair. Hit escape to cancel actually taking a screenshot.

  • Another way to get relative coordinates (i.e. the distance between two points in two dimensions) is to use a macro like this:

KM - Get Coordinates (Between Two Clicks).kmmacros (39 KB)

Macro screenshot

Usage: Trigger the macro, then click at the start and end points. The relative coordinates will appear as text in a window.


2. Changing drag direction:

  • If you wish to perform a vertical drag, simply swap these two values:
Screenshot

2 Likes

This is great. I guess move is faster than click and drag. And the solution is more general. And instructions!

1 Like

Oh wow, thank you! A year later, I was having trouble getting "drag" to work on a program, but this works!