Dockアイコンにプレグレスバーを描画するAppleScriptです。
書き方のクセがあからさまに違うこの内容は、Edama2さんからいただいたものですね、コレ。
AppleScript名:Dockアイコンにプログレスバーを追加 |
use AppleScript use framework "Foundation" use scripting additions on run set max to 100 repeat with num from 1 to max my progDockTile(max, num) delay 0.1 end repeat #アイコンを元に戻す current application’s NSApp’s setApplicationIconImage:(current application’s NSImage’s imageNamed:"NSApplicationIcon") end run #Dockアイコンにプログレスバーを追加 on progDockTile(max, current) set appIcon to current application’s NSImage’s imageNamed:"NSApplicationIcon" set iconSize to appIcon’s |size|() tell (current application’s NSImage’s alloc()’s initWithSize:iconSize) lockFocus() appIcon’s dissolveToPoint:(current application’s NSZeroPoint) fraction:1.0 set n to (iconSize’s width) / 16 #プログレスバーの長方形 set myRect to current application’s NSMakeRect(n / 2, n, n * 15, n * 1.6) –>{origin:{x:4.0, y:8.0}, |size|:{width:120.0, height:12.800000190735}} tell (current application’s NSBezierPath’s ¬ bezierPathWithRoundedRect:myRect ¬ xRadius:(myRect’s |size|’s height) / 2 ¬ yRadius:(myRect’s |size|’s height) / 2) current application’s (NSColor’s colorWithWhite:1.0 alpha:0.4)’s |set|() –>背景色 fill() current application’s NSColor’s whiteColor()’s |set|() –>枠色 stroke() end tell if current is greater than 0 then if current is greater than max then set current to max set myRect’s |size|’s width to (myRect’s |size|’s width) / max * current tell (current application’s NSBezierPath’s ¬ bezierPathWithRoundedRect:myRect ¬ xRadius:(myRect’s |size|’s height) / 2 ¬ yRadius:(myRect’s |size|’s height) / 2) set strartColor to current application’s NSColor’s colorWithRed:0.15 green:0.55 blue:1 alpha:0.8 set endColor to strartColor’s shadowWithLevel:0.7 set grad to current application’s NSGradient’s alloc()’s initWithStartingColor:strartColor endingColor:endColor grad’s drawInBezierPath:it angle:270.0 end tell end if unlockFocus() current application’s NSApp’s setApplicationIconImage:it end tell return (current + 1) end progDockTile |
More from my site
(Visited 151 times, 2 visits today)
Dockアイコンにプログレスバーを追加 v3 – AppleScriptの穴 says:
[…] グレスバーを描画して、プログレスバーの内容をアニメーションするAppleScriptです。以前のバージョンはmacOS 10.12以前の時代に書かれたものだったので、macOS 10.13以降の形式に書き換えま […]