Highlight Copy and Paste

Hello Guys,
any help with a macro that can automatic copy an highlight text and same time paste in an app like notepad.

I do a lot of copy and paste from browser Firefox and paste on a notepad . am thinking it possible to make a macro that once I highlight the text, it auto copy by pressing the cmd+c and same time paste in the notepad app with cmd+v.

thanks in advance ..

Your requirement seems fairly simple. One problem I foresee is that I'm not sure if there's a 100% reliable way to trigger the macro without pressing a key. Like CMD-C. It may be possible to do without CMD-C or some other key but I'm not yet certain.

Another minor issue is that I don't think Notes has good support for AppleScript so basically it's probably just going to paste the text into the current note. Is that okay?

One possible solution that might solve the first problem involves using a mouse with reprogrammable buttons. So tell me what brand and model your mouse is. This might be required if you insist on a solution that does not require you pressing a key to trigger the macro. I have reprogrammed my own mouse buttons to help resolve problems similar to your problem. I'm not quite sure yet whether this will help you out, and of course I don't know if you have a mouse with reprogrammable buttons in any case.

I like this problem. It's tricky. I might have a solution for you. My solution might have a side effect which may or may not be acceptable to you. We'll see.

Here's a possible solution for you. It works, but it has one undesirable side effect. The word "Edit" in the Safari menu Bar at the top of the screen is constantly flashing. It's very distracting. But it solves your problem with some interesting code. You can reject this solution due to the flashing, or you can put a yellow sticky note on the screen so it doesn't bother you.

It also has a small timing requirement. It won't copy the text until one second after you've selected it. That can easily be shortened to a shorter value if you edit the code. There's a minimum which is probably based on the speed of your computer.

This code uses an infinite loop approach to make it work. Some experts on this forum object to using infinite loops. They prefer loops that trigger periodically. I suppose you could modify this macro to work that way. In this case it's not too serious because the macro stops doing any work when Safari is not the front application. So it's easy to stop.

I mentioned earlier that if you had a programmable mouse there may be a solution that doesn't involve infinite loops like this one. There might also be an AppleScript solution but I'm not versed enough in AppleScript to know that. My gut tells me that AppleScript won't be able to solve this without you using a keystroke to trigger the macro.

Auto Copy.kmmacros (8.3 KB)

Thank you very much.. you really understood what I wanted.. I was suppose to mention mouse and not keyboard . I want to able to use my mouse without pressing key on the keyboard.
I use apple Magic Mouse 2 .

the notepad I mean was textedit to notepad++. not the notes. sorry about the confusion

Okay. Glad to hear you liked it. Can you make the macro above work to your satisfaction? I don't have Notepad so I'm not sure I can edit that action, you will have to make that change yourself.

As far as the mouse goes, we won't go down that path because your mouse is not programmable.

In my example above I didn't include any trigger. Sorry. You can assign any hotkey you want to that macro. I normally leave that to other people since the choice of hotkeys is a very personal thing.

In this case I should have added a Semaphore Lock action to the top of the macro to prevent people from running it twice. When I write new code like this I don't always make it robust, and that's my fault. Here's what you should add at the top of your macro before assigning a hotkey trigger to the macro:


Creating a macro to copy, activate your Note app, and paste is very simple. But you will need to give it a trigger of some type.