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

I want to have an application open a new window in the current space without switching to a space in which a window is already open, but I want to keep the

When switching to an application, switch to a space with open windows for the application

setting in System Preferences > Mission Control.

In other words, I want to tell an application to open a new window directly, without first telling it to activate.

How can I do this with AppleScript (if possible)?

share|improve this question
up vote 6 down vote accepted

Some applications have an action for opening a new window in their Dock context menu.

Other options for different applications:

tell application "TextEdit"
    make new document
end tell

tell application "Safari"
    make new document at end of documents with properties {URL:""}
end tell

tell application "Terminal"
    do script ""
end tell

tell application "System Events" to tell process "iTerm"
    click menu item "New Window" of menu "Shell" of menu bar 1
    set frontmost to true
end tell

tell application "Google Chrome"
    make new window
end tell
share|improve this answer
Awesome! Do you know of similar ones for Chrome and iTerm? – Will Feb 13 '13 at 6:14
Great, thank you very much! Incidentally, how did you find those commands? Is there easily-accessible documentation? – Will Feb 13 '13 at 21:52
Thanks! Just a note for the quick copy/pasters (like myself): activate after making a new Chrome window to bring the new window (all windows actually) to the front. - All the other examples here include some form of activation. – Joel Mellon Sep 27 '13 at 21:23

You must log in to answer this question.

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