alvin alexander

AppleScript Safari URL tip: How to open multiple URLs in Safari tabs

Well, I set out to write a simple tip on how to activate a Mac application using AppleScript, and I ended up writing a program to open a list of URLs in separate tabs in Safari using AppleScript. (Yeesh, I really took a detour. Oh, well.)

Without any further ado, here's the source code for this AppleScript program:

Brief description of the code

Here's a brief description of what this AppleScript program does:

  • urlList is a simple list with the URLs I want Safari to open.
  • The repeat statement starts the loop.
  • I'm clicking File :: New Tab using the System Events because I can't figure out how to get this to work by calling Safari directly. (I'm currently using Safari 3.0.3.)
  • The keystroke command types the URL into Safari.
  • key code 36 is needed to hit the [Enter] key.

Again, I had to take a few extra steps here because I couldn't script the tabs in Safari directly. Ideally code like this would have worked inside the tell application "Safari" statement:

Hopefully that support will be available in the future, or, if I'm mistaken, please send me an email and I will correct this program.

Help keep this website running!

  • How to open a macOS Terminal in the current Finder folder
  • AppleScript tip: script a program that isn't scriptable
  • AppleScript tip: if/then syntax
  • Mac OS X Finder FAQ: How to open the Finder from a Terminal window
  • Mac AppleScript Finder: How to put the path of the current Finder window on the clipboard

books by alvin

  • Scala Either type: How to get the value out of an Either
  • In dreams, light switches don’t work
  • ZIO 2: Processing ZIO command line arguments
  • ZIO 2: A ZIO.timeout interrupt example with ZIO.attempt
  • ZIO 2: Using Either with ZIO in a Scala for-expression

applescript safari open url

Using AppleScript to open a URL in Private Browsing in Safari

  • Posted 24 June 2020
  • Tagged with applescript , macos , macos:safari

I have a bunch of automations that open URLs.

If I want to open a regular window in Safari (my default browser), I have a variety of options – I can use open(1) on the command-line, or the webbrowser module in Python, or with AppleScript, or probably half a dozen other methods I haven’t thought of.

If I want to open a private browsing window, my options are more limited. The Safari AppleScript dictionary doesn’t know about private browsing, and all the other approaches I’ve seen are just passing Safari the URL to open. They can’t give it any instructions beyond “please open this URL”.

If you ask Google, there are lots of suggestions, but I struggled to find good code. Many of the results are broken, slow, or incomplete (they open the private browsing window, but not any URLs).

Rather than wade through more Google results, I came up with my own script for doing it, which opens the window and the URL:

I save this as a script in my $PATH and mark it as executable, and then I can open a new private browsing window from anywhere by running:

When you run this code, you may get an error (or a silent failure if you trigger it through a GUI rather than a terminal):

open_private_browsing:114:232: execution error: System Events got an error: osascript is not allowed assistive access. (-1719)

This is the macOS security system kicking in: it doesn’t let arbitrary scripts or applications click menu items in other applications. To allow this script to work, open the Security & Privacy preference pane. Under Accessibility , allow access to whatever application is triggering the script (in my case, iTerm 2), and it should be good.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

max.p

Applescript to open URL in Safari without titlebar...almost working :-)

iMac, MacBook Pro, Mac OS X (10.6.4)

Posted on Aug 30, 2010 8:37 AM

Chachi

Posted on Aug 30, 2010 3:04 PM

Loading page content

Page content loaded

Aug 30, 2010 3:04 PM in response to max.p

Aug 30, 2010 3:13 PM in response to Chachi

Aug 30, 2010 3:25 PM in response to max.p

Aug 31, 2010 11:35 AM in response to Chachi

Stack Exchange Network

Stack Exchange network consists of 183 Q&A communities including Stack Overflow , the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

AppleScript use Safari window ID to create new tabs

I have an AppleScript that creates a new Safari document, then opens multiple URLs in that window using a repeat loop. I would like the script to continue using the same window even if it's not the frontmost window.

