Ask Different is a question and answer site for power users of Apple hardware and software. 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

Ok, I realize this is asking for the impossible. I habitually have about 4 Chrome windows open. On linux, I have a system set up so I have a different keyboard shortcut to switch to each window, so I can jump to the correct one really quickly.

Is there possibly a way to do this on OSX? I'm willing to write moderate amounts of code if necessary to implement this, 'though I should probably head over to StackOverflow if that looks like it will be needed.

share|improve this question
How would you identify the windows or decide which one to focus? Do you keep them on different spaces or something? – user495470 Oct 6 '12 at 6:29
No, not difference spaces. Some other attribute of the window might be possible, though, like the order in which they were created. That's the way it works on linux. – Derek Thurn Oct 6 '12 at 16:52
How about creating a macro which would select the Window menu and then click at (X,Y) for the window you want? – timothymh Oct 6 '12 at 19:35
up vote 1 down vote accepted
    set text item delimiters to linefeed
    tell application "Google Chrome"
        do shell script "sort -n <<< " & quoted form of (id of windows as text) & " | sed -n 3p"
        set w to window id (result as integer)
        set b to bounds of w
        set t to title of w
    end tell
    tell application "System Events" to tell process "Google Chrome"
        window 1 where position is {item 1 of b, item 2 of b} and title is t
        perform action "AXRaise" of result
        set frontmost to true
    end tell
end try

Windows that were created later usually have a larger id. If the script is run when there's no second window, there won't be an error dialog because it's wrapped in a try block.

You can give the scripts shortcuts with FastScripts or by creating Automator services.

share|improve this answer
Thanks a ton! This is exactly what I wanted. I ended up calling out to a custom python script instead of using UNIX utilities, but this is pretty much what I'm now doing. – Derek Thurn Oct 12 '12 at 6:36

Your Answer


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.