How can I set a url to a specific tab in AppleScript to avoid opening new tabs everytime the script is run?

Tell application "system events".

activate an application "Safari".

key code 19 using the command to cmd - down 2 opened a second tab or activate it so open

Open the location "http://example.com".

tell the end

It works fine as long as one of them are real

1. the 2nd tab does not exist yet in this case it will be the 2nd tab and open the url in this place. Or...

2 If the 2nd tab already exists, it will launch the 2nd tab and reload the page until the 2nd tab is already at the location of Web site, we want to be.

But if you say 2 or more tabs open and you run this, if the 2nd tab the DSI not already on the url, you want it to be it will activate the 2nd tab and then open the location of the site in a new tab.

What I want is something like

Code 19 - key using the command down

Set the location of the active tab for the 1 in safari request to "http://example.com".

But this obviously doesn't work. So, how can I know Safari to use only the tabs that I said rather than open new ones every time?

You can try something like that.

tell application "Safari"
    if not (exists document 1) then make new document
    tell window 1
        if not (exists tab 2) then make new tab
        set current tab to tab 2
        set tab 2's URL to "http://www.google.com"
    end tell
end tell

Briefly tested with Safari on OS X 10.6.8 5.1.10.

Kind regards

H

Tags: Mac OS & System Software

Similar Questions

  • How to focus the tabs in Safari with AppleScript and avoid opening new

    Tell application "system events".

    activate an application "Safari".

    key code 19 using the command to cmd - down 2 opened a second tab or activate it so open

    Open the location "http://example.com".

    tell the end

    It works fine as long as one of them are real

    1. the 2nd tab does not exist yet in this case it will be the 2nd tab and open the url in this place. Or...

    2 If the 2nd tab already exists, it will launch the 2nd tab and reload the page until the 2nd tab is already at the location of Web site, we want to be.

    But if you say 2 or more tabs open and you run this, if the 2nd tab the DSI not already on the url, you want it to be it will activate the 2nd tab and then open the location of the site in a new tab.

    What I want is something like

    Code 19 - key using the command down

    Set the location of the active tab for the 1 in safari request to "http://example.com".

    But this obviously doesn't work. So, how can I know Safari to use only the tabs that I said rather than open new ones every time?

    Hello

    To set the focus to a tab: use the "class" property of the window tab.

    To open a URL: use the URL property of the tab instead of the command "open location".

    As this script:

    -------

    set theUrl to "http://example.com".

    Tell application "Safari".

    otherwise (there is an active tab from the front window) and then make new document - if no window

    the window before saying

    If (count the tabs) = 1 then - open URL in new tab

    set the active tab (to make the new tag at the end of the tabs with properties {URL: theUrl})

    -2 or more tabs

    the current value of the tab 2 - the second tab of the focus

    the value URL of the tab current theUrl - change the URL of the second tab

    end if

    tell the end

    tell the end

    -------

  • How can I set up a daily playlist for podcasts on Iphone 5

    How can I set up a daily playlist for podcasts on Iphone 5

    Without further explanation of what you want the list of reading to do, it is difficult to suggest something specific...

    You can just go down the list of the Unplayed episodes and start listening to. That you have finished playing the episode, it disappears from the list, so it is always "fresh" next time.

  • At the launch of Thunderbird, how can I set a password that prevents viewing of my emails if someone uses my computer?

    At the launch of Thunderbird, how can I set a password that prevents viewing of my emails if someone uses my computer?

    100% this addons can help you
    https://addons.Mozilla.org/en-us/Thunderbird/addon/master-password/

    Look at my Thunderbird when I open

  • How can I set the default download locations

    How can I set the default download locations?

    You can watch here:

    • Tools > Options > general: downloads
  • It's my 1st iPhone. How can I set up my voicemail? Thank you!

    It's my 1st iPhone. How can I set up my voicemail? Thank you!

    nonnamac wrote:

    It's my 1st iPhone. How can I set up my voicemail? Thank you!

    To set up Visual voicemail on your iphone, you will need to contact your cell phone provider to implement.

  • How can I set a password for firefox so that everyone must enter the password before running firefox

    My younger sister run my firefox just to this afternoon (she origin use IE), and she saw something that is not visible. How can I set a password for firefox so that everyone must enter the password before running firefox?

    Another option is the master password + extension.

    You must first make sure that Firefox uses a master password, for more details on how to do that see use a master password to protect stored logins and passwords. Then with the master password + extension in its options, go to the getting started section and make sure that "ask for password at startup" and "Exit if cancelled" is selected both.

    As with all extensions, this protection is quite weak and can be bypassed if start you Firefox in safe mode that disables extensions.

  • I remember my Skype ID but I don't remember my password? How can I set a new password?

    I remember my Skype ID but I don't remember my password? How can I set a new password?

    If you are still using the same email account, that you used when you created your Skype name, you can have your password of rest through this link:

    https://login.Skype.com/account/password-reset-request



    Please note: I do not answer requests for help via private Message.

  • How can I set contact ringtone purchased on multiple devices?

    I have a few iPhones: 5, 6, and 6... How can I set ringtone touch purchased on iTunes Store on multiple devices?

    Because you can not download again for free, you will have to try to sync them with your devices, see this article:

    Download your purchases past - Apple Support

  • How can you set it up to play 2 songs always together?

    How can you set it up to play 2 songs always together in iTunes, downloaded on your ipod?

    You can reach consecutive tracks whole CD you rip a CD, a file which has two songs, otherwise you can not really do. There is an iTunes feature called Shuffle by grouping, but it is not the iPod.

    TT2

  • How can I set up my new Officejet Pro 8600 more printing on paper photo 4 x 6?

    How can I set up my new Officejet Pro 8600 more printing on paper photo 4 x 6?  I'm running on Windows 7 64 bit.

    It's strange.  Looks like you have a second paper tray and put it to the default tray.  The second paper tray only supports the types of paper that show on your list.  It's strange because unless you have purchased a second tray paper, plus model has one.  Does only the high-end model.  Other than that, only certain types of media can be duplex, so if you have double-sided printing, it can limit the selection.  I'll watch what else could be the cause and get back to you.

  • How can I set the time axis on my waveform table to show run time that is to say whenever I start the program I should have 0 as the starting point

    How can I set the time axis on my waveform table to show run time that is to say whenever I start the program I should have 0 as the starting point. I've been messing around with the without success. I'm under Labview 2012.

    Thank you!

    Townes wrote:

    I can't understand what you mean. I have no formal training with labview. It took me a long time to write the simple program that I joined. Any guidance would be greatly appreciated!

    Its pretty normal for a beginner to take the time to write code. Right-click the map of waveform > Create > property node > historical data, you will get a property node, keep this at the beginning of the code and create a constant. You can also go to the VI properties and > run and select "clear indicators when it is called.

    I recommend you to go through the basic materials of LabVIEW which will give you an understanding on the basics of bases/components of LabVIEW.

  • How can I set up a website that charges a small fee when landed on?

    Original title: Mother Mary

    How can I set up a website that charges a small fee when landed on? I have something to show to the world & I, that the award is not unreasonable

    [Moved from the community centre of Participation]

    First of all, this is not the arena for that. Do some research on Google and Bing.

    Then, if someone has to pay a fee, it should be their choice, whether they pay or not. It'snot automatic. You will need to research the acceptance of credit card, merchant gateways, set bit. And it won't be cheap.

  • How can I set up a wifi connection?

    Programs Application Applications Apps game games Legacy Crash crashes Hang Application Compatibility hangs

    How can I set up a wifi connection

    Hello jamesjones882

    Please see the link below for setup of wireless networks. Thank you.

  • How can I set English (United Kingdom) as the language for keyboard

    original title: How can I set English (United Kingdom) as main language so that my keyboard does what it should?

    How can I set English (United Kingdom) as main language so that my keyboard does what it should?

    Monday, April 23, 2012 14:51:19 + 0000, TrevorConn wrote:

    How can I set English (United Kingdom) as main language so that my keyboard does what it should?

    Change the keyboard layout in Control Panel | Tab languages and keyboard language and region | Change keyboards button.

    Ken Blake, Microsoft MVP

