中ボタンでウィンドウ・タブを閉じる.ahk
code:中ボタンでウィンドウ・タブを閉じる.ahk
GroupAdd, kuntab, ahk_class MozillaWindowClass ;ウィンドウグループkuntabを作って、
GroupAdd, kuntab, ahk_class Chrome_WidgetWin_0 ;ブラウザやWPSなどタブのあるのを登録
GroupAdd, kuntab, ahk_class Chrome_WidgetWin_1
GroupAdd, kuntab, ahk_class QWidget
GroupAdd, desktop, ahk_class Progman ;これはデスクトップ
GroupAdd, desktop, ahk_class WorkerW ;これはデスクトップ
SetKeyDelay, 0
return
MButton::
MouseGetPos,,,hwnd,ctrl,2 ;中ボタンクリック位置にあるウィンドウをアクティブ化
WinActivate, ahk_id %hwnd%
IfWinActive, ahk_exe Simplenote.exe ;SimplenoteもChromeのWindowクラスが出るので区別
{
Send, !{F4}
return
}
IfWinActive, ahk_group kuntab
{
Send,{LButton} ;ちゃんと選択しないとアクティブタブが閉じてしまうので
Send,^{w} ;タブ閉じショートカット ctrl+w を発行
return
}
IfWinActive, ahk_class Shell_TrayWnd ;タスクバーなら 7+ Taskbar Tweaker に任せるので中ボタンを送る
{
Send, {MButton}
return
}
IfWinActive, ahk_group desktop ;デスクトップを中ボタンクリックで.ahkを再読み込み
{
Reload
return
}
Send, !{F4} ;それ以外なら alt+F4
return