最小化されたウインドウをひとつずつ引き出す(特定のアプリのみ)

ショートカットキー「⌘+M」で最小化はできるけど、逆は..
そんな時に考えた、最小化を解除するスクリプトです。
下記のスクリプトは「Safari」「Google Chrome」「Finder」に対応しています。
長くなるのでスクリプトには記述していませんが、他には「Script Editor」「TextEdit」「Pages」「Numbers」「Keynote」「Preview」「Pixelmator Pro」「Acorn」「Firefox」などに対応できます。
スクリプトは単体で実行しても変化はありません。AutomatorやShortcutsなどにコードやファイルとして入れ込むか、BetterTouchToolなんかに登録してショートカットキーを設定して実行します。
AutomatorやShortcutsは実行時ラグがあります。
スクリプト実行時に最前面にあるアプリ名を取得して実行されるので、最小化を解除したいアプリがアクティブな状態で実行します。そうすれば、スクリプトに記述してあるアプリならショートカットキーを押すたびウインドウがひとつずつ最小化解除されるでしょう。
これで当初の目論見は成功!?

use AppleScript version "2.4"
use scripting additions
use framework "Foundation"

set fPath to POSIX path of (path to frontmost application)
set appName to ((current application's NSString's stringWithString:fPath)'s lastPathComponent()'s stringByDeletingPathExtension()) as string

if appName is "Safari" then
tell application "Safari"
set wList to get every window whose miniaturized is true
if (count wList) > 0 then
set aWin to item 1 of wList
set miniaturized of aWin to false
end if
end tell
else if appName is "Google Chrome" then
tell application "Google Chrome"
set wList to get every window whose minimized is true
if (count wList) > 0 then
set aWin to item 1 of wList
set minimized of aWin to false
end if
end tell
else if appName is "Finder" then
tell application "Finder"
set wList to get every Finder window whose visible is false
if (count wList) > 0 then
set aWin to item 1 of wList
activate aWin
end if
end tell
end if

更新履歴

inserted by FC2 system