KM10 Feature Review: What Macros Execute This Macro?

In @peternlewis's list of new features is what I think is a hidden gem:

Added 'Or by Execute Macro' to macros editor listing the Execute a Macro actions referring to this macro.

What does this mean?

It shows a list of all macros that call this macro. For example:

image

If I click on the first entry:

image

It takes me to that macro, and you can see the reference right here:

image

If you reuse macros like this (and if you don't, you should think about it), this is invaluable.

9 Likes

This is great! It might be able to replace the macro I use to show where macros are embedded.

I’m not at my computer right now, do you know if the subroutine has to be called as a subroutine in the macros it’s embedded in? Or will it also show up if it’s called from an “execute a macro” action? I ask because I have many subroutines that are embedded in other macros and that are called using the “execute a macro” action. I honestly still haven’t had the time to wrap my head around the new execute as a subroutine feature.

No idea. I know that I'll be using subroutines a lot in the future, but I'm working on other problems at the moment. :joy:

I learn something useful like that nearly every day. Thanks.

I haven't used the new subroutines yet. (Probably because most of the subroutines I wanted to write need images passed to them, not strings, and I don't think that this will be possible in the new subroutine feature.)

Well, you could always convert the image to base64 encoding, which will go in a variable and also in subroutine parameters, but I don't know what you'd do with it after that.

I encode image files in base64 with this shell script ("b64FilePath" is the variable with the path to the file to be converted):

image

And there's probably a similar way to convert it back, although I've never done that. But like I said, I don't know what you'd do with it.

I will ponder your suggestion, but no doubt what I need to do is get the image back into a named clipboard to do things like image searches. I don't know why I didn't think of your idea, although that very fact answers my own question, because I'm ignorant. :slight_smile: Thanks.

If you're working locally it makes more sense (to me) to just pass the file path and let the target macro do the rest.

1 Like

I just checked and any macro that is executed from within another macro appears in the dropdown list here, even if they are not ran as a subroutine. VERY handy!

1 Like

Don't forget that you can do that with a file too.

That may be true. I know my needs aren't universal, but it would be much better for me if named clipboards could be passed without going through files.

Also, KM has a lot of places where app names are not simply strings, but some sort of hardcoded thing. There are times when I want to pass app names as parameters to subroutines. Are there any pages on this website addressing that problem?

Yes I noticed that a few weeks ago, and it's handy. But I think you can still use those files only as the thing you are "looking for", not the thing that you want to use as the larger image.

True.

Are you saying there's a way to use a named clipboard as the target image?

If so please elucidate.

A lot of places? Not so many.

The application token for one. What else?

You can always use search and replace to remove a path from a file name.

Or the path splitter action.

Or a filter.

No, I'm saying the exact opposite. I'm saying that there is no way to use anything but the screen as the target image. I'm lamenting that there is nothing else you can use as the target image. I apologize for not being perfectly clear. I presume that I'm clear now.

I presume we are using the same definitions. "Source image" would be what you are "searching for" and "target image" would be the larger thing you are "searching in."

Since you mention several ways to remove the path from a file name, that demonstrates that you don't understand my point. I'm not trying to get the app name. I'm trying to do the exact opposite. For example, let's say I have a variable that contains the string "Notes" and I want to "Activate" the Notes app because that's the name of the app in that string. How would I do that with the KM "Activate Application" action? As far as I can tell there's no way to use the KM action to activate an app named in a variable because the KM action "Activate App" contains only a hardcoded field for the app name, not a text field. Now do you understand my concern?

Ah, so.

I can't think of any way off hand to pass a simple name to a Keyboard Maestro launch/switch app action – but this is easy enough to accomplish with:

Shell:

open -a "$KMVAR_KmVariableName"

AppleScript:

set kmInstance to system attribute "KMINSTANCE"
tell application "Keyboard Maestro Engine"
   set theAppName to getvariable "local_AppName" instance kmInstance
end tell

# Uncomment for testing.
# set theAppName to "Keyboard Maestro"

tell application theAppName
   activate
end tell

-Chris

That's true, and this example not too difficult to fix with AppleScript, but as I said there are many KM actions with this issue. I'm counting about 27 actions, (not even including triggers) and I'm not eager to learn 27 different approaches in AppleScript to solve this problem.

First off, I understand your point, and I acknowledge the issue. Yes, it would be better if you could pass some things in variables that you can't currently do.

And yes, learning 27 different approaches would be a pain.

But, and here's the thing: You can in fact do a lot of what you want to do with some creative use not only of AppleScript, but also creating actions on the fly and launching them. So ask, and you shall receive (hopefully). :stuck_out_tongue:

2 Likes

I will consider that, but that would be in a different thread. Thanks.

1 Like