property gExceptDock : {"To Do"} -- set theResult to display dialog "背景をセットするドック名を入力して下さい。空で全部設定します。" default answer "" buttons {"キャンセル", "色指定して背景セット", "自動背景セット"} default button "自動背景セット" set dockName to text returned of theResult set pushButton to button returned of theResult if pushButton is "自動背景セット" then if dockName is "" then my setAllDockBackground() else my setDockBackground(dockName) end if say "mission complete" --終了をお知らせ else if pushButton is "色指定して背景セット" then set theResult to display dialog "色の番号を入力(1から8)" default answer "1" buttons {"キャンセル", "背景セット"} default button "背景セット" if button returned of theResult is "背景セット" then my setLayerBackground(dockName, 1, text returned of theResult as number) say "mission complete" --終了をお知らせ end if end if --my setLayerBackground("test", 1, 4) --my setLayerBackground("test2", 1, 3) --my setLayerBackground("test3", 1, 2) -- -- -- --以下関数 -- 色の最大数 property gMaxColor : 8 -- 二つ目の色を得る為に足す数 property gColor2offset : 8 on setAllDockBackground() tell application "DragThing" set x to count every dock repeat with x from 1 to x if normal dock is dock kind of dock x then if gExceptDock contains name of dock x is false then my setDockBackground(name of dock x) end if end if end repeat end tell end setAllDockBackground on setDockBackground(inDocName) tell application "DragThing" set layerX to count every layer of dock inDocName set colorIndex to 1 repeat with layerIndex from 1 to layerX my setLayerBackground(inDocName, layerIndex, colorIndex) set colorIndex to colorIndex + 1 if colorIndex > gMaxColor then set colorIndex to 1 end if end repeat end tell end setDockBackground on setLayerBackground(inDockName, inLayerIndex, inColorIndex) tell application "DragThing" set theDock to dock inDockName set theLayer to layer inLayerIndex of theDock set setColorName1 to name of dock colour inColorIndex set setColorName2 to name of dock colour (inColorIndex + gColor2offset) -- レイヤーの背景設定 set colour of theLayer to setColorName1 set style of theLayer to small button set texture of theLayer to "ブラシメタル" set texture mode of theLayer to normal -- 名前バーの背景設定 set name bar colour of theLayer to setColorName1 set name bar style of theLayer to window background set name bar texture of theLayer to "ブラシメタル" set name bar texture mode of theLayer to normal set yokoSlot to horizontal slots of theDock set color1 to 1 set slotx to count every slot of theLayer repeat with slotx from 1 to slotx set theSlot to slot slotx of theLayer --背景設定 set style of theSlot to small button set texture of theSlot to "ブラシメタル" set texture mode of theSlot to normal if slotx mod 2 = color1 then set colour of theSlot to setColorName1 else set colour of theSlot to setColorName2 end if --横の項目数が偶数のときは変わった時に --setColorName1を設定するslotx mod 2の値を --逆にしないとしましまにならない if yokoSlot mod 2 = 0 and slotx mod yokoSlot = 0 then if color1 = 1 then set color1 to 0 else set color1 to 1 end if end if end repeat end tell end setLayerBackground