how can I set a url to a specific tab in AppleScript to avoid opening new tabs every time the script is run?
tell application "System Events"
activate application "Safari"
key code 19 using command down -- cmd 2 open a second tab or activate it if open
open location "http://example.com"
end tell
This works fine as long as one of these are true
1. the 2nd tab does not yet exist in which case it will make the 2nd tab and open the url in that location. Or..
2 If the 2nd tab already exists, it will activate the 2nd tab and reload the page as long as the 2nd tab is already at the website location we want it to be.
But if you have say 2nd or more tabs open and you run this, if the 2nd tab isd not already on the url you want it to be it will activate the 2nd tab and then open the website location in a new tab.
What I would like it to do is something like
key code 19 using command down
set location of current tab of window 1 in application safari to "http://example.com"
But this obviously doesn't work. So how can I tell Safari to only use the tabs I specify instead of opening new ones every time?
iMac, OS X El Capitan (10.11.3)