Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 :)

share|improve this question
up vote 2 down vote accepted

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
share|improve this answer
    
Awesome, thank you very much for the great response! – Wolph Apr 24 '13 at 1:28
    
Starting from 10.9 Mavericks, perform action "AXRaise" of window 1 will require explicit permission to run. This message will appear: "Your App would like to control this computer using accessibility features." – bfred.it Jul 12 '14 at 0:53

You must log in to answer this question.

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