I am writing an AppleScript in which I need to get the number of the current window of Google Chrome and open a new tab in it. I want something like this (pseudo code):

set curWindNum to the current window of Google Chrome // returns something like "window 4" or just "4"
open a new tab in window curWindNum

How do I do this?

  • Do you have to return the number of the current window? Or can you just get the window? Apr 20, 2012 at 22:27
  • @ruddfawcett I need to be able to close the tab when I'm done and make sure that the script closes that tab, not some other tab.
    – daviesgeek
    Apr 20, 2012 at 22:30
  • Hmmm... Okay, so you want to assign a number to the current active window of Chrome, and then open a new tab in that window. You then want to close that tab? Am I understanding your question correctly? Apr 20, 2012 at 22:31
  • @ruddfawcett The full script will open a tab in the current active window of Chrome, load a webpage, then close the page. It will then repeat that with about 25 URLs.
    – daviesgeek
    Apr 20, 2012 at 22:33

1 Answer 1


Here is the beginning of a very simple AppleScript that will open a new tab at the end of the current window, and then it will load a URL. The script will wait 5 seconds (to allow the page to load) and then it will close that tab. I am still working on it, but this should do it for you. Let me know if you need some more help, or if you would like me to change something. Here is the script:

tell application "Google Chrome"
set ActivePage to window 1
set Tab1 to make new tab at end of tabs of ActivePage
set URL of Tab1 to "http://google.com"
delay 5
close active tab of window 1
end tell
  • No problem! I hope that it works for you! Apr 20, 2012 at 22:55
  • Works like a charm!
    – daviesgeek
    Apr 20, 2012 at 22:59

You must log in to answer this question.

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