(The problem is that if a user changes focus to another Safari window this script will open the URLs in the frontmost window instead of the previously created window.)

I would like to solve this issue by using the window id if possible but need some help on the scripting.

To that end I have created the following but again I think there might be an issue. I would rather not get the id using front window since a user could change the front window at an inopportune time and the script would pull the wrong window ID.

I would rather use something like

Even using the above I have been unable to open URLs in a window by using it's window id and need help with that scripting as well.

It would function something like this:

  • applescript

John's user avatar

  • 1 Just an FYI.. I've modified the example AppleScript code in my answer to use the window id directly and avoid using the index property of the window . –  user3439894 Aug 24, 2020 at 5:50

2 Answers 2

Update to address concerns of the use of: front window.

The following example AppleScript code guarantees the list of URL s gets opened in the target window regardless of its position in the z-order of windows .

Note: Scroll as needed to see all the code .

The updated example AppleScript code includes some error handling , in that if the tmp file (value of the tmpFileName variable ) is not created the script aborts without any message. This can be changed by converting the if not my writeToFile ... statement to a full if block and include an appropriate display alert , display dialog or display notification command , as wanted, followed by the return command .

As coded, this renders --> document "Untitled" returned from the make new document irrelevant, because with the included repeat loop it waits until the HTML file is loaded and can be queried by the actual name of the document as defined by the <title>" & windowName & "</title> tags in the document and ensures that the z-order is irrelevant.

The repeat loop as coded is written to wait up to 3 seconds for the HTML file to load and should be more than enough time. Adjust if necessary.

I opted to forgo the use of the do shell script command as used in your answer, however, if you prefer to use it, then:

Then remove the on writeToFile(theData, theFile, overwriteExistingContent) handler from the -- # Handler # section of the code .

Additionally, if you prefer a do shell script command to remove the tmp file , the value of the tmpFileName variable , then:

Original Answer

The following example AppleScript code is an example of how to open a list of URLs in the same window of Safari , regardless of its window order.

  • Do not use open location as it's a part of Standard Additions , not Safari . Use the URL property to set the URL of the document or tab .
  • Use a list of URLs and the index of the list item ( URL ) in the list .
  • When Safari is instructed to make new document , the new document becomes the front window of Safari . Get the window id of the front window immediately after the make new document command .
  • For subsequent URLs in the list , start the repeat loop at 2 and use the window id which was ascertained directly after the make new document command was executed.

user3439894's user avatar

  • Is there a way to do this so the newly created window has a location, front or back, and also has bounds? –  John Apr 13, 2021 at 17:39
  • @John, For changing the position/size of the window you can use the bounds command after the set winID to id of front window command , e.g., set bounds of window id winID to {0, 23, 1024, 768} . However, setting the position of the window , the value of the index of the window is not so straightforward, as it can depend on how many windows and what position you want to move the front window to. –  user3439894 Apr 13, 2021 at 19:51
  • @John, Have a look at this answer , you can take the lines of code from within the tell application "Finder" block and use that code to move the newly created window to the back of the z-order . You could add it after the. set winID to id of front window command or the, e.g., set bounds of window id winID to {0, 23, 1024, 768} command . –  user3439894 Apr 13, 2021 at 19:51

@user3439894 I accepted your answer - it answers the question well. There is another way - a hackie way to create an ID for a Safari window.

This allows the following commands to avoid using "front window" in case the window that was created is no longer frontmost when the rest of the commands begin - doubtful, but possible.

I am not sure there is a way to give a new window anything other than "Untitled" as a name while creating the window.

  • 1 John, Please see the Update to address concerns of the use of: front window section of my updated answer. Borrowing the concept from your answer I incorporated it into a fully functioning update of my original answer. Thanks. –  user3439894 Apr 14, 2021 at 18:53

You must log in to answer this question.

