How to drag automatically by KM?

question

Hello,

I'd like KM to select all files and drag into the program (Tagstripper) shown as image.

Could you help me?

Your comments would by much appreciated.

How would KM know which files to select? Are they all in the same Finder Folder? Are they all in some other app window being shown?

Also, is the TagStripper a macOS app? If so, it may be easier to just select the files in a Finder Folder, and then open in the TagStripper app. You could test by right-clicking on one file in the Finder, and select "Open in..." then choose "TagStripper".

JMichaelTX, Thanks a lot!
I resolved via
Cmd+A> Open find selection in Tag Stripper.
I didn't need drag & drop.

1 Like

Not working. I want to drag the Image and drop to the web interface selected area. I have the area coordinates. by apple script it is selecting the lates image but not dragging into the web interface

Rather than use AppleScript, try KM's "Move and Click and Drag" action. Fill in the click and the release coordinates as appropriate:

image

What I am doing is using TriggerValue it captures the latest image and it is working absolutely fine. After that I open the url then use the apple script to find the latest image and it also working correctly then I use the Move and click and drag action and use its drag to and I defined the coordinates of web interface image upload area, but still not working. This is my sequence after the apple script.

What does the AppleScript actually do? Because you aren't feeding any variables into your click-and-drag actions. Is the thing you want to drag always 481px to the right and 72px above the centre of the Chrome widow? Check that your release point is correct, and try adding a pause before the release to give Chrome a chance to register the file's arrival on the drop target.

When I add any image to my folder it monitors it and start the macro. I use the action set variable to text action in which clicking on insert tokens and select %TriggerValue% this TV is picking my latest image local path and it is picking correctly now I use this TriggerValue in my applescript to select the latest inage by its creation date. and this 481 and 72 is a starting positions that I capture from the folder where my images are. I am just trying to make this dragging happen…



This is what I am doing. This 1603 and 287 are my coordinates where I images are. I don't know is this correct to capture the coordinates because when the new image came I set it as list then it captures the new image coordinates by assuming.

these 532 and 139 are my coordinates of my web interface uploads area.

Please tell if I am doing wrong.

Since we don't have your macro, your local web page, or your watched folder it is impossible to reproduce your problem or to give more than general advice.

Start by breaking things down into manageable chunks so you can find out what the actual problem is. First make sure that drag'n'drop is working by:

  1. Hard-coding the click point to refer to a particular file
  2. Hard-coding the drop point to the "drop zone" in your browser window
  3. Running the macro and seeing if it works

So for me with a Finder window to the right and a Dropbox folder open in Chrome to left, and with Chrome the active app -- this works every time:

Notice that there's no need to activate the Finder (as long as the source item is visible), to pause, or to release the mouse button at the end.

If that works for you (with your numbers, obviously!) then you know the problem is either with the source item's or the destination's coordinates. I suspect the former -- it looks like you are using AppleScript to reveal and select the item you want to drag, but I can't see you either passing the coordinates of that item back to KM.

What might also help your troubleshooting is to add a "Set action delay" action before the drag'n'drop -- it won't slow the drag itself, but will add a pause between the pointer moving and the file being selected and another between the cursor arriving at the drop point and the drop itself:

image

Maybe also check the web page you're using -- "droppable" uploads often have the option to click and use a standard "Open" dialog to locate the item instead. That dialog is a lot easier to manipulate with KM than a drag'n'drop!

dragdrop.kmmacros (10.2 KB)
I guess it is impossible to drag the latest image automatically.

here is my macro, please check it. what I am doing

I can't run your macro, but this looks wrong:

image

That would only find filenames that contain those exact characters, in that order. (At least, that's my understanding of Contains.)

Instead, you could either write a little regular expression to use with Matches, or do this:

Notice the condition is checking any not all.

-rob.

Thanks!. I will correct it but if you will look at it at my main issue then it would be more appreciable.

I'm not sure what your main issue is? In the macro you sent, this line is also blank, so nothing will happen:

I think you want that pointing to the folder you're watching?

-rob.

Did you do the test I suggested, using hard-coded coordinates for both the start and end of the drag'n'drop? That'll prove whether drag'n'drop will even work for your web app (which isn't a given!).

For your macro itself, at no point are you telling KM the "latest file" coordinates -- is it always at the same position in the window you open (eg do you always sort that window with "latest at top")?

You can delete the "For Each" action and its contents -- it doesn't do anything as written, and isn't required. Just check the ending of %TriggerValue% and exit the macro if it isn't one of your required extensions.

Try replacing the AppleScript with a KM "Reveal a File" action, using %TriggerValue% as the parameter -- you may have add an "Activate window" action to bring your watched folder to the front.

And you'll probably need a pause after you've dropped, and before your final "Move File" action, to stop KM from moving a file that is still being transferred -- it might not break, but why take the risk?

No my main issue is when the new image came to that folder which i add in trigger, I want to select the latest image and drag the image and drop it to the web interface drag/drop are.

I am already doing the hardcode but as I said earlier when the new image came then coordinates will be different. For each is checking if the image come to the folder or not if the image come then the macro will start and trigger value picks the latest image path and it is doing perfectly.

ok for applescript I will try the step you suggested.

and when the image is uploaded then it move to the another folder and it is also doing it correctly.

Yes -- but you haven't told us what isn't working yet. We can't guess, so we have to take it step by step. If the hard-coded drag'n'drop is working then it will probably be either the start or end coordinates that are the problem.

If your watched folder is set to list view and to sort by "newest file at the top" then the new file's coordinates will always be the same, assuming you take them relative to the window's corner. But it will be very difficult (if not impossible) to reliably get the "position" of an item's icon in a Finder window in other ways.

The "For Each" is a pointless construct here -- there is only one thing, so why treat it as a collection to work through? And it doesn't do anything in your macro anyway because you aren't passing it a collection to work through.

This drag and drop isn't working. Yes the start coordinates are causing the issue. when new Image came the coordinates mismatched. I set the files as list view and sort by date modified but the when new image came the coordinates mismatched also there is no sorting option of "newest file at the top"