Drag and Drop

In sikuli there’s a function for drag and drop which accepts to images. It makes drag and drop so easy.

Is there such a way in KM as well?

Take a look at this KM Action:
Move or Click Mouse action (KM Wiki)

It has an option to click and drag, then drop.
It should work with anything the mouse pointer is on, including images.

I had tried that and it worked but it's not that intuitive.

Here is how my steps look like:

Is there any easy way to do that? The problem is with the offset. Any easy way to find the offset for the image. For example, if I want to click at certain point of the image.

Which "certain point"? That's what the offset specified.

You can use ImageCoords.left or ImageCoords.right or ImageCoords.MidX, but if you want to specify something other than those edges or middle, then you'll need to specify it somehow. Perhaps:

ImageCoords.left + 30% * ImageCoords.width

For example:
Lets say I want to click to the right side of the Image, but don’t know how much pixel away that is. How can I find out how many pixel I need to add in ImageCoords.

Please look at this video of sikuli:

It shows very easy way to define the offset visually without worrying about what to enter for offset value.

It’s very nice, but no, Keyboard Maestro has nothing like that.

I would simply create one image for each button, centred around the desired button, and click at the center of the image.

I can’t remember ever wanting to click at specific offsets in an image, generally, the image is of a UI control and I just want to click the UI control, anywhere will do.

Otherwise, as I showed, you can use the offset as a percentage, so that would work pretty easily most of the time (in the example shown, multiples of 10% would be enough to uniquely identify the buttons).

But I agree, it’s a nice UI.

Since drag and drop is used a lot these days, it’ll be great to have a separate action to do that.

For example, the drag and drop action can have two images. One for drag and another for drop. It will be very useful I think.

If "for drop" you mean the image to drop the image you dragging on, then this can be achieved easily enough with KM:

Given this as the FrontWindow:

This macro will drag the blue folder onto the red folder:

##Macro Library   Drag Image 1 to Drop on Image 2 [Example]

<a class="attachment" href="/uploads/default/original/2X/8/8ecf64d654bdb57591eb5b82969a5e1464120d79.kmmacros">Drag Image 1 to Drop on Image 2 [Example].kmmacros</a> (36 KB)
**Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.**


<img src="/uploads/default/original/2X/2/2df6a9699be4b95b0159f81fa0eba8090ad0cd53.png" width="478" height="759">
1 Like

Thanks JMichael, for such a comprehensive solution. I appreciate all the efforts you took to make such a nice easy to understand reply.

Since, drag and drop is used a lot these days, it will be nice to have a separate action with drag and drop image. Currently, it can be done via KM but needs some extra action steps to do that.

It will be nice to see separate action for drag and drop in next version of KM.

What would be really nice is to have a drag begin/end bracket trigger.

I have an app where to select text I have to double click and then drag. It would be really nice to detect that and this issue Cmd+C to copy the text and kick off automation.

I don’t know if that is what the original poster meant by DnD support.

I tend to agree with that.

The "Drag/Drop" is currently an option ("while dragging") under the Move or Click Mouse action (KM Wiki). I understand they are related, but from a user's POV it would be easier to find the Action if it was a separate action named "Drag and Drop".

Just my 2¢.

I’d rather not encourage Drag & Drop - Drag & Drop is extremely fragile and very likely not to work reliably, or to fail unexpectedly with the slightest change.

It’s good that Keyboard Maestro can do it, but it really should be a last resort as far as automation is concerned.