Is There a Difference Behind the Scenes Between Type and Paste?

I may have answered my question below, but I decided to ask it anyway, because I might be wrong.

Is there a functional difference between this action:

image

and this one:

image

I can see a few potential differences.

  • The TYPE action allows for special keys like function keys, while the INSERT action does not (or does it? Is there a way with tokens, like %Tab%?)
  • The TYPE action supports a "press and hold" option but the INSERT action does not.
  • The INSERT action supports multiple characters, tokens and variables, while TYPE does not.
  • The TYPE action supports sending data to a named application, while INSERT does not.
  • When inserting special characters like tabs via INSERT, the application is less likely (not sure if this is guaranteed) to interpret the character as a functional command, like moving to the next field in a spreadsheet.

But apart from these potential differences, is there a functional difference between the above two statements? Hmm, now that I ask, I think the answer is yes. The INSERT action achieves its goal by sending a CMD-V to the app (and modifies the clipboard), while the TYPE action actually sends the character to the app without modifying the clipboard.

But I think it's odd that the TYPE action has a feature that lets you direct which application to send its data to, while the INSERT action does not. That seems a little inconsistent to me. So let me say that I'm requesting a new feature, which is to allow the INSERT action to insert text into an application of choice, which would make it a little more consistent with the TYPE action.

It was a good exercise writing this post, thinking about these two actions and how they differ.

I realize under 10% of my feature requests make it into KM, but this request has a certain consistency t its logic so maybe it has a 20% chance.

I think you've answered your question. Just a couple of points:

I would never assume, or even expect, really, that pasting a Tab character would cause the application to move to the next field. Pasting is for, well, pasting, not navigation. I mean, if it works, cool, but I wouldn't expect it to.

AFAIK, the Paste action doesn't use CMD-V, because that's not supported in all apps. It actually generates a system Paste command, which is what CMD-V is supposed to trigger, but as I said, it's not necessarily supported in all apps. I could be wrong, but at least it's logical, even if it's wrong. :stuck_out_tongue:

I think of these two actions like this: If I'm entering text, I would use Paste. (Or pasting an image, of course). If I'm typing commands, like tabbing to the next field, or pressing a function key, or something like that, then I use Type a Keystroke.

There are exceptions, of course, as there are with anything.

Regarding "Type a Keystroke" being able to go to a specific application, whereas "Paste" can't, I suspect this is just how OS/X works. There probably just isn't an option to tell the system to paste to a specific application.

Hope this helps.

I do respect you greatly, because of your polite and generous ways of dealing with people and your enormous knowledge, but I think you're incorrect about one or two things here:

https://wiki.keyboardmaestro.com/action/Insert_Text_by_Pasting

That page says "The Insert (Styled) Text by Pasting action sets the clipboard to the (optionally styled) text and then types a Command-V keystroke."

while you said:

In fact you can see the text in the paste buffer after using the Paste action. Isn't that pretty definitive?

Secondly, you said the paste action can't "go to a specific application" but if the wiki is right, that the paste action "types a CMD-V keystroke", then it could choose an application to send it to. So I feel it was a design choice to not include an app selection option in the Insert Text by Pasting action. But I don't know what the rational was for the inconsistency.

Huh. Well, at least I worded my comment to not sound like a know-it-all. :stuck_out_tongue:I actually re-worded it intentionally because at first it sounded too much like I didn't think I could be wrong!

In fact you can see the text in the paste buffer after using the Paste action. Isn't that pretty definitive?

No, it just proves that the text was, in fact, pasted. It doesn't prove how it was pasted.

I'm holding out on the Wiki being wrong, rather than me. :joy:But if the Wiki is correct, then "you learn something every day". :stuck_out_tongue:

And by the way, thanks for the kind wording - I really appreciate it. In the future you can just disagree with me without sugar-coating it, but again, it's nice you worded it the way you did this time, so I know where you're coming from. I'm wrong a lot. I can live with it. :smirk:

"Kind wording" not only makes you feel good, it makes me feel good. So I'll probably continue the practice.

Hopefully you will feel the same way about the other thread in which I disagreed with you today. :slight_smile:

Yeah, but I think I'm right in that one. :stuck_out_tongue:

Jumping in to add no value whatsoever, just by reason alone I would suspect that Dave is correct. The "Paste" action should paste, as the keyboard shortcut could be replaced/remapped.
If the action can trigger paste on a system layer below the KB interface that would be more effective.

Your comments are most welcome and I respect your opinions.

While I've got the wiki words largely on my side, that's not absolute proof that I'm right. But usually when I suggest that the wiki is wrong it tends to be me that's wrong.

I guess if it matters we could wait for the Final Word from The Architect. I haven't seen him posting for a while so he might be taking a well earned break from the KM9 release.

@peternlewis Settle something for us, will you? Do the Paste actions ("Paste", "Insert Text by Pasting", etc) use ⌘V to do the paste, or do they use some other method? I figured you called some sort of "Paste" API function, but the Wiki says you use ⌘V.

I realize in the long run it doesn't really matter. But I'm curious. :smile:Thanks.

The paste action (in all its variants) works by typing a ⌘V. The copy action (in all its variants) works by typing a ⌘C.

Therefore they will not work proper yin any app for which ⌘C or ⌘V does not behave as expected, which is almost unheard of on the Mac.

There is no “Paste” API function.

1 Like

Thanks. For a person who's wrong frequently, it's nice to be right. And to save you the time of reading my original post, I will say it ended with the suggestion "to allow the INSERT action to insert text into an application of choice, which would make it a little more consistent with the TYPE action." Now that we know it works by sending a CMD-V, the idea is possible.

Not really - background applications frequently wont read clipboard changes until they are brought to the front. The whole thing with operating on background applications is fragile to say the least - it may occasionally allow some impressive things, but most times it simply will not work.

Wow. I didn't know that. I guess in that case this action would also be unreliable if it was sending the character to a background application:

image

P.S. Small bug in that action: it often doesn't display the application in the title bar of that action until you hide/show the action.

Anything sent to a background application is likely to be suspect - it if works, excellent. If not, bring the application to the front.

Looks like it happens only when changing back to “front application”. Resolved for the next version.

Dan you are a good dude!

1 Like

BACK to the original question ...

I have found a profound difference between typing and pasting text in a specific instance that I am using.

I am working with finding text and images on specific Chrome pages. I use the "Type a Keystroke" action to send a Cmd+F that will open the Chrome Search tool. That part is pretty straightforward.

When I use the "Insert Text by Typing" action to put text into that search field, I can watch Chrome first highlighting every single instance on the page of the first letter of that text. In my case, one of the search strings starts with "a" and I can see Chrome highlight every "a" on the page. Whew!

Where that is particularly problematic is when three or four characters specify a string that is not on that view, then Chrome may jump to another part of the HTML page where it does find that string, and that is not what I want, in fact it has the potential to mess up my sequence.

If I instead use the "Insert Text by Pasting" action to put text into the search field, that preliminary searching does not happen and the search field has the results that I intend without a lot of unnecessary intermediate search results that could mess me up.

I hope this helps.

1 Like

Hey August,

That problem is easily solved in Chrome and other apps that use the standard macOS Find pasteboard.

-Chris


Keyboard Maestro Actions.kmactions (663 B)