4

On a normal day I have several different windows open of all my applications. But for the sake of simplicity I will name one simple example:

  1. Chrome A left side of the screen (documentation)
  2. Chrome B right side of the screen (viewing result)
  3. Terminal A left side of the screen (the webserver, useful when viewing results)
  4. Terminal B right side of the screen (code window, I need the documentation chrome when using this).

Is there any keyboard shortcut to move Chrome A to the foreground without moving Chrome B to the foreground as well?

  • With Apple-tab it switches the application and move both of them to the foreground.
  • With Apple-` it switches the windows between the application so that doesn't work either.

Is there any keyboard shortcut to do this?

Desired behaviour: show Chrome A with Terminal B and Chrome B with Terminal A.

Note that I am looking for keyboard shortcuts, NO mouse clicks :)

1 Answer 1

4

You can use Witch to select and raise only specific windows.

This would usually focus the second window in creation order:

set text item delimiters to linefeed
tell application "Google Chrome"
    reopen
    do shell script "sort -n <<< " & quoted form of (id of windows as text) & " | sed -n 2p"
    tell window id (result as integer) to set index to 1
end tell
tell application "System Events" to tell process "Google Chrome"
    perform action "AXRaise" of window 1
end tell
do shell script "open -a google\\ chrome"

set frontmost to true and activate would also raise other windows. set index to 1 doesn't actually raise the window, but it makes it appear as window 1 to System Events, which can AXRaise it. See this answer for different ways to assign shortcuts to scripts.

This would select a window by the URLs of tabs:

tell application "Google Chrome"
    repeat with w in windows
        tell w
            repeat with t in tabs
                if URL of t contains "google" then
                    set index to 1
                    exit repeat
                end if
            end repeat
        end tell
    end repeat
end tell
2

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .