« [Tools]パーミッション値 8進数→10進数 | トップページ | [LaunchPad]ランチパッドのリセット(ResetLaunchPad) »

[NSRunningApplication]Dock再起動

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
#                       com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions


property refMe : a reference to current application


set strUTI to "com.apple.dock" as text

##起動中のアプリを取得して
set ocidAppList to refMe's NSRunningApplication's runningApplicationsWithBundleIdentifier:strUTI

####1以上ならアプリがあるって事なので
if (count of ocidAppList) ≠ 0 then
    ###アプリケーションを取得して
    set ocidAppFinder to ocidAppList's objectAtIndex:0
    ####終了させて
    ocidAppFinder's terminate()
end if

repeat 10 times
    ####3秒まって
    delay 3
    set ocidAppList to refMe's NSRunningApplication's runningApplicationsWithBundleIdentifier:strUTI
    ###アプリケーションが無いなら
    if (count of ocidAppList) = 0 then
        ###起動
        set ocidNewFinderApp to refMe's NSWorkspace's sharedWorkspace()
        ocidNewFinderApp's launchAppWithBundleIdentifier:strUTI options:(refMe's NSWorkspaceLaunchDefault) additionalEventParamDescriptor:(missing value) launchIdentifier:(missing value)
    else
        ###起動が確認できたら処理終了
        exit repeat
    end if
end repeat

return "処理終了"

|

« [Tools]パーミッション値 8進数→10進数 | トップページ | [LaunchPad]ランチパッドのリセット(ResetLaunchPad) »

Dock」カテゴリの記事

UTType」カテゴリの記事