起動中のアプリケーション名一覧から1つを選択して返すダイアログを表示するAppleScriptです。
返り値はアプリケーション名/バンドルID、visibleなプロセスのみか、invisibleなものも含めるかという指定ができます。
choose applicationだと「起動中のアプリケーション」という指定ができないので、作ってみました。
AppleScript名:Choose Runnning App.scpt |
— – Created by: Takaaki Naganoya – Created on: 2020/08/06 — – Copyright © 2020 Piyomaru Software, All Rights Reserved — use AppleScript version "2.4" — Yosemite (10.10) or later use framework "Foundation" use scripting additions set apName to chooseRunnningApp(true, false) of me –> "Xcode" set bID to chooseRunnningApp(true, true) of me –> "com.apple.dt.Xcode" on chooseRunnningApp(visibleAppF as boolean, bundleIDF as boolean) tell application "System Events" set pList to name of every process whose visible is visibleAppF set bList to bundle identifier of every process whose visible is visibleAppF end tell set cRes to choose from list pList with prompt "Select Runnning Application" without empty selection allowed if cRes = false then error number -128 –Cancel if bundleIDF = false then set apName to contents of first item of cRes return apName else set apName to contents of first item of cRes set apInd to retIndexNumInArray(pList, apName) of me set bundleID to contents of item apInd of bList return bundleID end if end chooseRunnningApp –Sequential Search in 1D Array on retIndexNumInArray(aList, aTarget) script obj property list : aList end script set aCount to 1 set hitF to false repeat with i in obj’s list set j to contents of i if aTarget = j then return aCount end if set aCount to aCount + 1 end repeat if hitF = false then return 0 end retIndexNumInArray |
More from my site
(Visited 219 times, 2 visits today)