LoginSignup
4
3

More than 5 years have passed since last update.

Karabinerを使い選択テキストをショートカットキーでWeb検索

Posted at

WindowsのAutohotkeyでやっていることをMacでもやりたいなと思い。
以下の例だと"英数"+"T"で選択テキストをWeblio辞書で検索しています。
Googleで検索する場合は、5行目をopen "https://www.google.com/search?hl=ja&q=`pbpaste`"にします。

private.xml

<vkopenurldef>
  <name>KeyCode::VK_OPEN_URL_WEBLIO_WITH_CLIPBOARD</name>
  <url type="shell"><![CDATA[
    sleep 0.2;
    open "http://ejje.weblio.jp/content/`pbpaste`"
  ]]></url>
</vkopenurldef>
<item>
  <name>英数 + T -> Weblioで選択テキストを検索 </name>
  <identifier>private.eisuu_t.weblio</identifier>
  <autogen>
    __KeyOverlaidModifier__
    KeyCode::JIS_EISUU,
    KeyCode::VK_MODIFIER_EXTRA1,
    KeyCode::JIS_EISUU
  </autogen>
  <autogen>
    __KeyToKey__
    KeyCode::T, ModifierFlag::EXTRA1,
    KeyCode::C, ModifierFlag::COMMAND_L,
    KeyCode::VK_OPEN_URL_WEBLIO_WITH_CLIPBOARD
  </autogen>
</item>

Karabinerの中でクリップボード変数とかないかなとか探しましたがなさそうでしたのでshellで...
というかshellが呼べるとなんでもできますね。
sleep 0.2;は、Cmd+Cのコピーが終了するのを待っています。

4
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
3