Not the answer you're looking for browse other questions tagged safari applescript ..

  • The Overflow Blog
  • Between hyper-focus and burnout: Developing with ADHD
  • Featured on Meta
  • Our Partnership with OpenAI
  • Imgur image URL migration: Coming soon to a Stack Exchange site near you!

Hot Network Questions

  • How can I make this kind of list 1., 1.1, 1.1.1, ... and 1.2, 1.2.1, 1.2.1.1, ...?
  • “Out of the mouths of babes”: Is this idiom strictly used to refer to children?
  • Which comma(s) can I remove in this sentence? I feel like there are too many here but all seem necessary to me
  • How to introduce a dangerous looking character to the rest of the party?
  • Is Minima Moralia suggesting that everyone is exchangable property?
  • Name of (90’s?) movie or tv that had an alien scorpion creature that attaches to a forearm as a weapon/tool?
  • Looking for words related to serial publication
  • Can I travel to the UK with a child accompanied visa without the adult named on my visa but with the consent from that adult to another adult?
  • How to find what is wearing out my SSDs
  • When is it worthwhile to report academic misconduct of a referee?
  • Why is it legal for a candidate to fund raise for a PAC, given that PACs aren't supposed to coordinate with them?
  • Almost sure convergence using exponential tail bound
  • Is the largest root of a random polynomial more likely to be real than complex?
  • Assigned texture leaking out of the area after aplying subdivision modifier
  • In OOP, what counts as a "getter"
  • How to draw such a sphere with mesh
  • What is this fuzzy green plant with spikes? (UK gardening)
  • Shortest battleship game, to find number of battleships
  • How can I determine whether a food or ingredient is "ultraprocessed"?
  • Find the Size of a File in a Portable Manner
  • I think I don't truly understand Cauchy's Integral theorem
  • If the Earth stopped spinning, what's the ideal point for it to stop to ensure the most people survive?
  • Sample size and coefficient of variation
  • Using already existing bolt width

applescript safari open url

applescript

  • Getting started with applescript
  • AppleScript Browser Interactions
  • Applescript from the Terminal command line
  • Get the current URL in Safari or Google Chrome
  • Get the Title of the current page in Safari or Google Chrome
  • Use an Applescript as a shell function
  • AppleScript User Interaction
  • AppleScript Variable Types
  • Making Applescript If and Else Statements

applescript Applescript from the Terminal command line Get the current URL in Safari or Google Chrome

Fastest entity framework extensions.

From the Terminal command line

Get the current URL from Safari

Get the active URL in Google Chrome

Got any applescript Question?

pdf

  • Advertise with us
  • Cookie Policy
  • Privacy Policy

Get monthly updates about new articles, cheatsheets, and tricks.

  • Home New Posts Forum List Trending New Threads New Media Spy
  • WikiPost Latest summaries Watched WikiPosts
  • Support FAQ and Rules Contact Us

macOS   Applescript + Safari open URL

  • Thread starter Iceman332k1
  • Start date May 14, 2010
  • Sort by reaction score
  • Apple Programming

Iceman332k1

Macrumors newbie.

  • May 14, 2010

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 http://www.hulu.com or http://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  

chown33

Code: tell application "Safari" to open location "http://www.hulu.com/"  

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  

TuffLuffJimmy

TuffLuffJimmy

Macrumors g3.

  • May 15, 2010

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.  

  • Aug 16, 2012

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!  

  • iPad Pro M4 hands-on
  • Nintendo hints at 'Switch 2' unveiling
  • Google Pixel 8a hands-on
  • Helldivers 2 PSN account reversal
  • Best college graduation gifts

Use AppleScript to open current Safari URL in Google Chrome

I've been using John Gruber's suggestions from Going Flash-Free on Mac OS X, and How to Cheat When You Need It to avoid installing Adobe Flash by using Google Chrome (which includes its own version of Flash) whenever I run into a page that has Flash I want to see.

