MACRO: Run Current Macro

All this standing around is wasting time!
You guys get back to work producing more macros that take up my time downloading and installing!

LOL

3 Likes

Great macro, Dan!

I'd like to request two enhancements:

  1. Support running the last macro selected for editing when the active app is an app other than KM. I often need to test macros that require the active, frontmost app to be something else, like Evernote.
  2. Provide an optional prompt showing the macro name and confirming the user wants to run it.

Thanks.

Thanks!

Have you tried it? It just asks the KM Editor for the currently-selected macro, and the KM Editor returns the selected macro regardless of whether the KM Editor is active (has to be running of course, but shouldn't have to be active).

Sounds reasonable. How would you imagine that would work? Holding down the key is for prompting for a parameter, so I wouldn't think that would be a good idea.

Yes, but evidently I was doing something wrong, like having the Macro Group disabled. :smile:

So, running with another app being active works.

I inserted these two Actions (in purple), but the Macro Name comes back as "Not Found"
What am I doing wrong? How do I get the name of the Macro to be run?

I don't see the need for any special UI. Just add the Actions and enable or disable however you like for the default. The user (as part of setup) can then change to suit his/her perf.

I'll post how I do it, and hopefully someone else can show me the one-step way of doing it, because I could never get it to work. And don't laugh at my convoluted solution - it works!

NOTE: In the second action, the word "uid" is NOT a variable. It's just text, and I replace it in the third action.

Hey, I know a guy that has already figured this out. LOL

Check out this:

So, here's my two Action to get the Macro Name, following your example:

Why the hell didn't that guy speak up earlier?

(I hate it when that happens. :confused:)

Anyway, cool! So show me how you'd change the macro, or just post it. (You want it, you do it! :slight_smile:)

Here's my small revision: Added 4 Actions (+ Change Log), all in purple.
Feel free to revise to suit your needs and style.

MACRO: Run Current Macro

Run Current Macro 1.1.1.kmmacros (44 KB)

This is really working out to be a great macro for me -- using many times a day.

A couple of questions/comments:

  1. What changed in the second action? It looks the same (I think).
  2. If I’m reading this correctly, it only alerts you of what macro is running - it doesn’t prompt you if it’s OK. Am I right? All you wanted was to be notified what it was running, with no chance to stop it?
  3. It would make sense to add the macro name to the Prompt for User Input title somewhere, don’t you think.

And lastly, I mean, seriously, you couldn’t tell what variable naming conventions I was using, and conform to them? That’s the first rule of modifying other people’s code - follow their style and conventions (assuming they have any), regardless of whether you like them or not (the styles and conventions, not the person :slight_smile:).

In my opinion, there’s only two times I wouldn’t do that - again, assuming they have a style or conventions. They are 1) Something is just flat-out wrong. 2) I couldn’t if I wanted to, because it’s over my head (we won’t name any names here).

I’m smiling as I type this, because I’m not ticked or anything. But let me tell you my thinking on this: I show respect to the other developer when I try to match their style, even if it makes my skin crawl a little. Maybe especially then.

So that’s my thoughts.

Maybe you are confused about which actions I changed.
I didn't change ANY actions. I ADDED 3:

The first two of those are modeled exactly after your actions in
MACRO: Get Selected Macro UUID (and name) (without the clipboard)

The 3rd is an ALERT, which does pause, and gives you the option to stop/cancel the macro.

I agree, except: You asked for my changes, which I had already done just for my own purpose, never intending to post. My post was just to show you my changes. I didn't expect you to use my revision as a replacement.

Feel free to totally discard my update if it is of no value to you. :smile:

OK. First, there are 5 actions in purple. That’s where my confusion was - I guess I made that first one purple myself - I forgot! :confounded:

Second, and this is another time to blush, I guess I’ve never used “Alert” before. I was thinking it was like Notify. I always use a Prompt to do what Alert does.

I’m having a great day, huh? Forgot I already knew how to get the name of a macro from it’s ID, and now this. LOL.

As far as the style/convention thing: I think my assumption was reasonable, since you went to the trouble of adding the change log and such. I personally wouldn’t have added that for my own uses, or at least nothing more than “I changed this”. But good on ya for doing that!

Anyway, that’s where my misunderstandings came from.

No problem. I wasn't trying to influence or change your style -- I was just being style-agnostic, and wanted to be clear, but didn't feel the need, nor have the time, to figure out your style, and conform to it. That's why in my upload post I stated:

My changes are very minor -- just 3 lines of "code". LOL

OK, I posted a new version. It only prompts if you aren’t running from the editor.

Also, the TriggerValue Prompt now includes the macro name, so it functions as the “do you want to continue” prompt, if you use the long key press option.

Very cool! :thumbsup:

1 Like

Dan, I used your technique in MACRO: Get Selected Macro UUID (and name) (without the clipboard) to make this KM Wiki update:

MacroNameForUUID Token -- KM Wiki

Please advise if you do not find it correct and clear, or if you have suggestions for improving it. Better yet, since you are also a Wiki editor, please feel free to update if you feel it needs it.

thanks.

Hey, I even forgot it existed, and you expect me to critique what you wrote? LOL.

It looks great to me. Glad it’s documented somewhere. Hopefully I won’t forget next time. :slight_smile:

Dan, this is definitely one of my favorite macros, that I use many times a day and saves me a lot of trouble and headaches because I don't ever have to assign a trigger to macros I am testing or developing as examples.

It has worked flawlessly, but today I run into one minor hitch:

It apparently timed-out while I was viewing the Display Text action of the macro it invoked. Not a big deal at all, but better not to have this behavior.

I'm not sure what the best fix is, but I changed the Script Action to unchecked "Abort on Timeout" and "Notify on Timeout"

Just after I posted this, it occurred to me that this may be an AppleScript error, not a KM error. So, I added a with timeout to your AppleScript:

tell application "Keyboard Maestro Engine"
  set rcmMacroUUID to getvariable "rcmMacroUUID"
  set rcmTriggerValue to getvariable "rcmTriggerValue"
  
  --- PREVENT AppleEvent TIMEOUT WAITING FOR TARGET MACRO TO COMPLETE ---
  with timeout of 60 * 60 seconds
    do script rcmMacroUUID with parameter rcmTriggerValue
  end timeout
  
  return "OK"
end tell

I ran into the same issue a few days ago, and I fixed it but never uploaded it.

So I just uploaded a new version.

By the way, I don’t believe the thing you changed will fix the problem. I think I had to specify a timeout value of 10 minutes in the AppleScript code itself. Obviously you could change it to a higher value if needed.

And yes, I use it constantly also. I can’t believe it doesn’t have more downloads. Not that my ego is bruised - people can do whatever they want. But now that I have this, I can’t ever imagine being without it!

Anyway, thanks for the support. Let me know if you run into any issues.

Yep, just updated my post as you were posting your reply.

Saw that. LOL. There’s got to be a term for that. Like “letters crossing in the mail”, but more modern.