I made a macro that restricts the app with other apps on Alfred.
It seems that it works smoothly. But there is one problem. Occasionally, it focuses on Finder without my permission.
It also sometimes focus on other apps. Perhaps the problem will be solved if you exclude the Finder Trigger in the macro. But I want to put Finder in this macro. Because I have to click every time, after canceling the Alfred restriction.
In other words, I want you to automatically release the macro when you focus on Finder.
If I understand correctly, you're trying to quit or launch Alfred when certain apps activate. What is the purpose of this? Is there a reason you're using AppleScript rather than using Keyboard Maestro's quit/activate actions?
Everything I said to @noisneil is true. No excuses. And I appreciate your great solution.
However, I had to stop Alfred perfectly because I used Photoshop at work.
I liked this and used it because all the other disturbing hot keys were invalidated.