20260402

Windows用のICOアイコンファイルを作る


Windows用のICOアイコンファイルを作る

ダウンロードはこちらから
NOTE記事一覧ですnote.com

【スクリプトエディタで開く】 |

ICN_IMG2ICNS4Win.scpt
ソース
001#!/usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003(*
0041:指定されたサイズの72ppiの正方形PNGを作成します
0052:指定されたサイズの144ppiの@2xサイズの正方形PNGを作成します
0063:グラス用のサイズの72ppiの画像を作成します
0074:エラーがなければ従来のICNSファイルを作成します
008
009v1 初回作成
010v2 macOS26のグラスを意識したサイズを作成するように変更
011それにともないプロファイルをDisplay P3に変更
012v3.0b 色々間違っていたのでザッと治した 仮
013v4複数ファイル対応 ワークフローと兼用にした
014
015Windows用のアイコンセット
016
017com.cocolog-nifty.quicktimer.icefloe *)
018----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
019use AppleScript version "2.8"
020use framework "Foundation"
021use framework "UniformTypeIdentifiers"
022use framework "AppKit"
023use scripting additions
024
025property refMe : a reference to current application
026
027##############################
028#RUN
029#Automator用
030#on run listAliasFilePath
031
032(*
033
034#ダイアログ
035      *)
036on run
037   
038   
039   set appFileManager to refMe's NSFileManager's defaultManager()
040   set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSDesktopDirectory) inDomains:(refMe's NSUserDomainMask))
041   set ocidDesktopDirPathURL to ocidURLsArray's firstObject()
042   set aliasDefaultLocation to (ocidDesktopDirPathURL's absoluteURL()) as alias
043   set appBundle to refMe's NSBundle's bundleWithIdentifier:("com.apple.osax.standardadditions")
044   if appBundle = (missing value) then
045      set strBundlePath to ("/System/Library/ScriptingAdditions/StandardAdditions.osax") as text
046      set ocidBundlePathStr to refMe's NSString's stringWithString:(strBundlePath)
047      set ocidBundlePath to ocidBundlePathStr's stringByStandardizingPath()
048      set ocidBundlePathURL to refMe's NSURL's fileURLWithPath:(ocidBundlePath) isDirectory:(false)
049      set appBundle to refMe's NSBundle's alloc()'s initWithURL:(ocidBundlePathURL)
050   end if
051   set strChooseAFile to (appBundle's localizedStringForKey:("Choose a File") value:("Choose a File") table:("Localizable")) as text
052   set appBundle to refMe's NSBundle's bundleWithIdentifier:("com.apple.AppKit")
053   if appBundle = (missing value) then
054      set strBundlePath to ("/System/Library/Frameworks/AppKit.framework") as text
055      set ocidBundlePathStr to refMe's NSString's stringWithString:(strBundlePath)
056      set ocidBundlePath to ocidBundlePathStr's stringByStandardizingPath()
057      set ocidBundlePathURL to refMe's NSURL's fileURLWithPath:(ocidBundlePath) isDirectory:(false)
058      set appBundle to refMe's NSBundle's alloc()'s initWithURL:(ocidBundlePathURL)
059   end if
060   
061   set strMultiple to (appBundle's localizedStringForKey:("NSMultipleDocuments") value:("NSMultipleDocuments") table:("AccessibilityImageDescriptions")) as text
062   set strMes to ("" & strMultiple & return & strChooseAFile & "") as text
063   set strPrompt to ("" & strMultiple & return & strChooseAFile & "") as text
064   set listUTI to {"public.image"} as list
065   try
066      tell application "SystemUIServer"
067         activate
068         set listAliasFilePath to (choose file strMes with prompt strPrompt default location aliasDefaultLocation of type listUTI with invisibles and multiple selections allowed without showing package contents) as list
069         #         set listAliasFilePath to (choose folder strMes with prompt strPrompt default location aliasDefaultLocation with invisibles and multiple selections allowed without showing package contents) as list
070      end tell
071   on error strErrMes number numErrNo
072      log strErrMes & numErrNo
073      return false
074   end try
075   if listAliasFilePath is {} then
076      return false
077   end if
078   
079   
080   set boolDone to (open listAliasFilePath) as boolean
081   
082   
083   return doQuitSelf()
084end run
085
086
087
088##############################
089#OPEN
090on open listAliasFilePath
091   tell application "Finder"
092      set listAliasFilePath to listAliasFilePath as alias list
093   end tell
094   repeat with itemAliasFilePath in listAliasFilePath
095      set aliasFilePath to itemAliasFilePath as alias
096      set strFilePath to (POSIX path of aliasFilePath) as text
097      set ocidFilePathStr to (refMe's NSString's stringWithString:(strFilePath))
098      set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
099      set ocidFilePathURL to (refMe's NSURL's fileURLWithPath:(ocidFilePath) isDirectory:(false))
100      #画像判定
101      set listResponse to (ocidFilePathURL's getResourceValue:(reference) forKey:(refMe's NSURLContentTypeKey) |error|:(reference))
102      set ocidChkUTType to (item 2 of listResponse)
103      set ocidWhiteUTI to (refMe's UTType's typeWithIdentifier:("public.image"))
104      set ocidWhiteSupUTI to ocidWhiteUTI's supertypes()
105      set boolContain to (ocidWhiteUTI's isSupertypeOfType:(ocidChkUTType))
106      if boolContain is true then
107         set boolDone to doMakeIcns(ocidFilePathURL)
108      end if
109   end repeat
110   
111   
112   
113   if boolDone is true then
114      ##################
115      #保存先
116      set appFileManager to refMe's NSFileManager's defaultManager()
117      set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSPicturesDirectory) inDomains:(refMe's NSUserDomainMask))
118      set ocidPicturesDirPathURL to ocidURLsArray's firstObject()
119      set ocidRootDirPathURL to ocidPicturesDirPathURL's URLByAppendingPathComponent:("Icons/MakeIcon") isDirectory:(true)
120      ##################
121      #Finderで場所を教える
122      set appSharedWorkspace to refMe's NSWorkspace's sharedWorkspace()
123      set boolDone to appSharedWorkspace's openURL:(ocidRootDirPathURL)
124   else
125      return false
126   end if
127   return true
128end open
129
130
131
132
133on doMakeIcns(argFilePathURL)
134   
135   set appShardWorkspace to refMe's NSWorkspace's sharedWorkspace()
136   set appFileManager to refMe's NSFileManager's defaultManager()
137   ##########################
138   #設定項目作成するアイコンサイズ
139   #72ppiを作成 偶数のみ
140   set listPxSize to {16, 24, 32, 48, 64, 128, 256} as list
141   #グラスサイズ(↑のサイズへパディングすると余白ができる)
142   #set listGlassSize to {15, 26, 52, 104, 206, 412, 824, 1648} as list
143   set listGlassSize to {16, 24, 32, 48, 64, 128, 256} as list
144   
145   
146   #入力ファイルパス
147   
148   set ocidFileName to argFilePathURL's lastPathComponent()
149   set ocidBaseFileName to ocidFileName's stringByDeletingPathExtension()
150   #
151   #保存先
152   set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSPicturesDirectory) inDomains:(refMe's NSUserDomainMask))
153   set ocidPicturesDirPathURL to ocidURLsArray's firstObject()
154   set ocidRootDirPathURL to ocidPicturesDirPathURL's URLByAppendingPathComponent:("Icons/MakeIcon") isDirectory:(true)
155   #保存先
156   set ocidSaveDirPathURL to ocidRootDirPathURL's URLByAppendingPathComponent:(ocidBaseFileName) isDirectory:(true)
157   ##########################
158   #iMaterial
159   set ocidMaterialDirPathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:("Material") isDirectory:(true)
160   #フォルダを作っておく
161   set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s init()
162   ocidAttrDict's setValue:(448) forKey:(refMe's NSFilePosixPermissions)
163   set listDone to appFileManager's createDirectoryAtURL:(ocidMaterialDirPathURL) withIntermediateDirectories:(true) attributes:(ocidAttrDict) |error|:(reference)
164   
165   ##########################
166   #iconset
167   set ocidIconsetDirName to ocidBaseFileName's stringByAppendingPathExtension:("iconset")
168   set ocidIconSetDirPathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:(ocidIconsetDirName) isDirectory:(true)
169   set strIconsetDirPath to ocidIconSetDirPathURL's |path|() as text
170   #フォルダを作っておく
171   set listDone to appFileManager's createDirectoryAtURL:(ocidIconSetDirPathURL) withIntermediateDirectories:(true) attributes:(ocidAttrDict) |error|:(reference)
172   #icnsファイルパス
173   set ocidIcnsFileName to ocidBaseFileName's stringByAppendingPathExtension:("icns")
174   set ocidIcnsFilePathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:(ocidIcnsFileName) isDirectory:(false)
175   set strIcnsFilePath to ocidIcnsFilePathURL's |path| as text
176   
177   ##########################
178   #Material作成開始
179   #PNG保存オプション
180   set ocidPngProperty to (refMe's NSMutableDictionary's alloc()'s init())
181   (ocidPngProperty's setObject:(refMe's NSNumber's numberWithBool:false) forKey:(refMe's NSImageInterlaced))
182   (ocidPngProperty's setObject:(refMe's NSNumber's numberWithDouble:(1 / 2.2)) forKey:(refMe's NSImageGamma))
183   #カラー
184   #set strIccFilePath to ("/System/Library/ColorSync/Profiles/sRGB Profile.icc") as text
185   set strIccFilePath to ("/System/Library/ColorSync/Profiles/Display P3.icc") as text
186   set ocidIccFilePathStr to refMe's NSString's stringWithString:(strIccFilePath)
187   set ocidIccFilePath to ocidIccFilePathStr's stringByStandardizingPath
188   set ocidIccFilePathURL to refMe's NSURL's alloc()'s initFileURLWithPath:(ocidIccFilePath) isDirectory:(false)
189   set ocidProfileData to refMe's NSData's alloc()'s initWithContentsOfURL:(ocidIccFilePathURL)
190   
191   #NSADATA
192   set ocidOption to (refMe's NSDataReadingMappedIfSafe)
193   set listResponse to refMe's NSData's alloc()'s initWithContentsOfURL:(argFilePathURL) options:(ocidOption) |error|:(reference)
194   set ocidReadData to (item 1 of listResponse)
195   
196   #NSIMAGE
197   set ocidReadImage to refMe's NSImage's alloc()'s initWithData:(ocidReadData)
198   set ocidImageSizePt to ocidReadImage's |size|()
199   set numWpt to ocidImageSizePt's width()
200   set numHpt to ocidImageSizePt's height()
201   
202   #NSIMAGEをコピーして
203   set ocidReadImageCopy to ocidReadImage's |copy|()
204   
205   #IMAGEREP
206   set ocidReadImgRep to (ocidReadImageCopy's representations)'s firstObject()
207   set numWpx to ocidReadImgRep's pixelsWide()
208   set numHpx to ocidReadImgRep's pixelsHigh()
209   #72ppiにしておく
210   set ocidSetSizePx to refMe's NSSize's NSMakeSize(numWpx, numHpx)
211   (ocidReadImgRep's setSize:(ocidSetSizePx))
212   #コピー範囲
213   set ocidFromRect to refMe's NSRect's NSMakeRect(0, 0, numWpx, numHpx)
214   
215   #■画像合成時に使うdrawInRect
216   set numX to 0 as integer
217   set numY to 0 as integer
218   #計算 W H
219   if numWpx > numHpx then
220      set numScale to (2048 / numWpx) as number
221      set numDrawWpx to 2048 as integer
222      set numDrawHpx to (numHpx * numScale) as integer
223      set numY to ((2048 - numDrawHpx) / 2.0) as integer
224   else if numWpx < numHpx then
225      set numScale to (2048 / numHpx) as number
226      set numDrawWpx to (numWpx * numScale) as number
227      set numDrawHpx to 2048 as integer
228      set numX to ((2048 - numDrawWpx) / 2.0) as integer
229   else if numWpx = numHpx then
230      set numDrawWpx to 2048 as integer
231      set numDrawHpx to 2048 as integer
232   end if
233   
234   set ocidDrawRect to refMe's NSRect's NSMakeRect(numX, numY, numDrawWpx, numDrawHpx)
235   
236   ##########################
237   #元になる2048pxの画像作成
238   set ocidFullImageRep to (refMe's NSBitmapImageRep's alloc()'s initWithBitmapDataPlanes:(missing value) pixelsWide:(2048) pixelsHigh:(2048) bitsPerSample:(8.0) samplesPerPixel:(4.0) hasAlpha:(true) isPlanar:(false) colorSpaceName:(refMe's NSCalibratedRGBColorSpace) bitmapFormat:(refMe's NSBitmapFormatAlphaFirst) bytesPerRow:(0) bitsPerPixel:(32))
239   (ocidFullImageRep's setProperty:(refMe's NSImageColorSyncProfileData) withValue:(ocidProfileData))
240   set ocidSetColor to (refMe's NSColor's colorWithRed:(1.0) green:(1.0) blue:(1.0) alpha:(0.0))
241   
242   #▼編集開始
243   refMe's NSGraphicsContext's saveGraphicsState()
244   set ocidSetImageContext to (refMe's NSGraphicsContext's graphicsContextWithBitmapImageRep:(ocidFullImageRep))
245   (ocidSetImageContext's setImageInterpolation:(refMe's NSImageInterpolationHigh))
246   (ocidSetImageContext's setColorRenderingIntent:(refMe's NSColorRenderingIntentSaturation))
247   (ocidSetImageContext's setCompositingOperation:(refMe's NSCompositingOperationMultiply))
248   (ocidSetImageContext's setShouldAntialias:(true))
249   (refMe's NSGraphicsContext's setCurrentContext:(ocidSetImageContext))
250   ocidSetColor's |set|()
251   
252   (ocidReadImgRep's drawInRect:(ocidDrawRect) fromRect:(ocidFromRect) operation:(refMe's NSCompositingOperationDestinationOver) fraction:(1.0) respectFlipped:(false) hints:(missing value))
253   
254   refMe's NSGraphicsContext's restoreGraphicsState()
255   #▲編集終了
256   #72ppiを確定させておく
257   set ocidSetSizePx to refMe's NSSize's NSMakeSize(2048, 2048)
258   ocidFullImageRep's setSize:(ocidSetSizePx)
259   set ocidFromRect to refMe's NSRect's NSMakeRect(0, 0, 2048, 2048)
260   
261   ##########################
262   #各サイズ作成
263   repeat with itemSizePx in listPxSize
264      
265      #各サイズ作成
266      set ocidArtBordRep to (refMe's NSBitmapImageRep's alloc()'s initWithBitmapDataPlanes:(missing value) pixelsWide:(itemSizePx) pixelsHigh:(itemSizePx) bitsPerSample:(8.0) samplesPerPixel:(4.0) hasAlpha:(true) isPlanar:(false) colorSpaceName:(refMe's NSCalibratedRGBColorSpace) bitmapFormat:(refMe's NSBitmapFormatAlphaFirst) bytesPerRow:(0) bitsPerPixel:(32))
267      (ocidArtBordRep's setProperty:(refMe's NSImageColorSyncProfileData) withValue:(ocidProfileData))
268      
269      set ocidDrawRect to refMe's NSRect's NSMakeRect(0, 0, itemSizePx, itemSizePx)
270      
271      #▼編集開始
272      refMe's NSGraphicsContext's saveGraphicsState()
273      set ocidSetImageContext to (refMe's NSGraphicsContext's graphicsContextWithBitmapImageRep:(ocidArtBordRep))
274      (ocidSetImageContext's setImageInterpolation:(refMe's NSImageInterpolationHigh))
275      (ocidSetImageContext's setColorRenderingIntent:(refMe's NSColorRenderingIntentSaturation))
276      (ocidSetImageContext's setCompositingOperation:(refMe's NSCompositingOperationMultiply))
277      (ocidSetImageContext's setShouldAntialias:(true))
278      (refMe's NSGraphicsContext's setCurrentContext:(ocidSetImageContext))
279      (ocidFullImageRep's drawInRect:(ocidDrawRect) fromRect:(ocidFromRect) operation:(refMe's NSCompositingOperationDestinationOver) fraction:(1.0) respectFlipped:(false) hints:(missing value))
280      refMe's NSGraphicsContext's restoreGraphicsState()
281      #▲編集終了
282      
283      #通常の72ppiの保存
284      set ocidSetSizePx to refMe's NSSize's NSMakeSize(itemSizePx, itemSizePx)
285      (ocidArtBordRep's setSize:(ocidSetSizePx))
286      #保存PNGデータに
287      set ocidSaveData to (ocidArtBordRep's representationUsingType:(refMe's NSBitmapImageFileTypePNG) |properties|:(ocidPngProperty))
288      #保存
289      set strSaveFileName to ("icon_" & itemSizePx & "x" & itemSizePx & ".png")
290      set ocidSaveIconSetFilePathURL to (ocidIconSetDirPathURL's URLByAppendingPathComponent:(strSaveFileName) isDirectory:(false))
291      set boolDone to (ocidSaveData's writeToURL:(ocidSaveIconSetFilePathURL) options:(refMe's NSDataWritingAtomic) |error|:(reference))
292      
293      #@2xの解像度の保存
294      set numHiResPx to (itemSizePx / 2) as integer
295      set ocidSetSizePx to refMe's NSSize's NSMakeSize(numHiResPx, numHiResPx)
296      (ocidArtBordRep's setSize:(ocidSetSizePx))
297      set ocidSaveData to (ocidArtBordRep's representationUsingType:(refMe's NSBitmapImageFileTypePNG) |properties|:(ocidPngProperty))
298      set strSaveImageFileName to ("icon_" & numHiResPx & "x" & numHiResPx & "@2x.png") as text
299      set ocidSaveIconSetFilePathURL to (ocidIconSetDirPathURL's URLByAppendingPathComponent:(strSaveImageFileName) isDirectory:(false))
300      set boolDone to (ocidSaveData's writeToURL:(ocidSaveIconSetFilePathURL) options:(refMe's NSDataWritingAtomic) |error|:(reference))
301      
302   end repeat
303   ##########################
304   #グラスサイズ作成
305   repeat with itemSizePx in listGlassSize
306      
307      #各サイズ作成
308      set ocidArtBordRep to (refMe's NSBitmapImageRep's alloc()'s initWithBitmapDataPlanes:(missing value) pixelsWide:(itemSizePx) pixelsHigh:(itemSizePx) bitsPerSample:(8.0) samplesPerPixel:(4.0) hasAlpha:(true) isPlanar:(false) colorSpaceName:(refMe's NSCalibratedRGBColorSpace) bitmapFormat:(refMe's NSBitmapFormatAlphaFirst) bytesPerRow:(0) bitsPerPixel:(32))
309      (ocidArtBordRep's setProperty:(refMe's NSImageColorSyncProfileData) withValue:(ocidProfileData))
310      
311      set ocidDrawRect to refMe's NSRect's NSMakeRect(0, 0, itemSizePx, itemSizePx)
312      
313      #▼編集開始
314      refMe's NSGraphicsContext's saveGraphicsState()
315      set ocidSetImageContext to (refMe's NSGraphicsContext's graphicsContextWithBitmapImageRep:(ocidArtBordRep))
316      (ocidSetImageContext's setImageInterpolation:(refMe's NSImageInterpolationHigh))
317      (ocidSetImageContext's setColorRenderingIntent:(refMe's NSColorRenderingIntentSaturation))
318      (ocidSetImageContext's setCompositingOperation:(refMe's NSCompositingOperationMultiply))
319      (ocidSetImageContext's setShouldAntialias:(true))
320      (refMe's NSGraphicsContext's setCurrentContext:(ocidSetImageContext))
321      (ocidFullImageRep's drawInRect:(ocidDrawRect) fromRect:(ocidFromRect) operation:(refMe's NSCompositingOperationDestinationOver) fraction:(1.0) respectFlipped:(false) hints:(missing value))
322      refMe's NSGraphicsContext's restoreGraphicsState()
323      #▲編集終了
324      
325      #通常の72ppiの保存
326      set ocidSetSizePx to refMe's NSSize's NSMakeSize(itemSizePx, itemSizePx)
327      (ocidArtBordRep's setSize:(ocidSetSizePx))
328      #保存PNGデータに
329      set ocidSaveData to (ocidArtBordRep's representationUsingType:(refMe's NSBitmapImageFileTypePNG) |properties|:(ocidPngProperty))
330      #保存
331      set strSaveFileName to ("icon_" & itemSizePx & "x" & itemSizePx & ".png")
332      set ocidSaveIconSetFilePathURL to (ocidMaterialDirPathURL's URLByAppendingPathComponent:(strSaveFileName) isDirectory:(false))
333      set boolDone to (ocidSaveData's writeToURL:(ocidSaveIconSetFilePathURL) options:(refMe's NSDataWritingAtomic) |error|:(reference))
334   end repeat
335   
336   ################## 
337   #ICNSファイル生成
338   set ocidIconSetDirPath to ocidIconSetDirPathURL's |path|()
339   set ocidSaveDirPath to ocidSaveDirPathURL's |path|()
340   set strLF to ("" & linefeed & "") as text
341   set strPyScripts to ("#!/usr/bin/env python3" & strLF & "# coding: utf-8" & strLF & "#/com.cocolog-nifty.quicktimer.icefloe" & strLF & "import sys" & strLF & "from PIL import Image" & strLF & "icon_files = {" & strLF & "    16:  \"" & ocidIconSetDirPath & "/icon_16x16.png\"," & strLF & "    24:  \"" & ocidIconSetDirPath & "/icon_24x24.png\"," & strLF & "    32:  \"" & ocidIconSetDirPath & "/icon_32x32.png\"," & strLF & "    48:  \"" & ocidIconSetDirPath & "/icon_48x48.png\"," & strLF & "    64:  \"" & ocidIconSetDirPath & "/icon_64x64.png\"," & strLF & "    128:  \"" & ocidIconSetDirPath & "/icon_128x128.png\"," & strLF & "    256: \"" & ocidIconSetDirPath & "/icon_256x256.png\"" & strLF & "}" & strLF & "images = [Image.open(path) for size, path in icon_files.items()]" & strLF & "images[-1].save(" & strLF & "    \"" & ocidSaveDirPath & "/favicon.ico\"," & strLF & "    format=\"ICO\"," & strLF & "    append_images=images[:-1]" & strLF & ")" & strLF & "for img in images:" & strLF & "    img.close()" & strLF & "") as text
342   
343   
344   set strCommandText to ("/usr/bin/python3 -c " & strPyScripts & "") as text
345   log return & strCommandText & return
346   set ocidPyScripts to refMe's NSString's stringWithString:(strPyScripts)
347   set ocidTermTask to refMe's NSTask's alloc()'s init()
348   ocidTermTask's setLaunchPath:("/usr/bin/python3")
349   set ocidArgumentsArray to refMe's NSMutableArray's alloc()'s init()
350   ocidArgumentsArray's addObject:("-c")
351   ocidArgumentsArray's addObject:(ocidPyScripts)
352   ocidTermTask's setArguments:(ocidArgumentsArray)
353   set ocidOutPut to refMe's NSPipe's pipe()
354   set ocidError to refMe's NSPipe's pipe()
355   ocidTermTask's setStandardOutput:(ocidOutPut)
356   ocidTermTask's setStandardError:(ocidError)
357   ocidTermTask's setCurrentDirectoryURL:(ocidSaveDirPathURL)
358   set listDoneReturn to ocidTermTask's launchAndReturnError:(reference)
359   if (item 1 of listDoneReturn) is (false) then
360      log "エラーコード:" & (item 2 of listDoneReturn)'s code() as text
361      log "エラードメイン:" & (item 2 of listDoneReturn)'s domain() as text
362      log "Description:" & (item 2 of listDoneReturn)'s localizedDescription() as text
363      log "FailureReason:" & (item 2 of listDoneReturn)'s localizedFailureReason() as text
364   end if
365   ##################
366   #終了待ち
367   ocidTermTask's waitUntilExit()
368   
369   
370   
371   return true
372end doMakeIcns
373
374
375
376
377##############################
378##############################
379to doQuitSelf()
380   try
381      tell application "System Events" to quit
382   end try
383   set listBundleID to {"com.apple.automator.xpc.runner", "com.apple.automator.xpc.workflowServiceRunner"} as list
384   repeat with itemBundleID in listBundleID
385      set ocidAppArray to (refMe's NSRunningApplication's runningApplicationsWithBundleIdentifier:(itemBundleID))
386      repeat with itemApp in ocidAppArray
387         try
388            set boolDone to itemApp's terminate()
389         end try
390      end repeat
391   end repeat
392end doQuitSelf
AppleScriptで生成しました