Mac – Add Keyboard Shortcut to Mac

automatorkeyboardmacshortcut

Is there a way I can make a keyboard shortcut for this?

Tab, Tab, ⬇︎, S, Return ⏎, Return ⏎

Is there a way I can bind this to a keyboard shortcut, i.e. ⌘ Command⌥ OptionG?

Best Answer

You can use Automator to create a service for this. Open Automator and click “New Document,” then choose the Service template:

Click Service, then click “Choose”

Next, click on the “Service receives selected text” dropdown and choose “no input:”

Next, add a “Run AppleScript” action:

  1. Click “Actions” in the sidebar
  2. Ensure the “Library” row in the first column is selected
  3. Search for “AppleScript”
  4. Double-click the “Run AppleScript” row in the search results

In the action on the right side of the window, paste this AppleScript into the text box:

on run {input, parameters}
    tell application "System Events"
        repeat 2 times
            keystroke tab
        end repeat
        keystroke (ASCII character 31) -- down arrow
        keystroke "s"
        repeat 2 times
            keystroke return
        end repeat
    end tell
    return input
end run

Next, click the “compile” (hammer ?) button to verify that the code was pasted correctly:

Choose File → Save (or + S), and type in a name you’ll remember. Next, open System Preferences ( → System Preferences…) and click “Keyboard.” Under the “Shortcuts” tab, select “Services” in the left list. Scroll to the bottom of the main list, under the “General” section, and select the service you just created. Click the “Add Shortcut” button and type the keyboard shortcut you’d like to use.

The shortcut should now work.

Based on the other answer