[Moderator's Note: This is now a native feature in KM 8+: Create a Macro Alias by any of these:
⌘L, Menu Edit > Make Alias, Drag/Drop with ⌘⌥ to another Macro Group.]
Sometimes I have a Macro in one group, and I want it in another group also. Usually this is because I want it on more than one Palette, or I want to have it on a Palette, yet give it a hotkey that works even if the Palette isn't visible.
I don't like duplicating the code in the original Macro. So the alternative is to create an "Alias". That's a Macro with one action in it, an Execute a Macro" action that executes the original Macro.
Perhaps this animated GIF can explain it better than words can:
All you have to do is select the original Macro, trigger this macro, and you get an "alias" to the original macro. Drag it somewhere, change the name, and you're good to go.
NOTE:
If you try this macro and it doesn't seem to do anything except beep, please see this post (click on it to see the full post):
I believe it's a simple fix. And I'd like to know if this affects you. Thanks!
I just Option-Drag a macro to the macro group where I’d like a duplicate. Like in the Finder, the cursor shows a plus sign (+) next to it while dragging.
That copies the entire macro. So If you need to change the logic, you now have two (or more) places to change it.
With an “Alias”, the second macro just points to the first. It’s the equivalent to holding down ⌘⌥ while dragging in finder (except of you don’t drag, so I suppose it’s more like right-click -> Make Alias).
Yeah, I’ve run into both of these problems too. Good solution. Embarrassingly simple.
I haven’t played with this yet, but I think there’s a much more important use for this. I have a lot of groups that are each active for a single application. I also have some groups containing macros that are active in a natural set of applications — something like all my editors, or except for my development tools, or occasionally something more specific such as the MS Office applications.
However, sometimes I have a macro that i want active in what is essentially a random set of applications. It would be nonsensical to create separate groups for each of these random combinations of applications. Much better to store the original macro outside of the application groups and put an alias in each application’s group.
Just so you know, I’ll never be unhappy if you natively implement any of my ideas. It’s not like I’m a cottage industry and you’ll take away my livelihood.
(FWIW – the first few times I used the macro, KM “bonked” and nothing happened. It later began working. Most likely clueless user error, but maybe not.)
My guess is that one of the pauses isn't long enough in the macro. When something gets copied to the clipboard, there's no way to tell when it actually finishes getting copied.
So if it happens again, my guess would be that the last Pause action isn't long enough. It's right before the "Paste" action, right near the bottom before the "Cleanup Variables" group:
It's at .4 seconds, so you could try increasing it to .6, or higher, and see if that helps.
If you end up doing this and it solves your problem, I'd appreciate it if you posted here to let me know.
Dan, here's a JXA snippet that waits for the clipboard to change. This was inspired by a comment from Peter that the KM Copy action does this. I just wrote this yesterday, so It has had only very limited testing, but seems to work well so far.
EDIT: 2016-06-18 15:56 CT (Sat)
var timeLimitSec = 5
var clipStr = ""
//--- Set the Clipboard so we can test for no selection ---
app.setTheClipboardTo("[NONE]")
//### Do something to put content on Clipboard, like an App COPY ###
//--- This is just an excerpt from the complete coded required ---
seApp.keystroke('c', { using: 'command down' }) // Press ⌘C
//. . .
//### THE BELOW IS THE MAIN POINT OF THIS SNIPPET ###
//--- LOOP UNTIL TIMEOUT TO PROVIDE TIME FOR APP TO COMPLETE COPY ---
var startTime = new Date().getTime() // number of milliseconds since 1970/01/01
var timeLimitMs = timeLimitSec * 1000.0
while ((new Date().getTime() - startTime) < timeLimitMs) {
delay(0.2) // adjust the delay as needed
//--- Get the contents of the Clipboard ---
clipStr = app.theClipboard()
//console.log(clipStr)
if (clipStr !== "[NONE]") break;
} // END WHILE waiting for copy to complete
At 0.7 I get no bonks -- although that seems like splitting hairs. To be scientific, I'd have to try to different times while aliasing every macro in my library. Probably not going to have time for that this decade.