Merging keyboard shortcuts

automationautomatorshortcut

How could I create a new keyboard shortcut to merge other shortcuts?
In particular I would like to merge ⌘ CommandC, ⌘ CommandF, ⌘ CommandV (Copy, Find and Paste) – would be useful for instance for Safari.

(a quick way could be automator, but I don't have much experience…maybe this post could help?)

A good example would be the use selection for find
(⌘ CommandE) feature that exists in preview.

Thanks for your help.

Best Answer

I have found a funny way to do this with Karabiner installed.

Add this to your private.xml:

<?xml version="1.0"?>
<root>
    <item>
        <name>Command sequence</name>
    <item>
        <name>Option-R</name>
        <identifier>remap.option_r2command.cfv</identifier>
        <autogen>
        __KeyToKey__
        KeyCode::OPTION_R,
        Option::KEYTOKEY_BEFORE_KEYDOWN, KeyCode::C, ModifierFlag::COMMAND_L, KeyCode::VK_WAIT_100MS,
        Option::KEYTOKEY_BEFORE_KEYDOWN, KeyCode::F, ModifierFlag::COMMAND_L, KeyCode::VK_WAIT_100MS,
        Option::KEYTOKEY_BEFORE_KEYDOWN, KeyCode::V, ModifierFlag::COMMAND_L, KeyCode::VK_WAIT_100MS,
        </autogen>
    </item>
    </item>
</root>

Then enable it in Change Key > command sequence > Option-R

enter image description here

A single key press on the right option key will evoke the cascade of command-C/F/V shortcuts.


This doesn't work in Sierra (because Karabiner still isn't Sierra compatible) and depending on the responsiveness of your app you may have to adjust VK_WAIT_100MS to higher values like VK_WAIT_300MS. You can alternatively use other usually rarely used keys like shift_r. A shortcut like alt_r/opt_rX should also work.

If you want to use alt_r/opt_rX as "shortcut" private.xml should look like this:

<?xml version="1.0"?>
<root>
</item>
    <item>
    <name>Command sequences</name>
    <item>
        <name>Option_R-X to Command-C/F/V</name>
        <identifier>remap.option_r-x2command.cfv</identifier>
        <autogen>
        __KeyToKey__
        KeyCode::X, ModifierFlag::OPTION_R,
        Option::KEYTOKEY_BEFORE_KEYDOWN, KeyCode::C, ModifierFlag::COMMAND_L, KeyCode::VK_WAIT_100MS,
        Option::KEYTOKEY_BEFORE_KEYDOWN, KeyCode::F, ModifierFlag::COMMAND_L, KeyCode::VK_WAIT_100MS,
        Option::KEYTOKEY_BEFORE_KEYDOWN, KeyCode::V, ModifierFlag::COMMAND_L, KeyCode::VK_WAIT_100MS,
        </autogen>
    </item>
    </item>
</root>