To make this easier, John suggested turning on the "Develop menu" in Safari's "Advanced" preferences, which includes a sub-menu to "Open Page With" and a sub-sub-menu that shows all of your installed browsers. John suggested using System Preferences to create a keyboard shortcut for "Google Chrome" or "Google Chrome.app" depending on which one you saw in the menu.

Unfortunately, this failed for me quite often. Every time I launched Safari, the keyboard shortcut would not work until I had opened that menu manually using the mouse. I hate using the mouse. After opening the menu, the keyboard shortcut would work until I quit Safari again. That was mildly annoying, but things recently took a turn for the worse.

Here's what the menu looks like for me now:

Notice that the browser listings now include version numbers. This means that a keyboard shortcut would have to include the version number, which means it would break whenever the browser is updated.

I asked a few folks, and it appears this changed in Safari 5.0.4. I haven't been able to find a way to revert to the old behavior, so I started looking for another way.

Enter AppleScript

Using AppleScript, you can send the current URL from Safari to Google Chrome.

Here is the AppleScript that I am currently using:

(Note: this article was updated on 2013–02–10 to include an updated and improved version of the AppleScript, as well as expanded instructions on how to use it.)

This AppleScript will launch Google Chrome if it is not already running, and will not overwrite any existing tabs in Google Chrome.

To use this AppleScript, you will need to download it from Github . Note that the download filename will be something ridiculously long which starts with 'gist4750810' (don't ask me why, it's a Github 'thing'). Find that file in your Downloads folder, double-click it, and Archive Utility will open it and show you a folder with a file named 'Open in Google Chrome.scpt' in it.

Now you'll want to open a new Finder window so you can navigate to where that file needs to be installed, so choose File » New Finder Window and then move on to the next section.

Installation

To use 'Open in Google Chrome.scpt' in Safari, it needs to be installed to ~/Library/Scripts/Applications/Safari/ (where ~ is the path to your Home directory).

If that folder does not exist, you will need to create it. The easiest way to do this is to go to the Finder and then choose the "Go to Folder..." option from the Go menu, as shown here:

Once you have done that, a window will appear prompting you to enter the path that you want to go to. Enter

~/Library/Scripts/Applications/Safari/

and see if it opens the folder.

(Aside: If it says "The folder can't be found" try going to ~/Library/Scripts/Applications/ instead, and then just create the 'Safari' folder using File » New Folder from the menu bar.)

Once you are in the ~/Library/Scripts/Applications/Safari/ folder, simply drag the 'Open in Google Chrome.scpt' file to it from the other Finder window.

Using 'Open in Google Chrome.scpt' From Safari

Once 'Open in Google Chrome' is installed, there are two ways to use it from Safari.

Option one is to use the "Scripts" menu extra from OS X. Option two is to use a program called FastScripts . I prefer FastScripts, but will explain how to use the standard OS X option first.

To use that Scripts menu, launch the "AppleScript Editor.app" found in /Applications/Utilities/ and then go to Preferences and enable the option 'Show Script menu in menu bar' as shown here:

Once the Script menu is enabled, you will see 'Open in Google Chrome' whenever you are in Safari. Just click on the Scripts icon in the menu bar and select it as shown here:

But what if you want to use a keyboard shortcut instead of the mouse? For that you will need FastScripts , which gives you everything the standard 'Scripts' menu offers, plus the ability to assign keyboard shortcuts.

To assign a keyboard shortcut, open FastScript's preferences and find the entry for 'Safari' under your home folder, then locate the 'Open in Google Chrome' entry. Click over in the 'Shortcut' column and assign it a keyboard shortcut. As you can see here, I have chosen ⌥ (Option) + G :

FastScripts lets you assign up to 10 keyboard shortcuts for AppleScripts for free. If you want to use more than 10, you'll need to buy a license for US$15. As a keyboard-lovin' mouse-hater, I consider that a bargain. FastScripts offers a lot more than just keyboard shortcuts , so I would encourage you to check it out.

"Flash Free"

