How can I pass a parameter to the Force Quit & Relaunch action? I’m trying to create a macro that can be triggered to relaunch any frozen app. When an app is frozen it might not necessarily be the Frontmost and I don’t want to create a macro for every single app on my system that can possibly freeze.
Actions that take applications generally cannot be configured to work on an application specified in a variable, so your only solution would be to implement the force quit and relaunch functionality yourself (or to have a variety of Force Quit and Relaunch actions, each configured for a possible application, and select the desired one with an If Then Else action, but that is clearly problematic as well).
A final option, which might actually work ok for this case, would be to use the AppleScript do script command of the Keyboard Maestro Engine to execute a Force Quit and Relaunch based on the XML of the action. Since you could adjust the XML to match the desired application, that would presumably work.
As Peter said the KM action doesn't allow for parameters, but between AppleScript and the shell you can do anything you want.
tell application "System Events"
set appList to name of processes whose background only is false
tell current application
set theApp to choose from list appList default items (first item of appList)
if theApp is not false then
set theApp to item 1 of theApp
set shCMD to "killall " & theApp & "; " & "open -a '" & theApp & "'"
do shell script shCMD
The frozen app is almost always airmail but sometimes other apps freeze too. I was looking for a way to quickly relaunch the app. My idea was to use Alfred + Keyboard maestro, so I would invoke Alfred (cmd+space), type the workflow keyword like "relaunch", space, then alfred would filter me a list of apps as I type and when I hit enter it would execute the KM by passing the app as parameter.
This works for some apps but not others. For example, if I trigger it while UAD Console is the front application, it doesn't quit the application, and instead launches the Console app.
I've tried the Alfred route, but it takes a while to show running apps, and then you have to manually search for it (if it isnt already visible in the UI). For my needs, I'd just like to quit and relaunch whichever app is currently in focus.