I have tried the following key combinations in an attempt to do this, to no effect:
- Command+Return ...+Space
- Option+Return ...+Space
- Control+Return ...+Space
- Command+Shift+\ (The "Show All Tabs" Command on my Macbook)
This leads me to believe that it really is an oversight on Apple's part.
Kludge: Create An Automator Command to Simulate A Mouse Click
I used code that I found at https://discussions.apple.com/thread/3708948 to put together the following AppleScripts:
Attempt 1: Didn't Work
I ran this code in an Applescript wrapped in an Automator Service mapped to "Command+Shift+Option+Control+Space", using the numbers I get from pressing "Command+Control+Shift+4" to get the address for the area (600 pixels horizontal from left, 300 pixels vertical from top), and it would work in normal Safari (pressing the key combination would make the mouse click at that pixel address), but it had no effect when the same key command was run in the "Show All Tabs" mode in Safari!
on run {input, parameters}
tell application "System Events"
tell process "Safari"
click at {600, 300}
end tell
end tell
return input
end run
Attempt #2: Worked, but Not Feasible
I did get a key command working with the following Applescript wrapped in an Automator Service, but it took 5.125 seconds to complete:(
on run {input, parameters}
set x to 600
set y to 150
do shell script "
/usr/bin/python <<END
import sys
import time
from Quartz.CoreGraphics import *
def mouseEvent(type, posx, posy):
theEvent = CGEventCreateMouseEvent(None, type, (posx,posy), kCGMouseButtonLeft)
CGEventPost(kCGHIDEventTap, theEvent)
def mousemove(posx,posy):
mouseEvent(kCGEventMouseMoved, posx,posy);
def mouseclick(posx,posy):
mouseEvent(kCGEventLeftMouseDown, posx,posy);
mouseEvent(kCGEventLeftMouseUp, posx,posy);
ourEvent = CGEventCreate(None);
currentpos=CGEventGetLocation(ourEvent); # Save current mouse position
mouseclick(" & x & "," & y & ");
mousemove(int(currentpos.x),int(currentpos.y)); # Restore mouse position
END"
return input
end run
Best Answer
OK, so the AppleScript required to click that menu item is quite simple:
The AppleScript snippet needs to be dressed up a little more to be useful:
The works for both Safari and Safari Technology Preview, which is nice.
Running this in, say, macOS Script Editor.app will remotely click the referenced menu item and display the expected conformation dialog.
Finally, we need to add a shortcut key to access the menu. There are a number of different ways to do this and choice will depend on personal preference and/or software at hand:
The last of the options above, FastScripts Lite, is the one that comes for free, and also the easiest method, so I'll use it in this answer.
Enter the above "activate...end tell" snippet into macOS Script Editor.app and save the resulting script to
~/Library/Scripts/Applications/Safari/Save Bookmarks for Current Window Tabs.scpt
.In FastScripts Lite.app you'll now have a menu item that is effectively an alias for Safari's "Add Bookmarks for These X Tabs..." menu item, and that can be assigned a shortcut key using FastScripts Lite.app > Preferences > Script Shortcuts.