Any Window Title of Any App

Is there a way to do "window title" checks or actions across all apps? Currently it seems that macros are restricted to either a specific app or "Front Application". But sometimes I don't know the application, for example it could one of several browsers. Also, sometimes app identifiers change (on update) and the macros breaks.

A couple examples of what I would like to do:
"Bring to front" "the window with the title Gmail" in "any app"
"If" "Any window title of" "any app" contains "window title text"

Not directly within Keyboard Maestro, no. Probably there is an AppleScript method.

This should do the trick. Let us know if it works for you.

##Macro Library   @Win List All Windows Visible to AppleScript


####DOWNLOAD:
<a class="attachment" href="/uploads/default/original/2X/0/0cb4f13e4b691447839974a0a76be1c6d8955f44.kmmacros">@Win List All Windows Visible to AppleScript.kmmacros</a> (6.1 KB)
**Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.**

---

###ReleaseNotes

Author.@JMichaelTX

**PURPOSE:**

* **List All Visible Windows for All Non-Background Apps**

HOW TO USE:

1.  Trigger this macro

TAGS:  @Window @App 

USER SETTINGS:

* Any Action in _magenta color_ is designed to be changed by end-user

ACTION COLOR CODES

* To facilitate the reading, customizing, and maintenance of this macro,
      key Actions are colored as follows:
* GREEN   -- Key Comments designed to highlight main sections of macro
* MAGENTA -- Actions designed to be customized by user
* YELLOW  -- Primary Actions (usually the main purpose of the macro)
* ORANGE  -- Actions that permanently destroy Variables or Clipboards,
OR IF/THEN and PAUSE Actions

REQUIRES:

1.  Keyboard Maestro Ver 7.3+ (don't even ask me about KM 6 support).
2.  El Capitan 10.11.6+
  * It make work with Yosemite, but I make no guarantees.



---

<img src="/uploads/default/original/2X/f/fdf04b22ffc801b7b088dfe9850d9e5f0320447d.png" width="581" height="833">
1 Like

This doesn't seem to catch the windows that are in other Mission Control workspaces. Perhaps there is a way to iterate over the workspaces in AppleScript? (without visibly changing the current workspace)
Thanks

Hey @XZF,

That would probably be because the windows in Mission Control aren't windows – they're buttons – and no Keyboard Maestro doesn't see them.

Vanilla AppleScript doesn't have access to Mission Control, but via UI-Scripting with System Events it can be made to. However, this can get quite complicated.

What exactly are you wanting to do?

-Chris

@ccstone,

... you mean that e.g. a Chrome browser window that is in another workspace is represented as a button?

I want to manipulate windows that are in other workspaces. Moving them to the current workspace, for example; or consolidating them in a particular workspace. Let's say I have five workspaces open, of which workspace 3 is active; and I want to move a Chrome window from workspace 2 to the current workspace. But I can't even see that window in my list of windows for the Chrome application.
Thanks.

Correct. That's how System Events sees them.

Unfortunately, you can't – not with Keyboard Maestro or AppleScript and System Events.

Apple doesn't provid an API for doing this, and any utility that is able to do so is “hacking” the macOS at some level.

Peter will only use public APIs for Keyboard Maestro for a variety of reasons, so unless Apple makes Mission Control more accessible it's unlikely that KM will ever support spaces.

-Chris