Bring One Application Window with a Specific Title to the Front?

In the Mac world, where possible, you avoid an installer unless necessary. And generally it is only necessary if the application wants to mess with your system, which makes an installer something of a warning sign for users.

Indeed, Keyboard Maestro does not “install” anything. Once you quit Keyboard Maestro and the Keyboard Maestro Engine your system is entirely unaffected by its presence.

Also on the Mac, generally for non-document oriented applications, information is stored in various folders in the ~/Library folder, which in turn is hidden from the user (in the Finder, hold the option key down and select Library from the Go menu). I am ambivalent about the decision by Apple to hide the folder, but it is certainly true that for most users, mucking around in the Library folder is a good way to mess up your system.

As described in the documentation, Keyboard Maestro stores its information in:

  • ~/Library/Application Support/Keyboard Maestro folder - your macros, variables, clipboards, and pretty much all your data is stored here.
  • ~/Library/Logs/Keyboard Maestro folder - just logs for the editor and engine are here.
  • ~/Library/Preferences/com.stairways.keyboardmaestro.* 3 files - general preferences, window settings, and such.

plus the Keyboard Maestro.app application, which can be placed anywhere, but should normally be placed in either /Applications or ~/Applications - and with Sierra it is important that you move it somewhere out of the Downloads folder because yet another bizarro Apple security feature will otherwise make automatic updates fail.

There are tools which will delete an application and all its settings, but frankly I would not recommend them.

It still seems pretty heavily used:

  • Finder in column view
  • Mail
  • Preview
  • Automator

BTW, the reason that the action selector covers the first two columns of the window is simply a requirement of screen space - if you all had iMacs, the action selector would be a drawer on the right side of the window, but that simply would not work on MacBook sized screens.

It’s probably not useful to discuss Keyboard Maestro UI in a topic on bringing windows to the front. If folks which to discuss it, especially if there is actually something constructive to say rather than just "I don't like it" or that it is not intuitive (which is fine to say, but does not lead to an improvement), then a new topic would be more appropriate.

1 Like

A late hello. I realize this is an older topic/ post, however there is no mention of what version JMichaelTX’s answer relates to- guessing 7.x.

I am a brand new user and am ‘stuck’ at version 6.4.8 due to my (Mac) OS version 10.9.5. I am not seeing “Bring Front Window to front”. Am guessing it is a version issue. This is the very first macro I am trying to build and am not finding a way to do it. Is there a different action in 6.x?

It also looks like from that same screenshot that there are many more Actions available. Is that true? Or is what I am seeing user created?

I am hoping that KM can replicate all of my macros so I can (seamlessly) replace our current keyboard shortcut app across the office.

Thanks in advance.

Bring to Front is a variant of the Manipulate Window action.

So add the Resize a Window or any of those window actions, and then look at the popup menu for the action. I cannot remember if Keyboard Maestro 6 had Bring to Front in it, but I'd be surprised if it didn't. Yes, according to the version 6 documentation, it does have Bring to Front as an option.

Even in Keyboard Maestro 6, there were many actions, and many actions also have many variants.

Keyboard Maestro can do pretty much whatever any other macro app can do with very few exceptions.

Thank Peternlewis. Will dig around some more. I would be surprised if it wasn’t there from what I’ve read about KM.

The bulk of this Post seems to be more about getting KM to work. Maybe those parts are better located elsewhere?

Anyway, back to the original question (tho maybe this is another case of KM misbehaving and the rest of the posting ARE need here...) of bringing a particular app's window to the front:

I have this action (which I also tried the "windows with title containing" option):

For this window in TextEdit:

I'm using in this Macro:

I'm activating by clicking on "Close Cheat Sheet" in this palette in Safari:
13%20AM
Which switches to TextEdit then stops without bringing the window forward.

I've also tried a conditional pause but keep getting a false for the condition being met so it seems KM is having an issue seeing that window.

When I click on the gear on the Bring Window(s) With Name Matching action and select Help I'm taken to the Wiki here:
https://wiki.keyboardmaestro.com/action/Manipulate_a_Window?redirect=1

where I can't find something to resolve this. Help please.

I have restarted KM Engine, restarted KM, and shutdown the iMac all to no avail.

Ultimately I looking to be able to open and close a pic from a palette. The open part works.

Thanks!

Hey Bern,

Somehow I doubt your window title matches what you use in the macro.

Try switching to contains.

If that works then find out what the actual window title is.

-Chris

If you just want to close this window, there's no need to activate the app, bring the window to the front, or type a keystroke. All you need is a single Manipulate a Window action:

Close Cheat Sheet.kmmacros (1.8 KB)
image

I created a TextEdit document with the same name to test this, and can confirm it works fine with the "containing" condition rather than "matching".

Hey @gglick @ccstone

In my stumbling around I misled you. That doc is a screenshot from @JMichaelTX Forum Cheat Sheet (How to Use This Forum) topic that opens in Preview not TextEdit. Changing the target app resolved it using any of the three title parameters.

Seeing that I can close a doc without all the other actions made my clumsiness seem almost purposeful. Making your partner look good even when he's off is a mark of being skillful, adult, generous, and kind.

image
Thank you both for allowing me to borrow your light to find my way!

2 Likes

Conversely, is there a way to switch to a window whose title does not contain certain text?

Use case: I need to select the currently open plugin window in Logic before running a macro. The plugin window title changes depending on the track it's on, but the other window titles always include " - Tracks" or " - Mixer".

Hey Neil,

You can do that with AppleScript:

--------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2021/07/15 19:51
# dMod: 2021/07/15 19:51 
# Appl: Finder, System Events
# Task: Bring the Window Whose Name Does NOT Contain “Mixer” Or “Tracks” to the Front.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @Finder, @System_Events, @Window, @Front
--------------------------------------------------------

tell application "System Events"
   tell application process "Logic Pro"
      set winList to windows whose name does not contain "mixer" and name does not contain "tracks"
      if length of winList = 1 then
         set winRef to item 1 of winList
         tell winRef
            perform action "AXRaise"
         end tell
      end if
   end tell
end tell

--------------------------------------------------------

It's possible with a Keyboard Maestro native action too, but you need a sophisticated understanding of how to use a negative-lookahead regular expression.

Bring Window Whose Name Does NOT Contain “Mixer” or “Tracks” to Front v1.00.kmmacros (5.7 KB)

On the other hand you could brute force it by getting a list of all the windows Keyboard Maestro can see in the given app, parse the list, and choose the window title NOT containing the undesired strings.

(This method would be more available to the average user.)

List Windows Keyboard Maestro Can See v1.1

-Chris

2 Likes

You, sir, are awesome! The AppleScript one works perfectly! Thankyou! :slight_smile:

1 Like

Here's slight adjustment to your regex-based idea. There seems to be an issue with KM 'seeing' Logic Pro plugin windows at the moment, but I've tested with other apps and it does work.

Non-Matching Window To Front.kmmacros (22 KB)

Macro screenshot