Now whenever I am in Safari and encounter a page which requires Flash, I press ⌥ + G and the page loads in Google Chrome. It's quick and easy, and doesn't require that I maintain a separate Flash installation.

Adobe Flash continues to be a source of security problems. Using it in only Google Chrome is a good way to increase your browsing security, especially since Chrome is frequently updated.

p.s. since I know there are many other Keyboard Maestro fans out there, I'll also add a quick link to my Keyboard Maestro macro for doing this same thing using Keyboard Maestro.

Latest Stories

Most app store developers aren’t taking apple up on its new outside payments option.

In a hearing on Friday as part of the ongoing legal battle with Epic, Apple said only 38 developers have applied to add links to external payment options — out of roughly 65,000 that could, according to Bloomberg.

The geomagnetic storm is a nightmare for farmers relying on precision agriculture tech

According to a report by 404 Media, the intense solar activity over the last few days has disrupted critical GPS systems that guide modern tractors. Modern John Deere tractors as well as those from other brands rely on this technology for precision.

Pre-orders for Ghost of Tsushima on PC are being canceled in countries without PSN access

People who pre-ordered the PC port of Ghost of Tsushima Director’s Cut in countries that don’t have access to PlayStation Network (PSN) were reportedly notified that their purchases have been canceled and auto-refunded.

'Extreme' geomagnetic storm may bless us with more aurora displays tonight and tomorrow

Tonight may offer another chance to catch the aurora if you have clear skies, according to the NOAA, and Sunday could bring yet more displays reaching as far as Alabama. The agency says the 'extreme' geomagnetic storm will continue through tomorrow.

28 Years Later is coming to theaters next summer

Fans have been waiting a long, long time for another installment in the 28 Days Later franchise, and we now know when the next followup is coming out: June 20, 2025. 28 Years Later will be directed by Danny Boyle and written by Alex Garland.

What we’re listening to: Trail of Flowers, Hyperdrama, Science Fiction and more

In this installment of What We're Listening To, the Engadget team discusses some of the recent releases we've had on repeat, including new music from Sierra Ferrell, Justice, Utada Hikaru and Caroline Polachek.

Waymo says its robotaxis are now making 50,000 paid trips every week

Waymo has revealed, as well, that it's had over one million rider-only trips across four cities.

Doctor Who: The Devil’s Chord review: Is this madness?

'The Devil's Chord' is a mess, but it's probably an intentional mess.

Doctor Who Space Babies review: Bet you didn’t expect that

'Space Babies' is crazy, chaotic and political. Just as Doctor Who should be.

Apple’s big AI rollout at WWDC will reportedly focus on making Siri suck less

Apple will reportedly focus its first round of generative AI enhancements on beefing up Siri’s conversational chops. The company will reportedly roll out a new version of Siri powered by generative AI at its WWDC keynote on June 10.

Samsung HW-Q990D soundbar review: A small but significant update

Samsung's home theater powerhouse got the one thing it was missing, but not much else for this year's model.

Climate protestors clash with police outside Tesla’s German gigafactory

Climate protestors in Germany reportedly broke through police barricades on Friday, amid clashes between activists and law enforcement. The protestors either made it onto (according to protestors) or near (according to local police) the grounds of a Tesla gigafactory in Grünheide, Germany, near Berlin.

The world’s largest direct carbon capture plant just went online

Climeworks has just opened the world’s largest direct carbon capture plant. It can suck around 36,000 tons of CO2 from the air each year, burying it underground.

Apple's entire AirPods lineup is discounted, plus the rest of the week's best tech deals

This week's best tech deals include the AirPods Pro for $180, the Amazon Kindle for $80 and a year of Paramount+ with Showtime for $60, among others.

Amazon's Echo Dot drops to just $28

Amazon's Echo Dot has dropped to $28, which is a great price for our favorite sub-$50 smart speaker.

Hulu's Black Twitter documentary is a vital cultural chronicle

