[KM] Reveal Macro and Group From UUID

MACRO: [KM] Reveal Macro and Group From UUID

VER: 1.1.1      2016-07-14

2016-07-14 18:07 CT (Thu)
(see Change Log below for details)

DOWNLOAD:

[KM] Reveal Macro and Group From UUID.kmmacros (15 KB)

PURPOSE:
• Open Macro and Group in KM Editor from Selected Macro or UUID
• Provides same function as Dan's "Reveal Macro Group",
and ADDs search by UUID from any app.
• This Macro auto-switches based on the front-most app.

AUTHOR: JMichaelTX (very minor mod)
DanThomas, original macro

USAGE:
Do either of these:
• Select a Macro in Keyboard Maestro.
OR
• Select KM Macro UUID (from any app)

THEN run this Macro

CHANGE LOG

1.1.1    2016-07-14
              • CHG:  Uncheck "Include Errors" in Execute JXA Actions to prevent
                 false positive error when running macOS Yosemite
              • CHG:  Error msg in Execute JXA Action #2 to indicate invalid UUID

This is a minor update based on the macro built by @DanThomas.
It simply adds an alternate source for the UUID (any app, like AppleScript)


3 Likes

@JMichaelTX thanks, this is a "necessary" macro :wink:

Nevertheless at this time, I get this message

As it is a JXA macro, could you help me to tune a little bit?

--Alain

You're on Yosemite, right?

That's just a warning message and can be ignored. I'll see if I can come up with a reusable solution.

@DanThomas, @JMichaelTX Yes, I am still on Yosemite.

but the calling macro crashes...

Thanks for your developments... and kind support :smiley:

--Alain

What do you mean, it crashes. Do you mean it actually doesn’t work? Or just that it displays that message?

Stupid question, but can you upgrade to El Capitan? The problem goes away then…

For both "Execute JavaScript" actions, turn off this setting:

I think that will solve the problem. I think.

Dan, sorry to tell this don't solve El Capitan (lake) error...

Exactly.

Sure, your suggestion is not stupid at all, but I am specially in hurry and don't want (can) face to much troubles in same time :blush:

@ccstone Chris - I can’t remember if you did this in AppleScript or not. It seems to me that you did, but apparently I’m search-impaired.

What I’m talking about is this:

  1. Get a Macro UUID from the clipboard.
  2. Find the group for that macro, by using the KM Engine’s “getmacros” command, and traversing the plist.
  3. Tell the KM Editor to focus that group, then switch back to editing the macro.

Like I said, I’m pretty sure we’ve been over this, but as my wife could tell you, sometimes I can’t see things that are right in front of me…

Thanks.

@alain: Sorry, but I don't understand your statement.

Did you try Dan's fix of UNCHECKING the "Include Errors" on both Execute JXA actions? That should fix the issue.

EDIT: 2016-07-14 09:53 CT (Thu)

I just tested this on my Yosemite Mac, and it does fix the issue -- the error msg no longer appears.

@alain, @JMichaelTX - This is probably no surprise, but I couldn't let it go.

Here's an AppleScript version:

[KM] Reveal Macro and Group From UUID (AppleScript version).v1.1a.kmmacros (16.1 KB)

This works fine.

Syntactically, I'd prefer a better solution than the nested repeats I use, but I can't figure out the native AS syntax for finding an item that contains an item with a property of a specific value. But it doesn't really matter - I's sure it doesn't do much more, internally, than what I coded.

@JMichaelTX, @DanThomas I try Dan fix so (of course) no more JXA error message, but the macro [KM] Reveal Macro and Group From UUID does apparently nothing (with/without Dan fix) in my case… at present :disappointed:

@DanThomas Thanks for the AppleScript version: I will let you know about…

–Alain

@alain, the macro has two modes, and you must do one or the other of these selections before running the Macro (BTW, you need to set a trigger for the macro):

  1. Select a valid UUID (as text somewhere outside of KM) for a KM Macro
  2. Click on "All Macros" group, and then select a Macro

The result should be, in both cases, the Macro Group for the macro is selected, and the Macro is selected.

That's all it does.

Perhaps we should have put in some regex checking to make sure we had something that looked like a UUID.

I don’t know why I don’t do that - I did it in one macro, and then just quit doing it. And it’s stupid, really, because I learned a long time ago that the more attention I spend on error checking, the less I have to debug someone else’s issues - or, for that matter, my own issues when I forget how something works (which is often, these days).

@DanThomas Yes, it will be better, something like this:

[\dA-F]{8}-[\dA-F]{4}-[\dA-F]{4}-[\dA-F]{4}-[\dA-F]{12}

And even more with some detection (with a message) of group UUID in place of macro UUID; same for non-existing macro UUID…

But don’t worry Dan, this is not the current trouble.

@JMichaelTX Thank for your detailed and careful help, but it was that I have done (I think so at least :wink: ) and nevertheless the right group was not selected…

As I have an AppleScript, I will manage by myself when I will have more time to play with.

Thanks a lot to both of you.

–Alain

I just posted this update to the original post above.

###Change Log

1.1.1    2016-07-14
              • CHG:  Uncheck "Include Errors" in Execute JXA Actions to prevent
                 false positive error when running macOS Yosemite
              • CHG:  Error msg in Execute JXA Action #2 to indicate invalid UUID

The error msg from Execute JXA #2 has been revised:

@alain, please try the revised macro I just published above.
It works fine on my macOS Yosemite machine.

1 Like

On my Yosemite machine too :thumbsup: (Thanks for your kind pugnacity) for the "~~~ ANY OTHER APP ~~~" branch... not for the KM Editor one (i.e. don't reveal the selected macro group).

[EDITED 15/07/2016 11:58:58 Paris time]

It's quite subtile: In fact, within KM Editor, selection of a given macro imply first a selection of its group if it is not already selected so there is 2 different situations:

  1. the right group is already selected and visible: nothing more happen and it is OK,

  2. the right group is already selected but need a scroll of group window: nothing more happen and it is weird.

BTW I add few more KM filtering actions, just to be more comfortable in UUID "raw" selection ;-):

Other point: I feel the need of selection of an UUID string as an alternative of macro selection, a kind of validation of macro/group UUID.

--Alain

@JMichaelTX - Can you test this for me on your Yosemite machine? It's not a suggested change to your macro (although it does include a version bump just to be clear) - it's to test a sub-macro I wrote to filter out the warning message. If the sub-macro works, I'll post it.

[DanTest] Reveal Macro and Group From UUID.v1.1a.kmmacros (27.7 KB)

Test this to make sure that the warning message is shown in one window, and filtered out in the other. The filtered result should be EXACTLY like the warning message was never there. So if you test it with a good UUID in the clipboard, the result should be empty, and if not, the result should contain your error message and nothing else - no extra "newlines" or anything.

Basically, I usually return "OK" when there's no errors, and I want to be able to test the result variable for "is 'OK'" and have it work regardless of whether it's run on Yosemite or not.

Let me know, will you? Thanks.

@DanThomas, OK, I will test when I get a few minutes.

Just so everyone knows, the need for this macro will be short-lived.

It is due to a bug in the KM Editor Search that causes search for a UUID to fail.
@peternlewis has identified and fixed this bug for the next KM version.

My point being that I don’t see much value in continuing to optimize this macro.

1 Like

I’m just uses it as a test case for my Filter macro, by the way. I think you understood that. Just making sure.