【AppleScript】全てのアプリケーションの終了(フォアグラウンド)
【スクリプトエディタで開く】 |
全てのアプリケーションの終了(フォアグラウンド).scpt | ソース |
|---|
| 001 | #!/usr/bin/env osascript |
| 002 | #coding: utf-8 |
| 003 | ----+----1----+----2----+-----3----+----4----+----5----+----6----+----7-- |
| 004 | (* |
| 005 | 全てのフォアグラウンドアプリケーションの終了 |
| 006 |
|
| 007 | Finderの除外 |
| 008 | と |
| 009 | "スクリプトエディタ"の除外 |
| 010 |
|
| 011 | com.cocolog-nifty.quicktimer.icefloe *) |
| 012 | ----+----1----+----2----+-----3----+----4----+----5----+----6----+----7-- |
| 013 | use AppleScript version "2.8" |
| 014 | use scripting additions |
| 015 |
|
| 016 | property refMe : a reference to current application |
| 017 |
|
| 018 | #ディスプレイ名=Finderで表示される名称の収集 |
| 019 | tell application "System Events" |
| 020 | set listProcesName to (displayed name of (every process whose background only is false)) as list |
| 021 | end tell |
| 022 |
|
| 023 | #その中でも終了させないホワイトリスト |
| 024 | set listWhiteList to {"スクリプトエディタ", "Finder", "loginwindow"} as list |
| 025 |
|
| 026 | #順番に終了-->未保存があればエラーで停止する |
| 027 | repeat with itemProcesName in listProcesName |
| 028 | set strProcesName to itemProcesName as text |
| 029 | if listWhiteList does not contain strProcesName then |
| 030 | tell application itemProcesName to quit |
| 031 | end if |
| 032 | end repeat |
| 033 |
|
| 034 | return |
| AppleScriptで生成しました |
|---|