I created a macro to start Safari and Load a specific webpage.
I would like to closet the leftmost tab (which is also one tab to the left, which is also titled Start Page). I have accomplished this by a) using the window controls to put the window in a specific position and b) using the the mouse control to click at a particular point of the window. Not very elegant but it works!
I would like to find a more elegant and more reliable way of doing this; for example, closing the leftmost tab, closing the tab name Start Page (which I could do using AppleScript but I cannot get AppleScript to run within KM).
I searched both the forum and the internet in my search for a KM non-AppleScript solution but cannot and one.
You don't have to select a tab in order to close it.
tell application "Safari"
tell front window
close (tabs whose name starts with "Start Page")
end tell
end tell
You can also do this by index.
tell application "Safari"
tell front window
set currentTabIndex to index of current tab
set leftTabIndex to currentTabIndex - 1
try
close tab leftTabIndex
end try
end tell
end tell
All good! The funny thing is that I wrote that code myself in AS but because I could not get AS to work until you pointed out that I did not have all the permissions I was looking for others way to do it.
I will add that I appreciate your AS as my AS skillset is also at the early stages.
I would like to see AS stick around due to its power but I heard it is may be deprecated! I hope not!
Considering the vast automation code base of vanilla AppleScript, AppleScriptObjC, JXA, and the up and coming Shortcuts which supports AppleScript I think deprecation has been deprecated.