Applescript + Safari open URL

Discussion in 'Mac Programming' started by Iceman332k1, May 14, 2010.

  1. Iceman332k1 macrumors newbie

    Joined:
    Dec 15, 2009
    #1
    I need to make an Applescript that opens Safari (or switches to it if it's already open) and then opens a webpage. Just something basic like www.hulu.com or www.gmail.com. I want to bind it to a tap on my new magic mouse, but for the life of me I am unable to find a script online that I can get to work. Again, I do not need it to do anything after opening the webpage.

    Thanks
     
  2. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #2
    Code:
    tell application "Safari" to open location "http://www.hulu.com/"
     
  3. Iceman332k1 thread starter macrumors newbie

    Joined:
    Dec 15, 2009
    #3
    Confused

    I'm sorry, but could you type it out as it should read as an applet? I'm honestly having trouble and this is my first attempt at applescripts
     
  4. TuffLuffJimmy macrumors G3

    TuffLuffJimmy

    Joined:
    Apr 6, 2007
    Location:
    Portland, OR
    #4
    Open AppleScript Utility (It's somewhere in the Applications folder I believe).

    Type the previous code with hulu.com replaced with whatever URL you want to go to.

    Save it as an Application.

    Now you have an Application.

    Double click the application to go to the URL.
     
  5. rsrs922 macrumors newbie

    Joined:
    May 31, 2012
    #5
    Reply

    If you don't want it to always open in safari, you can just remove the "tell application safari part"
    Make sure the browser you want to open it in is your default browser. Then in AppleScript, type:
    Code:
    open location "www.google.com"
    You can change the url to whatever you want.
    Then press "command shift s" to save as and select application. Now when you open the app, the url will open.
    Hope this helps!
     

Share This Page