How Do I Use KM to Copy and paste?

Hello, new to KM, but bought it two years ago and never really used it, thought it was really complex that I gave up just looking at its settings but I'm trying it again I heard many good things about it hence bought it in the first place.

How does someone copy and paste?

Want:

While typing how do I copy the previous word or two or a paragraph or even an entire email?

Also can this even work on a text website? a word or paragraph under the cursor? Is that even possible.

Thank you

Those two requests are somewhat different as far as copy goes, but the same for paste.

To paste you use the "paste" action in a macro. Add an action and then select all actions and then paste. It will paste whatever is on the macOS (aka system) clipboard. You could alternatively paste a specific (non-system) clipboard, or insert text that you've created/modified with other actions.

Copying the previous word could be done by using Opt+Shift+Left Arrow as a "type a keystroke" action and then the "copy" action. Words or paragraphs could use similar keystroke actions or you could get fancy with regex (among countless other alternative ways of doing it).

Text on a website could be done with the above methods, or with javascript. If you've got a specific example you'd like us to give you suggestions or ready built macros for then fire away.

See the excellent wiki and this forum for other info. E.g. https://wiki.keyboardmaestro.com/Clipboards

Yes, sorry, perhaps my question is more about copying. What I really want and have heard ppl use letters to execute copying actions(triggers) like copying previous word or paragraph. For instance if I type "cp" then this executes copy the previous word or paragraph.

Thank you.

I don't recall seeing anything yet that isn't possible with KM. The question is finding a solution that satisfies your requirement. Some solutions are simple but some are complex. So far your questions lean on the simple side.

All KM actions require a trigger. I presume in your case you want the trigger to be a keystroke (there are other kinds of triggers like timers). Let's say you want the keystroke F1 to select and copy the word under the pointer (you said "cursor" when I believe the correct term for what you meant is "pointer"; the cursor is the flashing vertical text bar, I think.) In that case the solution is quite simple:

Double Click and Copy.kmmacros (2.4 KB)

This does one of the things you asked for, but it may not be exactly what you want. I.e., it selects the text and doesn't unselect it after the copy. That's easy to solve, but most of the time when people ask questions it isn't clear precisely what they want. For example you didn't indicate which application(s) you wanted this to work in. Some application have keystrokes for selecting paragraphs, but since you didn't specify this, we can't get the solution yet.

But this simple macro should give you an idea of how to get going. If you explain more about your requirement someone can probably give you the solution. I guess it's hard to know what to ask for because you don't know what's possible. But I believe that anything is possible with KM.

What you are asking for is possible, even easy, but there's still some ambiguity. For example, what defines a paragraph? A CR? A LF? A blank line? If you can narrow down which application you want this macro to work with, there might be particularly easy solutions in terms of selecting a paragraph. You see some applications support AppleScript and some do not. The solution may depend on this.

Your question is certainly fair and reasonable. We should be able to get a good solution for you.

You are right my question wasn't clear. Well the application could be any that enables typing. Yes, I guess I'm looking for keystrokes for selecting words/paragraphs then copying it.

Well I use DevonThink3 and its many file type but mainly rich text/rtf.

Thank you for your help

Okay in that case we can't use simple solutions because each application has its own shortcuts for selecting paragraphs. Since you want it to work in all apps, even apps that don't have AppleScript support, now that increased the complexity from low to medium. That's okay. We can handle medium.

I think now we have to define what constitutes a paragraph. Is it a carriage return? So do you want all the text since the last CR and prior to the next CR? Or do you want it up to the current cursor location rather than the next CR? Or do you want it up to the mouse location? All these things will mean different solutions.

EDIT: Why is there a big red bar to the left of this post? I don't know what I did to cause that. It's quite pretty. If I was conceited I would add it to all my posts. :wink:

Okay here is a set of actions that seems to do the main thing you are asking for, which is select and copy the last paragraph of text before the cursor. I had to assume what the definition of a paragraph was since that wasn't defined yet.

Paragraph selector.kmmacros (5.3 KB)

I greyed out four actions because at the moment they aren't needed but I thought you were going to need them in the future so I put them there as deactivated actions.

Give it a try. Tell me if it's helpful or not. If not, what is it doing wrong?

Yes first lets start with a word then we move on to a paragraph. I mean a paragraph could be after a period(.) and ends at a period. Sorry I don't even know what's CR lol

I don't see a red bar, my whole Mac echo system is under night light. Dark mode everything even websites I visit, with the help of Darkreader App.

Yes I will start with this and see how things go, will let know know tomorrow if you are still around :slight_smile:

Thank you so much for your help. Sleepy.

I'm very sorry for using a technical term. It means Carriage Return (which I will now refer to as a CR, if you don't mind.) It's the character most applications use to define the end of a paragraph.

I can easily modify the code to stop at a period instead of a CR. However a period is usually used at the end of sentences (and not all sentences; and not exclusively for sentences). If we stopped at the previous period we would be selecting only a single sentence. I thought you originally wanted paragraphs, not sentences. That's why I used the tail command in my macro above, because that selects the text after the last CR.