Maybe you are looking for

  • extensions.blocklist.Enabled; False

    extensions.blocklist.Enabled; Falseprevents the extensions that you install personally be disabled. If you have an a bad mozilla should rather provide a delete button for this particular plugin that performs the actions required to destroy. Why would

  • installation of Palm Desktop 6.2.2 to a new PC

    I currently use Palm desktop 6.2.2 to store addresses and memos on my Windows 7 64-bit Pentium computer.  I have not HotSync to a portable device. I'm about to buy a new PC with an Intel i3 or i5 (Quad Core) processor.  I have to make a decision betw

  • Satellite A200 - strange question after updating the graphics driver

    The problem is with the driver Mobile Intel (r) 965 Express Chipset Family. System: Grand VISTA 32 bit Home Premium Service Pack 1. Laptop: Satellite A200. I have installed the new driver of this (suggestion by Toshiba TEMPO) source: http://CE.comput

  • How can I get a glimpse outside my files in pictures... can anyone advise? Merry Christmas to all!

    How to make a glimpse outside of my folders in the photos area there are so many it would help... had to return to the defalt settings & don't know how to get the tray on! .. can someone advise? Merry Christmas to all!

  • HP-M7-J120DX: upgrade details for HP M7-J120DX

    Hello I have a j120dx m7 and you want to change the disc. Already, I have the disc and it imaged with Acronis Disk clone. My question is how do the existing hard disk. I had several portable hp and have made several improvements to the player.  The v