Bring a specified window of an app to the front (if there are more than one window)

Well, actually that is a change. You said before that no Chrome window was activated.

Are you using my Macro exactly as is with no changes?
What versions of macOS, KM, and Chrome are you running?

Can anyone else reproduce the behaviour that @kreal is reporting?

After some exhaustive, frustrating testing, I have found this:

  1. This only fails when the macro is triggered from the Chrome window that does NOT contain the target URL
  2. Works fine triggered from the KM Editor
  3. Works fine when script is run from Script Debugger.

My only tentative conclusion is that this is somehow related to the other bug/change produced by Google in their latest Chrome update to not properly identify the frontmost window name.

@peternlewis and Chris (@ccstone) , any thoughts?

I am using the exact macro you provided above without editing.

MacOS Mojave, Google Chrome Version 69.0.3497.100, KM 8.2.4

You are right, it fails when the macro is trigerred from the Chrome window.
There is another scenario that fails:

Chrome 1st window is opened in main screen
Chrome 2nd window (which containts the target URL) is opened in 2nd screen
Trigerring macro from 3rd screen from any other app makes the Chrome tab active but doesn't make the 2nd Chrome window active.

I guess finding 1st, 2nd, 3rd etc browser window OR incognito window and make it frontmost would solve my question.

I've confirmed with another experienced user that Chrome is currently broke. So, I'll not spend any more time on this until it is fixed.

1 Like

Is there a way to perform this action in Safari?
I was unable to activate a Safari window with the target URL.

Didn't you already ask, and get an answer to this question:

It does work, finds and brings a tab with the target URL frontmost but it doesn't make the Safari window with the target URL active.
As you previously said - Chrome is broken and and it's not possible to activate a window with searchable tab so i am wondering is Safari also broken or we need to modify the script? As the script doesn't activate the window after selecting a tab.

I don't know if something in the macOS and/or Safari has changed, but it used to work fine. The code to bring the Safari window/tab active is already in the script, at the bottom:

if (winTitle ≠ "") then
  tell application "System Events"
    tell application process "Safari"
      set oWin2 to first window whose name is winTitle
      set focused of oWin2 to true
      tell oWin2 to perform action "AXRaise"
    end tell
  end tell
end if

So, I have nothing else to offer at this point.

Thank you for the help and for your time @JMichaelTX :+1:
I will work on a macro using the suggestions provided above and will share it after finding a solution.