The red bar seems to have disappeared. Thanks for mentioning it.

It's kind of you to say that. Thanks. Most days I'm around.

Hi @Vandeer, welcome to Keyboard Maestro (KM) and its Forum.
KM is one of the best Mac automation tools available, its Forum is one of the best and friendliest forums on the Internet. Whenever you reach a tough stumbling block trying to use KM, please feel free to post your question/problem here for help.

Since you are new, lets start with the basics.

KM uses Macros to automate your workflows.
Macros are composed of Actions , each of which represent one step, or command, in the macro workflow.

In your case, you need two of the most basic KM Actions:

  • Copy action
    • Does exactly the same thing as when you do a ⌘C
  • Paste action
    • Does exactly the same thing as when you do a ⌘V

Let take a look at these in a macro:

image

Of course, the COPY Action copies whatever thing you have currently selected (text and/or images).
I snuck in another Action (Activate TextEdit) so that the Macro would first switch to another app before making the paste. Of course, you could have KM to other things, like switch windows, or move to a different location in the current document. If you want documentation on any Action, click on its Gear menu, and select "Help".

Make sense? OK, let's more on.

Are you familiar with the standard Mac keystrokes for navigating and selecting text?
I could not find a succinct reference for this, so from one of my Evernote Notes:

Move the insertion point

CMD-Right Arrow end of the current line
CMD-Left Arrow beginning of the current line
CMD-Down Arrow end of the document
CMD-Up Arrow beginning of the document
OPT-Left Arrow beginning of the previous word.
OPT-Right Arrow end of the next word.
OPT-Down Arrow end of the current paragraph
OPT-Up Arrow beginning of the current paragraph

To select the text from the current insertion point, just hold down the SHIFT key in any of those keystrokes.

So, KM can issue any keystroke using the Type a Keystroke action. Looks like this:

image

So, assuming that the current insertion point is AFTER the last word you want to select, you just use these Actions to select the last TWO words:

image

Make sense? OK, let look at the complete macro now:

MACRO:   Copy and Paste [Example]

**Requires: KM 8.2.4+   macOS 10.11 (El Capitan)+**
(Macro was written & tested using KM 9.0+ on macOS 10.14.5 (Mojave))

#### DOWNLOAD Macro File:
<a class="attachment" href="/uploads/default/original/3X/a/0/a06c3fae2264a2b4a07a34eacfcaa4f60e7484c8.kmmacros">Copy and Paste [Example].kmmacros</a>
**Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.**

** **Make These Changes to this Macro** **
1. Assign a Trigger to this macro.
2. Move this macro to a Macro Group that is only Active when you need this Macro.
3. ENABLE this Macro, and the Macro Group it is in.
---


<img src="/uploads/default/original/3X/0/7/075413b0f90626eec3941cdbaf612b01646d8086.png" width="483" height="787">

---

OK, that should get you started.
For homework ( :wink: ), dup this macro, and revise the dup to select and copy a whole paragraph using the keystrokes I posted above.
Give it your best shot, and if you really can't figure it out, come back here and we'll help more. 
If you have new question, please post in a new topic.

`~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`


You will also find this helpful:
[Tip: How Do I Get The Best Answer in the Shortest Time?](https://forum.keyboardmaestro.com/t/tip-how-do-i-get-the-best-answer-in-the-shortest-time/10797) 

**Getting Started with Keyboard Maestro**

* Read the [Quick Start](https://wiki.keyboardmaestro.com/Quick_Start).
  * This is essential to become familiar with KM terminology
* Do the tutorial (Help ➤ Tutorial) in the KM Editor.
  * Gives you a live walkthrough of creating a macro in the KM Editor
* Review/Browse the Available [Macro Actions](https://wiki.keyboardmaestro.com/Actions)
* For Help with an Action in your Macro, click on the gear icon <img src="/uploads/default/original/2X/f/f1f820852b2301d32534138e4cf4b093cdadf89b.png" width="25" height="21"> at the top right of the Action, and select "Help"
* Search the [Keyboard Maestro Wiki](https://wiki.keyboardmaestro.com) for detailed help.
* Start small, and grow your macros organically.
* Be prepared for some trial and error in the beginning.
* Make good use of this [Keyboard Maestro Forum](https://forum.keyboardmaestro.com/)
  * Checkout these Great Resources
     * [KM Forum Macro Library](https://forum.keyboardmaestro.com/c/macro)
     * [KM Forum Best Macro List](https://forum.keyboardmaestro.com/t/best-macro-list/4118)
     * [KM Forum Tips & Tutorials Section](https://forum.keyboardmaestro.com/c/tips)
  * Search for existing macros
  * Post your questions/issues if you get stuck
  * Be sure to first read:  [Tip: How Do I Get The Best Answer in the Shortest Time?](https://forum.keyboardmaestro.com/t/tip-how-do-i-get-the-best-answer-in-the-shortest-time/10797)

For more help, see [Getting Started with Keyboard Maestro and the Forum ](https://forum.keyboardmaestro.com/t/getting-started-with-keyboard-maestro-and-the-forum/6).

`~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`