Create individual macros for each app in the Applications folder

I'm in the process of transitioning from Raycast to KM as much as I can, because Raycast isn't fully supported on old OS such as Catalina, so some extensions stopped working and pretty much 99% of what I'm using Raycast for can be achieved with KM.

One of the things Raycast does well is that it automatically updates the "database" of apps installed and so even if I installed an app 10 seconds ago, when I go to Raycast, it's available right away.

It seems that I need to create individual macros per application with the Activate Application action. Right now I have 180 applications and doing it manually would take forever...
If that's the only way, so be it, but before I started this crazy journey and then someone pointing out I could have done it in a few seconds with a macro, I decided to ask if there's a way to automate this?
I was thinking that XML would be an option, but the Activate Application action's XML contains stuff like


So I don't know how KM would be able to find all of this information in case I wanted to use the XML route.
Any tips?

I was thinking that maybe another option would be to use the Execute AppleScript route, because in that case the XML would always be the same and I just needed to update the name of the Application in the XML with a variable. I already have the names of all 180 applications separate anyway.
The only issue I see with this approach is that the macro won't have the app's icon so if I wanted that, this would take me way longer than picking the application on a Activate Application action.


I don't know anything about Raycast at all, but can you explain what it does with applications that you want to replicate in Keyboard Maestro? If it's just a launcher, doesn't Keyboard Maestro's Activate Application Launcher do what you want?


Raycast is like a Spotlight replacement, but with extra features (extensions) that allow you to do more things than Spotlight (and better) and it allows developers to create those extensions, so you get like a "super-tool" so to speak.

I never used the Application Launcher, but checked it now.
There are a few issues with that option:
1 - It would require me to have a dedicated shortcut to open it, which I wanted to avoid otherwise I would just keep Raycast to do that. I pretty much just want to have one shortcut (CMD+Space) to open the Execute Macro by Name and show all my macros, which is what I use now, and when I hit that shortcut, it also includes all the applications.
3 - One of the things I still feel about KM is that a lot of the graphic stuff looks like stuff designed 15-20 years ago and even though I know that things don't work better or worse because of the way they look, I think it's an important aspect when you have tools that look modern (or at least give you the option to customize them). The Application Launcher still looks like it was designed for Snow Leopard or something...
4 - It doesn't have a search field so if 2 applications include the same word, it won't show the 2 results next to each other to allow the user to pick one. Let's say one was "Mail" and the other one was "Another Mail". With Raycast (or Spotlight) you will see them both, but not with the Application Launcher. You would need to really type the exact name, if you know what I mean?

Maybe the only option is really to just do it manually. At least I only have to do it once for the vast majority of applications and then update that list here and there when I install or uninstall an app, which is not a big deal.

This isn't exactly what you want, but may fall happily in-between your ideal and what's actually maintainable. It'll list all the apps on your machine and present them in a "Prompt With List", allowing for sub-string searches in the way you want. Search, select, app opens.

Open An App.kmmacros (3.1 KB)

Its name is prefixed with a space (you could use any first character(s) that is unique across your macros), so I'd see the workflow as āŒ˜-Space to show all your macros, Space then Return to run this one, start typing your search.

The problem with "one tool to rule them all" is that different/dedicated utilities are often better at a particular thing, or at least work in a way that you prefer -- which is why you chose them in the first place. If you can't upgrade your OS (insert obligatory "now out of support" warning here) could you fix your Raycast version to an old one that did support Catalina better?

I think that having one single starting point is admirable, but there will be trade-offs. For the record, I have been an Alfred user FOREVER, I tried Raycast for about a year, but went back..

Here's my thought. Use Alfred as your main KM Macro search / App launcher

That link (above) might be a bit old... here's a newer solution

1 Like

If you really want to create an individual macro for each application this AppleScript will:

  1. Make a new macro group called "New Openers" if such doesn't already exist
  2. Will make in that group a new macro called "Open application name" for each application in the current Finder selection, containing the "Activate a specific application" action targeting the app

Because these are KM macros just as you'd make by hand they include the icon of the targeted app. And it's easy to change the XML of you want different default action settings.

As written the macros will be enabled but have no trigger -- it would be easy enough to give them all the same hotkey trigger is you wanted to go the Conflict Palette route, but it sounds like you don't want to do that.

Pop this into your favourite script editor, select some apps in the Finder, run the script:

set firstXML to "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"\">
<plist version=\"1.0\">

set secondXML to "</string>

set thirdXML to "</string>

set lastXML to "</string>

tell application "Keyboard Maestro"
		set gpID to id of first item of (every macro group whose name is "New Openers")
	on error
		set gpID to id of (make new macro group with properties {name:"New Openers"})
	end try
end tell

tell application "Finder"
	set theList to (get the selection)
	repeat with eachItem in theList
		if class of eachItem is application file then
			set theName to displayed name of eachItem
			set thePath to (characters 1 thru -2 of POSIX path of (eachItem as alias)) as text
			set bundleID to id of eachItem
			set theXML to firstXML & bundleID & secondXML & theName & thirdXML & thePath & lastXML
			tell application "Keyboard Maestro"
				set newMacro to make new macro with properties {name:"Open " & theName}
				set newMacro to move newMacro to macro group id gpID
				set theAction to make new action at newMacro with properties {xml:theXML}
			end tell
		end if
	end repeat
end tell

I'm sure there are improvements to be made -- I'm a bit rusty -- but it does at least work!