Can I Automatically Copy a Text in Selected?

I know this works, but it copies every time I click, or if I add a modifier key, it becomes more of a hassle, is there another way to trigger it, for example by whether it is dragged, or the interval between releases
auto copy Macro (v10.0)

auto copy.kmmacros (2.6 KB)

Hi @jone_smith

The tricky thing about using the mouse click (or trackpad click) as the trigger for a Macro is that we are always clicking the mouse around screen - so the problem becomes how does the Macro know when to trigger and copy stuff and when not to?

I had a play with a Macro in TextEdit which achieved what I think you want (it tested for a few conditions - 1) had the mouse been dragged after the initial click 2) was "copy" enabled in the App menu 3) had the mouse button been pressed and released - before making the copy) but it still wasn't 100% reliable so I'm not uploading it.

One thing you could try - have a hot key run a Macro which basically puts you into a selection "Mode" where any text you click on and drag the mouse over is automatically copied while you are in that selection "Mode". And have another hot key end that "Mode". I think that would be more robust.

Or... drag over the text you want to select and press ⌘C :grinning::wink:

Thank you for your reply, and thank you for your suggestion, I don't know why I always think it is possible to achieve, but my current ability is not enough to achieve, :laughing: I can only provide some of my ideas, for example, can be based on the interval between the mouse hold and release time to determine whether to select the text to trigger, or according to the mouse hold after whether to move to trigger, I think these are two feasible trigger conditions, I don't know what you think? think how? If you can, please let me know, thank you!

I still think you are trying to do something not that advisable and that kind of fights the way the Mac is designed to work. But with that said...

I have done something which I think achieves what you are after. This example Macro works in TextEdit - but it can be adapted to the App you are working in by putting it in that App's Macro Group.

But before doing that try it out with some text in TextEdit to check it is working.

The logic is that the Macro doesn't do anything if any of the following are true:
The Mouse has not been moved between the down and the up click
The Menu item "Copy" is not enabled (i.e. this becomes enabled when something is selected)

Breaking down the steps:

  1. It is triggered when the Mouse or Trackpad Button is pressed (rather than when it is released).
  2. It copies the current mouse location to a Variable - LOCAL__MousePosition1
  3. It pauses for 0.25 seconds (I found it needed this pause to catch up)
  4. It Pause until the mouse button has been released
  5. It copies the new position of the Mouse to a Variable - LOCAL__MousePosition2
  6. If the mouse hasn't moved between down and up click (i.e. LOCAL__MousePosition1 = LOCAL__MousePosition2) or the Menu Item "Paste" is not enabled, the Macro ends without doing anything.
  7. Otherwise it copies the selection to the Clipboard.
  8. It displays the Clipboard Briefly

Here is a little GIF showing it in action. I first click the mouse around without selecting text and then I start to select text:

EXAMPLE Copy Selected Text in TextEdit App by Clicking and Dragging-Animated GIFF Small 12fps

EXAMPLE Copy Selected Text in TextEdit App by Clicking and Dragging Version 4.kmmacros (44.5 KB)

Screenshot of Macro

EXAMPLE Copy Selected Text in TextEdit App by Clicking and Dragging Version 4

Thank you very much, it works very well.:+1:

1 Like

Feedback and pondering:

I've enjoyed using this. There is an initial cognitive overhead of remembering that the click/drag loaded the clipboard which needs to be used BEFORE selecting anything else as the anything else then replaces what's on the clipboard. I've found the initial issue is that I often go in with a loaded clipboard and then select something else I want to replace with the CB's content. This obviously doesn't work.

One option could be to have the next click auto-paste the clipboard so it doesn't get replaced. Another option would be to have each click and drag continuously auto-loading a clipboard manager, and the next click after the drag presents the clipboard manager to pick from. This more tightly integrates the CB manager into the copy/paste process. It's probably a wash at this point in terms of saving the number of actions needed.