Is it possible to use AppleScript to open a link in a new tab in Safari?
相关问题
- Xcode debugger displays incorrect values for varia
- Is there a way to report errors in Apple documenta
- Advice for supporting both Mac and Windows Desktop
- Avoid cmake to add the flags -search_paths_first a
- installing packages for python 3
相关文章
- 现在使用swift开发ios应用好还是swift?
- Visual Studio Code, MAC OS X, OmniSharp server is
- xcode 4 garbage collection removed?
- IntelliJ IDEA can't open projects or add SDK o
- Automator: How do I use the Choose from List actio
- Safari blocks play() on video despite being called
- ImportError: No module named twisted.persisted.sty
- How can I vertically align my status bar item text
You can try following approach:
Also u can combine usage of Apple script within FastScript (free for 10 shortcut)
To add your script - just save script in
/Library/Scripts
. After you will be able to set some shortcut for new script.If you want to open new Window than new tab u can play within next:
Note: you need to allow AppleScript to use specialCapabilities in security settings in this case.
I can't comment :-/ so I will answer to say that Tim's answer (above) works as of OS X 10.8.5. This one-line version of his script also works:
Arrgh -- the one line is overflowing. Here it is without the code tags:
tell window 1 of application "Safari" to set current tab to (make new tab with properties {URL:"http://www.stackoverflow.com"})
I think this also does what you asked for, but it is much shorter and is less browser-specific:
This will open the specified URL in your default browser. And if you explicitly want to open it in Safari, use this:
Worked for me in Safari v.11
It's been a while since a new answer's been posted here. I think this is the optimal way to do this. It will open Safari if it's not open, create a new window if there are no windows open, and add the tab to the current (or newly created) window.
This should usually create a new tab and focus it (or focus an existing tab if the URL is already open):
It opens a new window if "Open pages in tabs instead of windows" is set to never though.
tell application "System Events" to open location
doesn't work with some URLs that contain non-ASCII characters:This opens a new tab even when new pages are set to open in windows:
set index to 1
doesn't raise the window, but it makes the window appear aswindow 1
to System Events, which canAXRaise
it.