Safari app scripting
Safari app scripting
- Subject: Safari app scripting
- From: "Robert (PT Business Groups)" <email@hidden>
- Date: Mon, 13 Aug 2018 15:52:08 +0100
Hello list;
An Applescript novice here …..
I use the Safari app in High Sierra and have several scripts that run nicely
for it.
One small issue that I can’t get past in my scripts is to be able to open a new
window (make new document) without it accessing the default homepage.
In normal use I want the homepage to open but when using scripts I would like
the window empty to begin with.
I do have workarounds in place but just wondered if there was something I was
missing like a simple one liner (just to soothe my curiosity).
Here’s a portion of my ‘basic’ coding that I’ve come up with:
"
tell application "Safari"
activate -- If this launches Safari then it opens window with default
homepage tab.
delay 2.5 -- Need time for the default homepage to load otherwise the
next step can't close it.
try
set taburl to URL of tab 1 of front window
if taburl starts with "https://www.macintouch" then
close tab 1 of front window -- This should close the
window if it has Macintouch as the first and hopefully only tab in the window.
If not the only tab then it should close just the Macintouch tab.
end if
end try
make new document -- Opens new window with default homepage tab.
open location "https://www.lg.com/
open location "https://www.netgear.com/
open location "https://rogueamoeba.com/
open location "https://www.barebones.com/
open location "https://bombich.com/
open location "https://etrecheck.com/
open location "https://handbrake.fr/
set winlist to front window
delay 2.5 -- Give tab 1 a chance to load.
set taburl2 to URL of tab 1 of front window
if taburl2 starts with "https://www.macintouch" then
close tab 1 of winlist -- This should close the window if it
has Macintouch as the first and only tab in the window. If not the only tab
then it should close just the Macintouch tab.
end if
"
Many thanks in advance.
Robert.
___________________________________________
This email has been scanned by iomartcloud.
http://www.iomartcloud.com/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden