How to switch focus to a window of certain name

I have the following macro I use to open a project quickly in my editor:


I want to extend so that if this project is already open, it will switch to it and not call the open action again as that will create a new window with the project.

In order to do this, I think I need to do an if check that will scan through all my active windows and check if anything that has text - web-test inside it.


Only problem is I don't know how I can do this. KM doesn't seem to provide a native action for this and I searched around and couldn't find any applescript or JXA to do this.

Would love any help on this. :orange_heart:

Hey @nikivi ,

I've never used VSC, but if the text web-test is in the title of any of its windows, something like this seems like it would work:


1 Like

This works indeed. Thank you!

Only thing I am curious about is why do I need to activate the app before triggering the Bring Window action. Without bringing VSCode as active app, bring window doesn't seem to work and I don't get why.


Oh never mind I got it. This is what I wanted:


KM is amazing.

1 Like

Hey Nikita,

By now you should know that you can drop an application on Apple's Script to find out if it is scriptable.

Drop the Keyboard Maestro Editor on it for a demonstration of how it works and looks.

Visual Studio Code definitely is NOT scriptable.

Save yourself some time next time.