LoginSignup
2
1

More than 5 years have passed since last update.

BetterTouchToolでアプリ再起動コマンド作成

Posted at

BTTを用いて、macのウィンドウの赤いボタンを右クリックすると最前面のアプリが再起動するように設定してみました。

需要がまるで不明ですがメモ。

設定手順

  1. BetterTouchToolの設定画面を開き、Otherタブを選択
  2. トリガーとして「Rightclick Red Window Button」を選択
  3. Predefined Actionとして「Open Application / File / Apple Script ...」を選択
  4. 以下のAppleScriptを指定する(下のリンク先のものをまるまる引用している)

Applescript to Relaunch Frontmost App - Nerdy Thoughts

relaunchapp.scpt
tell application "System Events" to set theApp to the name of the first process whose frontmost is true
tell application theApp
quit
set isRunning to true
repeat while (isRunning)
delay 1
tell application "System Events"
set isRunning to ((name of processes) contains theApp)
end tell
end repeat
do shell script "open -a " & quoted form of theApp
end tell

使用時の注意

赤ボタンの右クリックは最前面でないアプリに対しても有効ですが、あくまで再起動されるのは最前面のアプリです。
本当はマウスオーバーしているアプリの名前を取得するか、先に最前面に持っていくかしようと思ったのですが、方法がわかりませんでした。

というか無理という結論がちらほら見えているので(こことかこことか)、半ば諦めています。

ということで中途半端ですが、使うときにはそのアプリが最前面に出てるか確認してから使いましょう。

2
1
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
2
1