All Apple news

AppleScript: How to open new Windows in Safari with one click

Show you how to use AppleScript to launch new Windows in Safari.

In macOS, there is one annoying feature in dealing with a large number of Windows. Icons in the dock and never open the app again, and return the user to already running sessions. For example, if you open at least one window with Safari, after clicking on the browser icon, the system will take the user inscribed on it. At the same time, to open a new window, click on the logo of the program, right-click and choose the option “Open new window”.

To fix this problem, you need to create a script and replace it with a shortcut from Safari to the dock.

To do this:

  • Run AppleScript utility (it is installed by default on every Mac).
  • In the appeared window enter the following command:

tell application “Safari”

make new document with properties {URL:””}

end tell

This command will launch a browser with an empty window. If you enter in the URL field a link, it will open by default. It should be noted that using this script, Safari will open in the background and focus on the window with the application will have to manually. Fortunately, it is also possible to correct by adding in the Apple Script one command:

tell application “Safari”

activate

set visible of second window to true

end tell

That’s about it. The script is ready. Now it needs to move to the dock, because we are not going to run it from the AppleScript every time.

To do this:

  • To save the selected script with the key combination ⌘+S.
  • Then go to “File” at the top of the screen.
  • Select “Export…”
  • In the resulting window, find the item “file Format” and change it to the option “Program”.
  • Then you need to find a program in your iCloud Drive and drag it to the dock.

Now the dock will be a new shortcut to launch a separate Safari window. There is one time – change the icon. By default, the scripts receive the basic badge, which will not suit everyone’s taste. This can be a quick fix.

To do this:

  • Download your favorite Safari icon in PNG format.
  • To open it in the app “Preview” and press ⌘+.
  • Then we need to find our created script, click on it once and press ⌘+I.
  • In the window that appears, click on the icon in the upper left corner, and press ⌘+V.

That’s about it. The program is ready.

MDlavka — our store for your favorite readers. Technology Apple for the most pleasant prices are waiting for you every day from 10:00 to 21:00. Putting a promo code macdigger when ordering, get a discount 500 rubles.

Follow the news of the Apple in our Telegram-channel, as well as in the app on iOS MacDigger.

Leave a Reply

Your email address will not be published. Required fields are marked *