Is there a way to do this nativily with Keyboard Maestro actions? I would like to use the activate application action but it doesn't look like you can add varible names?
I am making an action to toggle between the current three front applications and another default set of three applications to speed up some workflow.
I believe AppleScript is the solution to your problem. What is wrong with using AppleScript to activate an app whose name is stored in a variable? I can see you know how to do that.
Maybe what you are missing is that you haven't considered creating a KM subroutine that is passed a value which is the name of an app (or the name of a variable that contains the app's name) and use that information to call an Execute AppleScript action which will activate that app by its name. That would be a simple and clean solution, and it would even look like a native KM action (although it's really a subroutine.) Since this would work, why is not acceptable?
Nothing is wrong with using AppleScript at all and that is where I started with Automation 20 some years ago. It just seems like more and more Keyboard Maestro always has a native way of doing something when I have gone down the AppleScript route so more of just learning rather than calling on other tools.
Yeah I am not really sure how I would do that. I thought of something like this but it wouldn't open apps in other folders.
So does this mean all your applications are already running? And all you want to do is bring a different one to the front? If so, Use Variable might be what you're looking for.
Thanks, I should have clarified I do have it working and just wondered if there was another way to do this that is more native without using AppleScript. I am trying to learn Keyboard Maestro a bit better and not be stuck in my ways.
Right, but is the this launching applications or just bringing them to the front? If you're using tell application app to activate to bring each app to the front, then you could use Use Variable to set the front application by name from your variables. Or am I still misunderstanding something?
Oh gotcha I think I would probably need to see an example of what you are referring to. I am just trying to bring them to the front because in most cases they would already be opened but on occation they might not be the first time I run it.
As long as I'm understanding everything correctly, I think these three KM actions should be able to replace your applescript action (possibly you'd need a set action delay also)
The second step is to pass the name of a variable to that macro, like this:
Remember, you are passing the NAME OF A VARIABLE, not the pathname of the application. That's how you stated your problem. Notice that the first action of the subroutine is to de-reference the variable name into a value, and the second action launches the app.
I only learned about it relatively recently myself (from Rob if memory serves), and it's been incredibly useful to me and my workflows. Considering how many times I've mentioned it to others here in the forum, it seems that very few people are aware of its quietly powerful capabilities.
Yes, it's amazing and powerful. Still, some people might like the subroutine approach, as it puts more opportunities for customization in the user's hands.
Thank you yes that works great and it is funny I was looking at all those options last week and didn't remember seeing that. Looks like all three options work for what I am after.