Keyboard Maestroで「Path Finderで選択したファイルを特定アプリで開く」プラグインを作成する方法

Keyboard Maestroで、Finderで選択したファイルを特定アプリで開きたいときは「Open the Finder Selection」アクションを使うと簡単に実現できます。
しかし、Path Finderを使っている人は変数を使ったり条件分岐やAppleScriptを組み合わせてようやく実現できます。
マクロが長くなってしまうと見通しが悪くなってしまいますし、時間が経ってから見返したときに、何をやっているのか分からなくて混乱してしまいます。
そこで、Third Party Plug InsでPath Finderで選択したファイルを特定アプリで開けるようにしてみました。
Third Party Plug Insについて
Third Party Plug Insの作り方や必要ファイルは過去に紹介したので、そちらをご覧ください。
Keyboard Maestro Action.plist
入力欄ではTokenStringを使用して、アプリ名を入力するようにします。
本当は「Open the Finder Selection」アクションと同じように、アプリ一覧が表示されるセレクトボックスを表示させられると良いのですが、Third Party Plug Insでは用意されていませんでした。
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Name</key>
<string>Open the Path Finder Selection</string>
<key>Script</key>
<string>Action.scpt</string>
<key>Icon</key>
<string>Icon.png</string>
<key>Title</key>
<string>Open Path Finder Selection '%Param%Open Path Finder selection with%'</string>
<key>Parameters</key>
<array>
<dict>
<key>Label</key>
<string>Open Path Finder selection with</string>
<key>Type</key>
<string>TokenString</string>
</dict>
</array>
</dict>
</plist>Action.scpt
入力欄の「Open Path Finder selection with」の値を取得したいので、「set appName to system attribute “KMPARAM_Open_Path_Finder_selection_with”」でappName変数に入力した値を入れています。
あとは、appNameをもとにアプリを取得して、Path Finderで選択しているファイルを開くだけです。
set finderSelection to ""
set theTarget to ""
set appName to system attribute "KMPARAM_Open_Path_Finder_selection_with"
set appPath to path to application appName
set defaultTarget to (path to home folder as alias)
tell application "Path Finder"
set theTarget to {}
repeat with pfItem in (get selection)
set the end of theTarget to POSIX path of pfItem
end repeat
end tell
tell application appName
open theTarget
end tell使い方
使うときはThird Party Plug Insに追加されている「Open the Path Finder Selection」をマクロに追加して、入力欄にアプリ名を入力すればOKです(正確に入力する必要があります)。

まとめ
やっていることは、今まで使っていたAppleScriptを外部ファイル化して、Keyboard Maestroの入力欄と繋げているだけなので、コードの関数化に近いです。
今まで複数のアクションを使っていたことが1つにまとめられて、管理もしやすくなりました。



Fantastical 2は音声入力を使って予定を追加するのが便利!
Path Finderでタブセットを使うと、よく使うフォルダ一式を一気に開けるようになる!
.DS_Storeなどの不要なメタデータファイルを自動で削除する「BlueHarvest」
Visual Studio CodeのEmmetのlang属性をjaに変更する方法
Chrome拡張機能の「1Password」と「1Password X」の違いはなに?どちらを使えばいいの?
日々の制作をラクにするTips #1日1Tips – 2019年10月
Hazelを使って、最近使用していないアプリケーションやフォルダにラベルを貼って可視化する
Transmit 5のPanic Syncでサーバー情報が同期されないときの対処法
ウェブサイトを作る上での基本「Macの画像圧縮方法」のまとめ
Path Finder 8で使えるツールバーの項目一覧
AirPodsで片耳を外しても再生が止まらないようにする方法
MacのKeynoteにハイライトされた状態でコードを貼り付ける方法
iTerm2でマウスやトラックパッドの操作を設定できる環境設定の「Pointer」タブ
DeepLで「インターネット接続に問題があります」と表示されて翻訳できないときに確認すること
Ulyssesの「第2のエディタ」表示を使って2つのシートを横並びに表示する
【2026年版】Karabiner-Elementsで実現する右commandキー活用のススメ
Bartender ProのTop Shelf機能でできること
高機能なスクリーンショットアプリ「CleanShot X」
macOSの効率化に関するDiscordコミュニティ「CMD-F」を立ち上げました
1Passwordの開発者向け機能(SSH Agent / Environments / 1Password CLI / Developer Watchtower)
Default Folder Xで保存ダイアログ内のファイルリストにフォーカスする方法
Obsidianで整理した知識をAnkiで定着させる方法
Figma × Keyboard Maestroでどこまで効率化できる?
マウス操作の完成度が高いウインドウリサイズアプリ「Magnet」
Macで複数ディスプレイを使っている場合に便利な設定集