Merging keyboard shortcuts

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.


Solution 1:

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>

Solution 2:

So, I found a solution by creating an applescript with automator:

on run {input, parameters}
tell application "System Events"
    key code 8 using command down
    delay 0.1
    key code 53
    key code 3 using command down
    key code 9 using command down
end tell
return input
end run

that does his job.

(the reason why there is the escape key - key code 53 - is that I was looking for a solution that works also for for jupyter notebook)

ps: the problem is still to find a shortcut that had no conflict...