Here is an AppleScript that should help you. Open AppleScript Editor and save this as a script. I have modified the source that I found here to support taking arguments on the command line.
Use it like this:
osascript new_window.scpt http://www.google.com http://www.stackoverflow.com
Of course, replace the URLs above with your own URLs.
new_window.scpt
on run argv
tell application "Safari"
if (count argv) = 0 then
-- If you dont want to open a new window for an empty list, replace the
-- following line with just "return"
set {first_url, rest_urls} to {"", {}}
else
-- `item 1 of ...` gets the first item of a list, `rest of ...` gets
-- everything after the first item of a list. We treat the two
-- differently because the first item must be placed in a new window, but
-- everything else must be placed in a new tab.
set {first_url, rest_urls} to {item 1 of argv, the rest of argv}
end if
make new document at end of documents with properties {URL:first_url}
tell window 1
repeat with the_url in rest_urls
make new tab at end of tabs with properties {URL:the_url}
end repeat
end tell
activate
end tell
end run
You could even create an alias for this in Terminal and be able to use it easier. I would add the following to ~/.bash_profile
:
alias newwindow='osascript /path/to/new_window.scpt'
Call newwindow
whatever you want. Save .bash_profile
and restart Terminal for it to work.
In case anyone is looking for a similar solution for Google Chrome, here is a different take on the same idea.
chrome_new_window.scpt
on run argv
tell application "Google Chrome"
if (count argv) = 0 then
make new window
else
tell (make new window)
set URL of active tab to item 1 of argv
repeat with the_url in the rest of argv
open location the_url
end repeat
end tell
end if
set active tab index of first window to 1
activate
end tell
end run
It is simple. You don't.
I have MAC 2 months and Iv heard UX of MAC is gorgeous so I went for it. But for some strange reason MAC has 95% of UX realy awesome as I would expect the top UX to be BUT, there are still those 5% :( And I am not talking about some hard to use UX elements or hidden tasks. Those 5% are everyday usage UX errors MAC has. And when I say error I mean it, its not like I prefer Windows or Linux way, its that human has some "limitations" and for many tasks the "best" UX already exists but in Apple there sits some UX manager (propably few of them) and he thinks like this: "Hmm, we have to differ on as many levels as possible so we are not the same as competition" - so they take that UX, tweak those 5% of it, so it looks different.
How do I know that? Well ofc, I dont, but is there any other logical explenation for that and theese other examples:
App window control buttons on the left side? Yes its briliant - your mouse moves are limited, so your work is faster. It takes a while if ur not used to it, but it is realy good idea and its faster. But now - what will those 3 buttons acutually do? Quit app / minimize app / maximize app? Noooo, that would be too easy for everyone, lets make it different, lets make close button to close only "windows" of the app not entire app and lets leave the top bar of app hanging there so everyone can switch to it and be confused where is his focus, cause he sees the app below but it doesnt have focus right...? Minimize? Yea, it does minimize - did they notice, that minimize and close does the same thing? (It actually doesnt - but the result is the same, so "why....?) Nope they didnt. And maximize? No, why would someone want to maximize, lets make it fullscreen, cause thats the button every person needs, right...? But one brave manager raised hand and said: "But there are still ppl who actually want to maximize the window". "Hmm, ok lets keep it there with some wier shortcut, BUT lets not maximize to cover all screen, I think it is better to maximize only what we think is the best for the user. With more windows opened at once, its gonna be so messy but we dont care about it. And heh, guys, Iv got an idea, lets make a nice little prank, I think it would be hillarious to leave 1px space at the top and bottom of the screen, you know just to have fun of them :D. Every user who spends 1500$ or more will appreciate that! Its gonna be so funny to see them in their chairs asking why would someone do that :D"
Best Answer
System Events only includes windows in the current space / desktop:
I don't know any way to convert a System Events window object to a Safari window object though, apart from hacks like this:
tell application "System Events" to value of attribute "AXIdentifier" of window 1 of process "Safari"
does not correspond totell application "Safari" to id of window 1
.