Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8505755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T02:24:37+00:00 2026-06-11T02:24:37+00:00

Do you guys know how to activate the n-th Google Chrome window with Applescript?

  • 0

Do you guys know how to activate the n-th Google Chrome window with Applescript? For example, if I have three Google Chrome windows opened, how do activate the second?

I’ve tried many different combinations, e.g.:
tell tab 3 of window 2 to activate

I’ve also noticed that:

tell application “Google Chrome”
tell window 1 to activate
end tell

and,

tell application “Google Chrome”
tell window 2 to activate
end tell

produce the same results, it only activates the last window
opened, Is this a bug?

Thanks in advance 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T02:24:38+00:00Added an answer on June 11, 2026 at 2:24 am

    tl;dr

    Using set index of window <n> to 1 isn’t fully effective in that it doesn’t truly activate the window – it does make it visible, though.

    Workarounds (examples assume you want to activate window 2):

    • Yar’s answer offers a pragmatic workaround, though it’s not entirely clear why it works. It does, however, have the advantage of not requiring the calling application to be authorized for assistive access, unlike the following solutions.

    • user495470’s answer hints at a robust and generic solution that also works with non-AppleScriptable applications:

      tell application "System Events" to tell process "Google Chrome"
          perform action "AXRaise" of window 2
          set frontmost to true
      end tell
      
    • Alternatively, use the AppleScript handler defined below as follows:

      • tell application "Google Chrome" to my activateWin(it, window 2)

    While adayzdone’s answer should work and almost does, there is a catch – which may or may not be a problem (observed on Chrome 21.0.1180.89 on Mountain Lion) [update: still applies as of Chrome 47.0.2526.106 on OSX 10.11.2]:

    While the solution will show the desired window as the front window, Chrome will NOT treat it as the front window if a different window was previously active. You can tell by the inactive close/min/zoom title-bar buttons, by what window title the checkmark is next to, and by the fact that keyboard shortcuts such as Cmd-L will not apply to the desired window.

    If your next action will be to click somewhere on the window anyway, this may not be a problem, as such a click will fully activate the desired window.

    Otherwise, you can employ a reasonably robust GUI-scripting workaround (gratefully adapted from a generic solution here):

    Update: Sadly, the problem of not actually activating the window whose index you set to 1 seems to affect ALL apps (experienced on OS X 10.8.3).
    Here’s a generic function that properly activates a given window in a given AppleScriptable app using GUI scripting.

    # Activates the specified window (w) of the specified AppleScriptable
    # application (a).
        # Note that both parameters must be *objects*.
    # Example: Activate the window that is currently the 2nd window in Chrome:
    #   tell application "Google Chrome"
    #       my activateWin(it, window 2)
    #   end tell
    on activateWin(a, w)
        tell application "System Events"
            click menu item (name of w) of menu 1 of menu bar item -2 ¬
                       of menu bar 1 of process (name of a)
        end tell
        activate a
    end activateWin
    

    On a side note, what the OP tried – e.g., activate window 1 – seems to be broken in ALL apps on OS X 10.8.3 as well – while the underlying application is activated, the window spec. is ignored.

    Here’s the original, more didactic code:

    tell application "Google Chrome"
        # Each window is represented by the title of its active tab
        # in the "Window" menu.
        # We use GUI scripting to select the matching "Window" menu item
        # and thereby properly activate the window of interest.
        # NOTE: Should there be another window with the exact same title,
        # the wrong window could be activated.
    
        set winOfInterest to window 2 # example
        set winTitle to name of winOfInterest
    
        tell application "System Events"
            # Note that we must target the *process* here.
            tell process "Google Chrome"
                # The app's menu bar.
                tell menu bar 1
                    # To avoid localization issues,
                    # we target the "Window" menu by position - the next-to-last
                    # rather than by name.
                    click menu item winTitle of menu 1 of menu bar item -2
                end tell
            end tell
        end tell
        # Finally, activate the app.
        activate
    end tell
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I bet you guys know Google Chrome browser, yeah it comes from Chromium open-source
Sorry guys, didn't know how to word this one. Still learning jquery and have
A simple quiz: Probably many guys know this before, In my app there is
Do you guys know if Google calendar has any kind of push services? Is
You guys know in Pastebin how according to the selected language, the code is
Do you guys know about an ajax toolkit (or something similar to the m$-ajaxtoolkit)
guys I know this question is very basic but I've met in few publications
Guys I know this question is silly but just to make sure: Having in
I would like to know what guys are using to make diagram of your
hi guys I wanted to know, is there a way to not display my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.