"Insert Text by Typing" (Or Pasting) Does Not Seem to Work in KM Fields

I decided to collect some Tokens on a Palette to quickly insert them directly from there when needed. As I tried to use the Action "Insert text by typing" (or pasting) nothing happened. The field stayed blank. The result in my particular example should look like this…

image

As a workaround or better for testing purposes I created a Named Clipboard containing the Token and used Paste from Named Clipboard which worked.

image

Is there a specific reason that I can't use typing text? I fear when I need to use Named Clipboards it gets messy because I already have "quite a few" that I need to use.

A side effect: In this case I worked with Finder selections and my goal was to duplicate a file and rename it in one macro. I recognized that KM behaves differently from the Finder. After duplicating the original file kept selected. IMHO in most cases the newly created file is the one that should be renamed or further processed, i.e. moved to a different location. When using the Finder command CMD&D the new file is selected automatically and the renaming can be done using the same Token. Of course this can also be done using the Finder command which I did.

Anyway, maybe an idea for a small improvement in one of the next updates @peternlewis?

Thanks!

I'm not sure what's going on in your case, but I have multiple macros that type things into KM fields.

Also, and this is just an aside - it's not for solving the "typing" issue - I'm not sure why you'd need to use a named clipboard, but if it's because "Insert Text by Pasting" affects the clipboard, you can just use "Delete past clipboard 0" after the Insert Text by Pasting action.

I don't really understand what is happening with your insertion problems. My guess is there is a problem with your macro.

Use the Reveal a File action to select the duplicated file.

Thanks a lot @DanThomas.

Indeed I couldn't really get the second part of your answer. But the issue seems to be gone by itself. Just right now I tried to reproduce it to recorded a small screencast and now it works like it should.

I can't reproduce what happened yesterday.

Thanks again and have a nice weekend.

Thanks a lot @peternlewis. As already mentioned in the answer to Dan right now I wasn't able to reproduce the issue I had yesterday. I didn't change anything with my macros and as shown in my second screenshot the Action on this Palette had initially just the one command "Insert Text…". Everything else was just added for testing purposes. I probably should have restarted KM or even my Mac.

Indeed I read the Wiki yesterday and was considering to use it. But doesn't this action need to know the name of the duplicated file? Which probably would be possible to get with a bunch of additional actions but I like to keep it simple and am fine with the Apple command and just was wondering.

Thanks again and enjoy your weekend.

I hate when that happens! Have a good weekend.

2 Likes

Hey HaPe,

At least in the image you're showing the field does not appear to be selected.

As for the file duplication and rename issue – it appears to me that you're doing this the hard way...

-Chris


Finder ⇢ Duplicate and Rename the Selected Item v1.00.kmmacros (6.0 KB)
Keyboard Maestro Export

Hello Chris,

thanks a lot for your hint and example.

My screenshot just shows the ready-to-go Macro where I just left the original tried "Duplicate…" Action deactivated. Of course I tried to insert my Token into the blank Field after inserting the referring Action. But that evening it wouldn't work at all whilst yesterday it worked from the first try.

Your example looks great and of course, this is again the Pro-level. It explains to me the way to use "Reveal…" which needs the step ahead I was guessing in my answer to Peter to "know" the path where the file is located. Nevertheless, if I am not missing something my Macro gets the same result. At least it does exactly what I wanted to have in just two Actions except my "typical" Delay action I am mostly using.

Can you explain to me what you find to be "the hard way"?

Thanks and have a good weekend!

It's generally risky to depend upon the Finder to do its thing when it provides no programmatic feedback when it finishes a process.

In your case the order of operation should keep you from having a problem, but it's easy to get into trouble.

Finder duplication appends “copy” – which may be fine with you – but I wouldn't like it.

My macro is direct, bombproof, and should be a little faster than the Finder.

This job can be done easily with a little AppleScript as well.

# Duplicate the selected item in the Finder and rename the dupe.

tell application "Finder"
   set finderSelectionList to selection as alias list
   if length of finderSelectionList = 0 then error "No files were selected in the Finder!"
   set theItem to item 1 of finderSelectionList
   
   set newFile to duplicate theItem
   select newFile
   set name of newFile to "New File Name" & "." & (theItem's name extension)
end tell

-Chris

Hi Chris,

Thanks a lot for your description, now I have a better imagination. Thanks also for the script example. As already mentioned a few times here I like to avoid to start investigating in scripting. My time is very limited and even "just" using KM I am always trying to estimate if the creation, optimization and often pretty time consuming testing phase of a macro for a bunch of steps is worth the time or if it'd better to do it manually.

If I would start to learn scripting I'd fear that this question would appear even more. And I'd have to start from zero with AppleScript which is simply not possible due to the lack of time.

I will change my macro to your version to be bombproof. That sounds great.

Thanks again for your help,

HaPe

1 Like