I've been using Keyboard Maestro 11 for about a month on my new MacBook Pro M4 Pro (Sequoia 15.5 (24F74). Yesterday, I noticed that when I tried to Copy & Paste blocks of text, only the first line will paste into my document. I was able to work around it and it seemed to eventually clear up. Today (after rebooting at start-up), Copy & Paste was functioning fine, until it wasn't. Suddenly, it reverted back to the one-line behavior. I decided to launch the Clipboard History Switcher, and I saw that the entirety of the copied text is there, even though only the first line would paste. I was able to drag the entry of the copied entry into my document, though all the formatting was gone. What's going on?
Not sure. I've never seen this behavior before. Does it make a difference what app you're pasting into?
It was a few different apps. When the problem started, I was in Chrome (latest build) copying some AppleScript that Claude generated for a KM Macro (ironic, huh?). I pasted it into an Execute AppleScript Action and noticed that only part of one line (in this instance, a
Copy and Paste how? In what way is Keyboard Maestro involved? Is it involved, or might this be something else entirely?
I wonder if the remaining lines were hidden off to the right ?
If the copied source has a different line delimiter (\r
is a common alternative to the expected \n
and "Claude" may copying from (cough... approximately retrieving from ... a Windows source, or assuming a Windows client))
then in a macOS context you may see a single (very) long line, rather than a series of delimited lines.
The solution, if you are putting yourself down-stream of a lot of reconstituted mulch from a Claude hose-pipe, or material generated on Windows systems, will be to automatically run a clipboard cleaner, normalizing to \n
, and perhaps pruning out multiple white space sequences.
Yes, although it seems, from what @NealWiser writes, that Keyboard Maestro is involved, it might be worth turning its Engine off if there is any doubt about that (see ‘File > Quit Engine` in Keyboard Maestro). Find out whether the unexpected behaviour continues, and then of course, turn the Engine back on so you can continue using KM.
Also, @NealWiser, try Help > Interactive Help
if you have not already done so, and follow the Wiki’s guide on troubleshooting.
Were you using the standard MacOS shortcuts (hotkeys) to do that? If so, have you perhaps reassigned ⌘-V for use with a macro? Check for ⌘-C too. (Reassigning such common shortcuts to macros can be used to enhance copy and paste behaviour for one’s needs, but one has to be fully aware of what the macros are doing. )
Do any of your macros interact with clipboard history?
In short: you (or we, if you report the results of your experiments here) need to narrow down the possible reasons for the problem.
If you are able to narrow the problem down to just one macro, and need help with it, post the macro in a reply to this topic.
Good luck with your testing and let us know how you get on.
Thanks for everyone's help. While I was away for the weekend, I haven't noticed the behavior returning (for now). I'll keep my eyes open if it recurs.
@kevinb I didn't think of quitting the engine. I'll definitely try that if/when it happens again. Also:
- I haven't changed the Copy/Paste Mac shortcuts.
- While it occurred while trying to create a specific Keyboard Maestro macro, it wasn't one that interacts with the clipboard history, and I don't have any that do.
@Nige_S I assumed Keyboard Maestro is involved because the error occurred when using keyboard shortcuts as I was working on another keyboard shortcut, and was able to get partial resolution by finding the content I was cutting and pasting in the Keyboard Maestro Clipboard History. While correlation is not causation, it's the logical first place to start.
@ComplexPoint No, nothing was hidden off screen (I did look).
If you suspect Keyboard Maestro, the best first place to start is the Engine Log (~/Library/Logs/Keyboard Maestro/Engine.log
, also available via the Editor's Help menu then the "Open Logs Folder" menu item). That'll show you which, if any, macros have triggered -- much quicker than checking all your macros for any reference to the Clipboard.
If it is KM then there's at least three ways this could be happening:
- When you Copy with
⌘C
a macro is triggered that does the Copy and then sets the System Clipboard to only the first line of the text - When you Paste with
⌘V
a macro is triggered that sets the System Clipboard to the first line of the System Clipboard, then Pastes - You have a macro with a "Clipboard Changed Trigger" that executes when the System Clipboard changes, and sets the Clipboard to the first line of the Clipboard
Any of the above may only be active when certain apps are frontmost, may be enabled/disabled by another macro, etc. -- that may be why the problem is intermittent.
They don't have to -- they'd interact with the System Clipboard itself. There is only one System Clipboard; the History is KM's record of previous states and yes, when a macro changes the System Clipboard the previous Clipboard is added to the top of the History stack.
I've conducted additional tests and it appears that the Copy & Paste issue is being caused by KM. However, I do not see anything in any of my macros that could be triggering it. Except for the macro that opens the Clipboard History, none of my macros reference it at all.
Also, re it being intermittent, today it happened when copying text between Chrome and the Notes app, but it worked differently each time as I went back and forth.
“Appears” won’t do. In order to make progress, you need to be sure, and I don’t think there has been evidence that KM is even probably to blame. Correct me if I am wrong about that, of course.
From your original post:
Current thoughts:
- If the copied text reaches the clipboard (in the Clipboard History Viewer, you see copied text at the top, as the "System Clipboard” entry, right?), but it does not get pasted from it, that suggests a paste issue rather than a copy issue.
- I gather that you (quite sensibly) always paste using ⌘-V and that pasting by any other method (e.g.
File > Paste
) is untested; however, testing it over an extended period would be too arduous to be practical, and it is most likely that it is ⌘-V uniquely that is triggering something. - You see nothing in the KM logs to indicate that a macro is run when you press ⌘-V, correct?
I see no reason why KM would interfere with pasting if you are not triggering a KM macro with ⌘-V. My bet would be that the weirdness is being caused by a process beyond KM.
Do you have any other shortcut applications running? Anything that could be intercepting ⌘-V? Examples: BetterTouchTool, Alfred... There are many. Check Shortcuts.app too.
Take a very careful look through the Applications folder (also ~/Applications) and pick out which applications might be running and (mis)handling ⌘-V.
As a further potential aid to remembering any forgotten applications that could be involved, you might also create a KM macro to list all applications that are running—for instance, use a Display Text
action, set to display text in a window, and use the tokens %Application%Foreground%
and %Application%Background%
(or %Application%All%
to see everything in one list, but it will be very long).
If that all fails, and if no-one else here has better ideas, try something more drastic e.g.
- Uninstall KM (if it is still your prime suspect). Make an extra backup of your macros first, just in case… and try using your Mac without KM for a while (is that even possible?
).
- Set up a new administrator account on your Mac and start testing there from scratch, installing any suspected applications one by one.
Again -- Clipboard History is irrelevant in this except as a way for you to view the current and past System Clipboards.
You need to search the "All Macros" Smart Group for "System Clipboard"
and SystemClipboard
(to also catch token use).
Better yet, open the log file in the Console app as explained above. Scroll to the bottom of the log then position the window somewhere visible. Get on with your work and, next time the odd Paste happens -- look at the log. The last entries will relate to the latest-run macros, telling you which to investigate. No entry -- then it isn't a KM macro that's causing the problem.
Thanks for your detailed reply. After posting yesterday, I decided to take some time and try to narrow down the problem. I disabled one macro group at a time thinking that's how I could find the/any offending macro, but the issue is so intermittent that I didn't see anything obvious (I also have a lot of groups to filter through). And while I've also been experimenting with Mac's Shortcuts (I haven't had a chance to start testing those yet), the issue did appear to go away once I turned off the Keyboard Maestro Engine. I'm reenabling the KM Macros a few at a time to try to narrow it down before moving on to the Shortcuts, but since I have over 100 macros and I'm crazy busy right now, it's going to take a while.
Please see my reply to Kevinb. However, I will try your suggestion about the Log file and the "All Macros" Smart Group. I just haven't had a chance to dig into that yet. And thanks for the help. I do appreciate it.
On the basis of the details in your posts, I think you might save time by checking Shortcuts.app first.
- You have not set so much up in Shortcuts.app as you have in KM, so there will be much less to check. Have you even set up your own “shortcuts” in Shortcuts.app? If not, you can rule that application out; otherwise you will not have much to check.
- Enabling macros or (to narrow things down quicker) macro groups is methodical, but you should only need to check each macro’s triggers, and I think you have already done that. If a macro does not have a ⌘-V trigger, then it will not be the cause of the problem; a macro could still be executed by other means, e.g. an Applescript trigger from another application which is taking ⌘-V as its own trigger, but either way, KM’s log will show you whenever a KM macro has been triggered, and if you do not see a corresponding entry there, I do not see that KM could be involved.
Rule out Shortcuts, then check what other applications you have that may be handing ⌘-V. That includes automation apps, clipboard apps, any such “helper” apps!
My bet would be that a little time spent doing that would be better spent than a lot of time testing for problems connected with KM macros. If nothing else, those other applications would be in the clear.
Good advice. Thanks. This is where an AI agent would be useful, but we're not there yet.