Apple - Safari "Search Tabs" Keyboard Shortcuts

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

I think I got your answer. I spent all day looking for this. I use a great free app called BetterTouchTool( using OS X 10.10 ) to add aditional gestures and shortcuts to all apple devices, and it work instantaneously! No delay!

I will make screenshots with each step you need to configure. NOTE: It will bind the mouse position as a keyboard shortcut of your choice when you're using safari. Downsides: You can't change safari's window position, and the position of the mouse will be different from the monitor from your notebook. Solution: I recommend map the mouse position using it in fullscreen with the screen you most use most of the times( or just map two shortcuts for each screen )

  • 1 Download the app http://www.bettertouchtool.net

  • 2 Open the app, select keyboard, add an app to list to the shortcuts you will add( in this case Safari ), choose your shortcut( I'm mapping "Option + 1" in this screenshot ), then, inside the Trigger select menu, select "Move Mouse to Position" in the "Other Mouser Actions".I marked the wrong option in the screenshot, it's the option above. It's NOT "Save mouse position". Sorry i'm too tired, it's 3 am and I have to work tomorrow enter image description here

  • 3 Choose where you want the cursor to go( The position in the input box will check the first result when the UI is showing ~3 results)

enter image description here

  • 4 Add a following event: A left click event. And that's it! enter image description here

Do the same with a different mouse position to get the 2nd, 3rd.. result but keep in mind the ui will change if larger results, sometimes even hiding the first result.


I've been using Applescript to do this since before they added this feature:

http://hea-www.harvard.edu/~fine/OSX/safari-tabs.html

It pops up a search dialog, you enter your search, and it immediately activates a single matching tab, or gives you a dialog to select from a list of matching tabs. It brings the window to front and makes this the active tab in the window.

(I have a similar script for finding Terminal windows.)

Tags:

Macos

Safari

Tabs