Hulu's new documentary, "Black Lives Matter: A People's History," explores the rise and global influence of the community.

Google just patched the fifth zero-day exploit for Chrome this year

Google just patched the fifth zero-day exploit for Chrome this year. The company has released a security update for users to download.

The Rogue Prince of Persia is delayed because Hades II is a juggernaut

The Rogue Prince of Persia was supposed to debut in early access on May 14, but Evil Empire and Ubisoft have delayed it to get out of the way of Hades II.

Engadget Podcast: Is the iPad Pro M4 overkill?

Is the iPad Pro M4 overkill?

The Morning After: Apple apologizes for its iPad Pro ad that crushed human creativity

The biggest news stories this morning: How to watch Google's I/O 2024 keynote, Apple apologizes for its iPad Pro ad, Nintendo is done paying Elon Musk for X integration on its consoles.

IMAGES

  1. Apple: AppleScript URL from open safari window

    applescript safari open url

  2. Use AppleScript to open current Safari URL in Google Chrome

    applescript safari open url

  3. AppleScript で Safari を開く

    applescript safari open url

  4. In Applescript, how do I launch Safari "Silently" open url then close

    applescript safari open url

  5. Apple: AppleScript application as a Safari Webpage

    applescript safari open url

  6. AppleScript App Using Safari Interface

    applescript safari open url

VIDEO

  1. Drag & drop a Safari URL

  2. AppleScript: Safari (Webautomation)

  3. Как открыть ссылку в новой вкладке iPhone Safari

  4. Automate Safari using AppleScript

  5. Как в Safari на iPhone открыть ссылку не покидая страницы. iPhone ссылки Safari фоновый режим

  6. Safari Not Loading Pages On macOS

