Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

1 Answer 1

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 at 0:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.