COMMENTS

  1. Open URL in new Safari tab with AppleScript

    Applescript won't make Safari open a URL at a new window. 2. Open URL on macOS via command line. Hot Network Questions Non-noetherian schemes with noetherian underlying space (in the Zariski topology) Having a second bite of the data-apple without p-hacking HST can apparently operate in one-gyro mode, if need be. ...

  2. How to open a specific url in the current Safari tab with AppleScript

    To open a URL in a tab in Safari, you use set url to and then the URL. So, for example, this script will open stack overflow in the current tab of the current window: tell application "Safari". tell window 1. tell current tab. set URL to "https://stackoverflow.com". end tell. end tell. end tell.

  3. AppleScript to prompt for url input, open url in safari, then open

    I'd like the script to ask for the user to enter a url, it will then open a new window with this page and then it will click the bookmark which will itself run some JavaScript on the open page. The example AppleScript code , shown below, was tested in Script Editor under macOS Catalina with Language & Region settings in System Preferences set ...

  4. How do I open a generic URL from AppleScript?

    6. If myscheme is properly registered in the Launch Services Database to open a particular application, then you can use the open location command, which: "Opens a URL with the appropriate program." Use as in the following examples: set theURL to "myscheme://a/b/c". open location theURL.

  5. AppleScript Safari URL tip: How to open multiple URLs in Safari tabs

    tell application "System Events". -- enter the url in the open window. keystroke (item 1 of urlList) key code 36. repeat with i from 2 to (numURLs) -- for each additional url, first create a tab. tell process "Safari". click menu item "New Tab" of menu "File" of menu bar 1. end tell.

  6. Using AppleScript to open a URL in Private Browsing in Safari

    Tagged with applescript, macos, macos:safari; I have a bunch of automations that open URLs. If I want to open a regular window in Safari (my default browser), I have a variety of options - I can use open(1) on the command-line, or the webbrowser module in Python, or with AppleScript, or probably half a dozen other methods I haven't thought of.

  7. AppleScript URL from open safari window

    URL is a property of a document or a property of a tab in a window, so use this: if URL of document 1 is "www.google.com" then. or this: if URL of current tab of window 1 is "www.google.com" then. Update, example of how to use the exists command: tell application "Safari". set b to exists URL of document 1 -- this put false or true into the ...

  8. Applescript to open URL in Safari without…

    tell application "Safari" activate set theURL to URL of document 1 set windowID to id of window 1 do JavaScript ("window.open('" & theURL & "','_blank','titlebar=0');") in document 1 close window id windowID end tell </pre> The above script opens a new window with the current document's url and then closes the original window.

  9. AppleScript use Safari window ID to create new tabs

    The following example AppleScript code is an example of how to open a list of URLs in the same window of Safari, regardless of its window order. Notes: Do not use open location as it's a part of Standard Additions, not Safari. Use the URL property to set the URL of the document or tab. Use a list of URLs and the index of the list item (URL) in ...

  10. Generate a List of Open Safari Tabs With AppleScript

    The syntax of these is nearly identical, only one grabs the name of the current tab and the other grabs the URL. I found the specific syntax for these commands in the Safari AppleScript dictionary. Notice that, to grab the name and URL of the current tab, we're simply using the x and y variables that increment each time the repeat block is run.

  11. applescript Tutorial => Get the current URL in Safari or Google Chrome

    From the Terminal command line. Get the current URL from Safari. osascript -e 'tell app "safari" to get the url of the current tab of window 1'. Get the active URL in Google Chrome. osascript -e 'tell app "google chrome" to get the url of the active tab of window 1'.

  12. Applescript + Safari open URL

    macOS Applescript + Safari open URL. Thread starter Iceman332k1; Start date May 14, 2010; Sort by reaction score; Forums. Software. Developers. Apple Programming . I. Iceman332k1 macrumors newbie. Original poster. Dec 15, 2009 9 0. May 14, 2010 #1 I need to make an Applescript that opens Safari (or switches to it if it's already open) and then ...

  13. AppleScript : Safari : Open link in a new tab (Command+Click)

    This seems oddly specific, and there might be a better solution that's more general. - JMY1000. Jul 1, 2016 at 11:03. I do some investigation on some profile and need to open different links on different tab so I can have a overview of each data. - Kevin.

  14. Use AppleScript to open current Safari URL in Google Chrome

    Using 'Open in Google Chrome.scpt' From Safari Once 'Open in Google Chrome' is installed, there are two ways to use it from Safari. Option one is to use the "Scripts" menu extra from OS X. Option ...

  15. Applescript that tells Safari to open a URL in my clipboard

    Hi. I want an AppleScript that tells Safari to open a URL on my clipboard. Here's my code, so far: on run {input, parameters} tell application "Safari" open location "URL" activate end tell return input end run

  16. AppleScript Help: Wait for Safari Page to load

    I am trying to create a script to open the URL csbsju.instructure.com in Safari, wait for the page to load all the way, click the login button, and then double check if the URL is correct (there's a bug that adds dashboard-sidebar, so I'm just checking the URL and if it's incorrect, redirecting the page. ... AppleScript to prompt for url input ...

  17. Save the source of an open webpage from Safari with AppleScript

    set theDocumentTitle to the name of document 1. set theDocumentSource to the source of document 1. tell application "TextWrangler". activate. set theNewDocument to make new document with properties {name:theDocumentTitle, text:theDocumentSource} set theDocumentsFolderPath to the path to the documents folder as text.

  18. In AppleScript, how to open a URL location that contains a hash (#)?

    505 3 16. 1. Try removing the / before the # character, or supply the name of the webpage between / and # character. - Nimesh Neema ♦. Dec 10, 2018 at 15:57. Nimesch, that helps me a lot right now! Not sure if it solves the problem in a generic way though. If you want, please phrase it as an answer so I can vote it up.

  19. macos

    I need to have Safari visit a specific URL, and "Save As... page source" to a specified location in my Home folder. ... This is probably the easiest method to download a web page and doesn't require that Safari actually open the page. ... AppleScript to prompt for url input, open url in safari, then open bookmark with specific name.