AppleScript Photoshop

[Photoshop]基本:application

#!/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

######ログ表示
doLogView()

property objMe : a reference to current application


property objNSNotFound : a reference to 9.22337203685477E+18 + 5807


tell application "Adobe Photoshop 2022"
#########################読み取りのみ
##log properties as record
log frontmost as boolean
log name as text
log version as text
log build as text
log scripting version as text
log scripting build date as text
log free memory as number

log default type as list
log windows file types as list
log macintosh file types as list
log system information as text
##log recent files as list
log locale as text
#########################設定可能
log display dialogs as text
-->(always/‌error dialogs/‌never)
##set always to display dialogs

log current tool as text

set listToolName to {"ArtHistoryBrushTool", "3DFOVTool", "3DObjectPanTool", "3DObjectRollTool", "3DObjectRotateTool", "3DObjectScaleTool", "3DObjectSlideTool", "3DOrbitCameraTool", "3DPanCameraTool", "3DRollCameraTool", "3DWalkCameraTool", "addKnotTool", "artBrushTool", "backgroundEraserTool", "blurTool", "bucketTool", "burnInTool", "cloneStampTool", "colorReplacementBrushTool", "colorSamplerTool", "convertKnotTool", "countTool", "cookieCutterTool", "cropTool", "customShapeTool", "deleteKnotTool", "directSelectTool", "dodgeTool", "ellipseTool", "eraserTool", "eyedropperTool", "freeformPenTool", "gradientTool", "handTool", "historyBrushTool", "lassoTool", "lineTool", "magicEraserTool", "magicStampTool", "magicWandTool", "magneticLassoTool", "marqueeEllipTool", "marqueeRectTool", "marqueeSingleColumnTool", "marqueeSingleRowTool", "moveTool", "paintbrushTool", "patchSelection", "pathComponentSelectTool", "patternStampTool", "penTool", "pencilTool", "polySelTool", "polygonTool", "quickSelectTool", "rectangleTool", "redEyeTool", "rotateTool", "roundedRectangleTool", "rulerTool", "saturationTool", "sharpenTool", "sliceSelectTool", "sliceTool", "smudgeTool", "spotHealingBrushTool", "textAnnotTool", "typeCreateMaskTool", "typeCreateOrEditTool", "typeVerticalCreateMaskTool", "typeVerticalCreateOrEditTool", "wetBrushTool", "zoomTool"}

try
set objResponse to (choose from list listToolName with title "短め" with prompt "長め" default items (item 1 of listToolName) OK button name "OK" cancel button name "キャンセル" with multiple selections allowed without empty selection allowed)
on error
log "エラーしました"
return
end try
if objResponse is false then
return
end if

set theResponse to (objResponse) as text

set current tool to theResponse

log current document as list

####塗りのデフォルトカラー
log foreground color as record
set recordForeColor to {class:RGB color, red:255, green:255, blue:255}
set foreground color to recordForeColor
set recordForeColor to {class:CMYK color, cyan:0.0, magenta:0.0, yellow:0.0, black:0.0}
set foreground color to recordForeColor

###背景色のデフォルトカラー
log background color as record
set recordBackgroundColor to {class:RGB color, red:255, green:255, blue:255}
set background color to recordBackgroundColor
set recordBackgroundColor to {class:CMYK color, cyan:0.0, magenta:0.0, yellow:0.0, black:0.0}
set background color to recordBackgroundColor

log color settings as list

####通知設定
set boolNotifiers to notifiers enabled as boolean
if boolNotifiers is false then
set notifiers enabled to true as boolean
else
set notifiers enabled to false as boolean
end if


log preferences folder as alias
###設定フォルダを開く
set aliasPrefDir to preferences folder as alias
tell application "Finder"
make new Finder window to aliasPrefDir
select folder aliasPrefDir
end tell

end tell











display notification "処理終了" with title "処理が終了" subtitle "処理が終了しました" sound name "Sonumi"
log ">>>>>>>>>>>>処理終了<<<<<<<<<<<<<<<"
return ">>>>>>>>>>>>処理終了<<<<<<<<<<<<<<<"




#########################ログ表示
to doLogView()

tell application "System Events"
set listAppList to title of (every process where background only is false)
end tell
repeat with objAppList in listAppList
set strAppList to objAppList as text
if strAppList is "スクリプトエディタ" then
tell application "Script Editor"
if frontmost is true then
try
tell application "System Events" to click menu item "ログを表示" of menu "表示" of menu bar item "表示" of menu bar 1 of application process "Script Editor"
end try
end if
end tell
end if
end repeat

end doLogView
#########################

|

[Photoshop]レイヤの名前をつける(自分用)

レイヤの名前やIDを指定して、他の処理に渡す時用


#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#レイヤグループ(Layer Set)の入れ子ネスト構造は5階層まで対応
#
#
# 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

tell application "System Events"
set listAppList to title of (every process where background only is false)
end tell
repeat with objAppList in listAppList
set strAppList to objAppList as text
if strAppList is "スクリプトエディタ" then
tell application "Script Editor"
if frontmost is true then
try
tell application "System Events" to click menu item "ログを表示" of menu "表示" of menu bar item "表示" of menu bar 1 of application process "Script Editor"
end try
end if
end tell
end if
end repeat


tell application "Adobe Photoshop 2022"
###全面ドキュメントを定義
set objActivDoc to current document
###全面ドキュメント
tell objActivDoc
####アクティブレイヤ
set objActivLayer to current layer
####レイヤ判定時にはIDを使うといいよ
####選択中のレイヤのID
####set numActivLayerID to id of objActivLayer
####
set listEveryLayerSet to every layer set as list
log listEveryLayerSet
##
set numCntEveryLayerSet to (count of listEveryLayerSet) as number
########ROOT
if numCntEveryLayerSet > 0 then
repeat with objLayerSet in listEveryLayerSet
tell objLayerSet
set numLayerSetID to id
set name to ("LayerSet-" & numLayerSetID & "") as text
set listEveryArtLayer to every art layer as list
repeat with objArtLayer in listEveryArtLayer
tell objArtLayer
set numArtLayerID to id
set name to ("ArtLayer-" & numArtLayerID & "") as text
end tell
end repeat
########1階層目
set listEveryLayerSet1 to every layer set as list
set numCntEveryLayerSet1 to (count of listEveryLayerSet1) as number
if numCntEveryLayerSet1 > 0 then
repeat with objLayerSet1 in listEveryLayerSet1
tell objLayerSet1
set numLayerSetID to id
set name to ("LayerSet-" & numLayerSetID & "") as text
set listEveryArtLayer1 to every art layer as list
repeat with objArtLayer1 in listEveryArtLayer1
tell objArtLayer1
set numArtLayerID to id
set name to ("ArtLayer-" & numArtLayerID & "") as text
end tell
end repeat
########2階層目
set listEveryLayerSet2 to every layer set as list
log listEveryLayerSet2
set numCntEveryLayerSet2 to (count of listEveryLayerSet2) as number
if numCntEveryLayerSet2 > 0 then
repeat with objLayerSet2 in listEveryLayerSet2
tell objLayerSet2
set numLayerSetID to id
set name to ("LayerSet-" & numLayerSetID & "") as text
set listEveryArtLayer2 to every art layer as list
repeat with objArtLayer2 in listEveryArtLayer2
tell objArtLayer2
set numArtLayerID to id
set name to ("ArtLayer-" & numArtLayerID & "") as text
end tell
end repeat
########3階層目
set listEveryLayerSet3 to every layer set as list
set numCntEveryLayerSet3 to (count of listEveryLayerSet3) as number
if numCntEveryLayerSet3 > 0 then
repeat with objLayerSet3 in listEveryLayerSet3
tell objLayerSet3
set numLayerSetID to id
set name to ("LayerSet-" & numLayerSetID & "") as text
set listEveryArtLayer3 to every art layer as list
repeat with objArtLayer3 in listEveryArtLayer3
tell objArtLayer3
set numArtLayerID to id
set name to ("ArtLayer-" & numArtLayerID & "") as text
end tell
end repeat
########4階層目
set listEveryLayerSet4 to every layer set as list
set numCntEveryLayerSet4 to (count of listEveryLayerSet4) as number
if numCntEveryLayerSet4 > 0 then
repeat with objLayerSet4 in listEveryLayerSet4
tell objLayerSet4
set numLayerSetID to id
set name to ("LayerSet-" & numLayerSetID & "") as text
set listEveryArtLayer4 to every art layer as list
repeat with objArtLayer4 in listEveryArtLayer4
tell objArtLayer4
set numArtLayerID to id
set name to ("ArtLayer-" & numArtLayerID & "") as text
end tell
end repeat
########5階層目
set listEveryLayerSet5 to every layer set as list
set numCntEveryLayerSet5 to (count of listEveryLayerSet5) as number
if numCntEveryLayerSet5 > 0 then
repeat with objLayerSet5 in listEveryLayerSet5
tell objLayerSet5
set numLayerSetID to id
set name to ("LayerSet-" & numLayerSetID & "") as text
set listEveryArtLayer5 to every art layer as list
repeat with objArtLayer5 in listEveryArtLayer5
tell objArtLayer5
set numArtLayerID to id
set name to ("ArtLayer-" & numArtLayerID & "") as text
end tell
end repeat
end tell
end repeat
end if
################5階層目
end tell
end repeat
end if
################4階層目
end tell
end repeat
end if
################3階層目
end tell
end repeat
end if
################2階層目
end tell
end repeat
end if
################1階層目
end tell
end repeat
########レイヤーセットのネストの終了
end if
#######通常のROOTにあるレイヤ
set listEveryArtLayer to every art layer as list
repeat with objArtLayer in listEveryArtLayer
if background layer of objArtLayer is false then
tell objArtLayer
set objkindArtLayer to kind of objArtLayer
set numArtLayerID to id of objArtLayer
if objkindArtLayer is text layer then
set name to ("TextLayer-" & numArtLayerID & "") as text
##set name to ("テキスト:" & numArtLayerID & "") as text
else if objkindArtLayer is levels layer then
set name to ("LevelsLayer-" & numArtLayerID & "") as text
##set name to ("レベル補正:" & numArtLayerID & "") as text
else if objkindArtLayer is curves layer then
set name to ("CurvesLayer-" & numArtLayerID & "") as text
##set name to ("トーンカーブ:" & numArtLayerID & "") as text
else if objkindArtLayer is exposure layer then
set name to ("露光Layer-" & numArtLayerID & "") as text
##set name to ("トーンカーブ:" & numArtLayerID & "") as text
else if objkindArtLayer is gradient fill layer then
set name to ("GradientFillLayer-" & numArtLayerID & "") as text
##set name to ("グラデーション:" & numArtLayerID & "") as text
else if objkindArtLayer is solid fill layer then
set name to ("SolidFillLayer-" & numArtLayerID & "") as text
##set name to ("単色塗り:" & numArtLayerID & "") as text
else if objkindArtLayer is pattern fill layer then
set name to ("PatternFillLayer-" & numArtLayerID & "") as text
##set name to ("パータン塗り:" & numArtLayerID & "") as text
else if objkindArtLayer is brightness contrast layer then
set name to ("BrightContrastLayer-" & numArtLayerID & "") as text
##set name to ("明るさコントラスト:" & numArtLayerID & "") as text
else if objkindArtLayer is vibrance layer then
set name to ("VibranceLayer-" & numArtLayerID & "") as text
##set name to ("自然な彩度:" & numArtLayerID & "") as text
else if objkindArtLayer is hue saturation layer then
set name to ("HueLayer-" & numArtLayerID & "") as text
##set name to ("色相彩度:" & numArtLayerID & "") as text
else if objkindArtLayer is color balance layer then
set name to ("ColorBalanceLayer-" & numArtLayerID & "") as text
##set name to ("カラーバランス:" & numArtLayerID & "") as text
else if objkindArtLayer is black and white layer then
set name to ("BWLayer-" & numArtLayerID & "") as text
##set name to ("白黒:" & numArtLayerID & "") as text
else if objkindArtLayer is photo filter layer then
set name to ("PhotoFilterLayer-" & numArtLayerID & "") as text
##set name to ("レンズフィルタ:" & numArtLayerID & "") as text
else if objkindArtLayer is channel mixer layer then
set name to ("ChannelMixerLayer-" & numArtLayerID & "") as text
##set name to ("チャンネルミキサー:" & numArtLayerID & "") as text
else if objkindArtLayer is color lookup then
set name to ("ColorLookupLayer-" & numArtLayerID & "") as text
##set name to ("カラールックアップ:" & numArtLayerID & "") as text
else if objkindArtLayer is inversion layer then
set name to ("InversionLayer-" & numArtLayerID & "") as text
##set name to ("反転:" & numArtLayerID & "") as text
else if objkindArtLayer is posterize layer then
set name to ("PosterizeLayer-" & numArtLayerID & "") as text
##set name to ("ポスタリゼーション:" & numArtLayerID & "") as text
else if objkindArtLayer is threshold layer then
set name to ("ThresholdLayer-" & numArtLayerID & "") as text
##set name to ("2階調:" & numArtLayerID & "") as text
else if objkindArtLayer is gradient map layer then
set name to ("GradientMapLayer-" & numArtLayerID & "") as text
##set name to ("グラデーションマップ:" & numArtLayerID & "") as text
else if objkindArtLayer is selective color layer then
set name to ("SelectiveColorLayer-" & numArtLayerID & "") as text
##set name to ("特色:" & numArtLayerID & "") as text
else if objkindArtLayer is smart object layer then
set name to ("SmartObjectLayer-" & numArtLayerID & "") as text
##set name to ("スマートオブジェクト:" & numArtLayerID & "") as text
else
set name to ("ArtLayer-" & numArtLayerID & "") as text
##set name to ("アートレイヤ:" & numArtLayerID & "") as text
end if

###リンクレイヤーにLをつける
set objLinkLayer to linked layers of objArtLayer
if objLinkLayer is not {} then
set name to ("" & name & "L") as text
end if

end tell




end if

end repeat

end tell
end tell

|

[Photoshop]選択レイヤをロックして、それ以外はロック解除

レイヤグループ(Layer Set)の入れ子ネスト構造は5階層まで対応

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#レイヤグループ(Layer Set)の入れ子ネスト構造は5階層まで対応
#
#
# 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

tell application "System Events"
set listAppList to title of (every process where background only is false)
end tell
repeat with objAppList in listAppList
set strAppList to objAppList as text
if strAppList is "スクリプトエディタ" then
tell application "Script Editor"
if frontmost is true then
try
tell application "System Events" to click menu item "ログを表示" of menu "表示" of menu bar item "表示" of menu bar 1 of application process "Script Editor"
end try
end if
end tell
end if
end repeat


tell application "Adobe Photoshop 2022"
###全面ドキュメントを定義
set objActivDoc to current document
###全面ドキュメント
tell objActivDoc
####アクティブレイヤ
set objActivLayer to current layer

####レイヤ判定時にはIDを使うといいよ
####選択中のレイヤのID
####set numActivLayerID to id of objActivLayer
####
set listEveryLayerSet to every layer set as list
log listEveryLayerSet
##
set numCntEveryLayerSet to (count of listEveryLayerSet) as number
########ROOT
if numCntEveryLayerSet > 0 then
repeat with objLayerSet in listEveryLayerSet
tell objLayerSet
set listEveryArtLayer to every art layer as list
repeat with objArtLayer in listEveryArtLayer
tell objArtLayer
set all locked to false
end tell
end repeat
########1階層目
set listEveryLayerSet1 to every layer set as list
set numCntEveryLayerSet1 to (count of listEveryLayerSet1) as number
if numCntEveryLayerSet1 > 0 then
repeat with objLayerSet1 in listEveryLayerSet1
tell objLayerSet1
set listEveryArtLayer1 to every art layer as list
repeat with objArtLayer1 in listEveryArtLayer1
tell objArtLayer1
set all locked to false
end tell
end repeat
########2階層目
set listEveryLayerSet2 to every layer set as list
log listEveryLayerSet2
set numCntEveryLayerSet2 to (count of listEveryLayerSet2) as number
if numCntEveryLayerSet2 > 0 then
repeat with objLayerSet2 in listEveryLayerSet2
tell objLayerSet2
set listEveryArtLayer2 to every art layer as list
repeat with objArtLayer2 in listEveryArtLayer2
tell objArtLayer2
set all locked to false
end tell
end repeat
########3階層目
set listEveryLayerSet3 to every layer set as list
set numCntEveryLayerSet3 to (count of listEveryLayerSet3) as number
if numCntEveryLayerSet3 > 0 then
repeat with objLayerSet3 in listEveryLayerSet3
tell objLayerSet3
set listEveryArtLayer3 to every art layer as list
repeat with objArtLayer3 in listEveryArtLayer3
tell objArtLayer3
set all locked to false
end tell
end repeat
########4階層目
set listEveryLayerSet4 to every layer set as list
set numCntEveryLayerSet4 to (count of listEveryLayerSet4) as number
if numCntEveryLayerSet4 > 0 then
repeat with objLayerSet4 in listEveryLayerSet4
tell objLayerSet4
set listEveryArtLayer4 to every art layer as list
repeat with objArtLayer4 in listEveryArtLayer4
tell objArtLayer4
set all locked to false
end tell
end repeat
########5階層目
set listEveryLayerSet5 to every layer set as list
set numCntEveryLayerSet5 to (count of listEveryLayerSet5) as number
if numCntEveryLayerSet5 > 0 then
repeat with objLayerSet5 in listEveryLayerSet5
tell objLayerSet5
set listEveryArtLayer5 to every art layer as list
repeat with objArtLayer5 in listEveryArtLayer5
tell objArtLayer5
set all locked to false
end tell
end repeat
set all locked to false
end tell
end repeat
end if
################5階層目
set all locked to false
end tell
end repeat
end if
################4階層目
set all locked to false
end tell
end repeat
end if
################3階層目
set all locked to false
end tell
end repeat
end if
################2階層目
set all locked to false
end tell
end repeat
end if
################1階層目
end tell
end repeat
########レイヤーセットのネストの終了
end if
#######通常のROOTにあるレイヤ
set listEveryArtLayer to every art layer as list
repeat with objArtLayer in listEveryArtLayer
tell objArtLayer
set all locked to false
end tell
end repeat
######ロック終了
####選択中のレイヤのみロック解除
if background layer of objActivLayer is false then
tell objActivLayer
set all locked to true
end tell
end if
end tell
end tell

|

[Photoshop]レイヤロック

レイヤグループ(Layer Set)の入れ子ネスト構造は5階層まで対応

#!/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

tell application "System Events"
set listAppList to title of (every process where background only is false)
end tell
repeat with objAppList in listAppList
set strAppList to objAppList as text
if strAppList is "スクリプトエディタ" then
tell application "Script Editor"
if frontmost is true then
try
tell application "System Events" to click menu item "ログを表示" of menu "表示" of menu bar item "表示" of menu bar 1 of application process "Script Editor"
end try
end if
end tell
end if
end repeat


tell application "Adobe Photoshop 2022"
###全面ドキュメントを定義
set objActivDoc to current document
###全面ドキュメント
tell objActivDoc
####アクティブレイヤ
set objActivLayer to current layer
####レイヤ判定時にはIDを使うといいよ
####選択中のレイヤのID
####set numActivLayerID to id of objActivLayer
####
set listEveryLayerSet to every layer set as list
log listEveryLayerSet
##
set numCntEveryLayerSet to (count of listEveryLayerSet) as number
########ROOT
if numCntEveryLayerSet > 0 then
repeat with objLayerSet in listEveryLayerSet
tell objLayerSet
set listEveryArtLayer to every art layer as list
repeat with objArtLayer in listEveryArtLayer
tell objArtLayer
set all locked to true
end tell
end repeat
########1階層目
set listEveryLayerSet1 to every layer set as list
set numCntEveryLayerSet1 to (count of listEveryLayerSet1) as number
if numCntEveryLayerSet1 > 0 then
repeat with objLayerSet1 in listEveryLayerSet1
tell objLayerSet1
set listEveryArtLayer1 to every art layer as list
repeat with objArtLayer1 in listEveryArtLayer1
tell objArtLayer1
set all locked to true
end tell
end repeat
########2階層目
set listEveryLayerSet2 to every layer set as list
log listEveryLayerSet2
set numCntEveryLayerSet2 to (count of listEveryLayerSet2) as number
if numCntEveryLayerSet2 > 0 then
repeat with objLayerSet2 in listEveryLayerSet2
tell objLayerSet2
set listEveryArtLayer2 to every art layer as list
repeat with objArtLayer2 in listEveryArtLayer2
tell objArtLayer2
set all locked to true
end tell
end repeat
########3階層目
set listEveryLayerSet3 to every layer set as list
set numCntEveryLayerSet3 to (count of listEveryLayerSet3) as number
if numCntEveryLayerSet3 > 0 then
repeat with objLayerSet3 in listEveryLayerSet3
tell objLayerSet3
set listEveryArtLayer3 to every art layer as list
repeat with objArtLayer3 in listEveryArtLayer3
tell objArtLayer3
set all locked to true
end tell
end repeat
########4階層目
set listEveryLayerSet4 to every layer set as list
set numCntEveryLayerSet4 to (count of listEveryLayerSet4) as number
if numCntEveryLayerSet4 > 0 then
repeat with objLayerSet4 in listEveryLayerSet4
tell objLayerSet4
set listEveryArtLayer4 to every art layer as list
repeat with objArtLayer4 in listEveryArtLayer4
tell objArtLayer4
set all locked to true
end tell
end repeat
########5階層目
set listEveryLayerSet5 to every layer set as list
set numCntEveryLayerSet5 to (count of listEveryLayerSet5) as number
if numCntEveryLayerSet5 > 0 then
repeat with objLayerSet5 in listEveryLayerSet5
tell objLayerSet5
set listEveryArtLayer5 to every art layer as list
repeat with objArtLayer5 in listEveryArtLayer5
tell objArtLayer5
set all locked to true
end tell
end repeat
set all locked to true
end tell
end repeat
end if
################5階層目
set all locked to true
end tell
end repeat
end if
################4階層目
set all locked to true
end tell
end repeat
end if
################3階層目
set all locked to true
end tell
end repeat
end if
################2階層目
set all locked to true
end tell
end repeat
end if
################1階層目
end tell
end repeat
########レイヤーセットのネストの終了
end if
#######通常のROOTにあるレイヤ
set listEveryArtLayer to every art layer as list
repeat with objArtLayer in listEveryArtLayer
if background layer of objActivLayer is false then
tell objArtLayer
set all locked to true
end tell
end if
end repeat

end tell
end tell

|

[Photoshop]レイヤロック解除

レイヤグループ(Layer Set)の入れ子ネスト構造は5階層まで対応

#!/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

tell application "System Events"
set listAppList to title of (every process where background only is false)
end tell
repeat with objAppList in listAppList
set strAppList to objAppList as text
if strAppList is "スクリプトエディタ" then
tell application "Script Editor"
if frontmost is true then
try
tell application "System Events" to click menu item "ログを表示" of menu "表示" of menu bar item "表示" of menu bar 1 of application process "Script Editor"
end try
end if
end tell
end if
end repeat


tell application "Adobe Photoshop 2022"
###全面ドキュメントを定義
set objActivDoc to current document
###全面ドキュメント
tell objActivDoc
####アクティブレイヤ
set objActivLayer to current layer
####レイヤ判定時にはIDを使うといいよ
####選択中のレイヤのID
####set numActivLayerID to id of objActivLayer
####
set listEveryLayerSet to every layer set as list
log listEveryLayerSet
##
set numCntEveryLayerSet to (count of listEveryLayerSet) as number
########ROOT
if numCntEveryLayerSet > 0 then
repeat with objLayerSet in listEveryLayerSet
tell objLayerSet
set listEveryArtLayer to every art layer as list
repeat with objArtLayer in listEveryArtLayer
tell objArtLayer
set all locked to false
end tell
end repeat
########1階層目
set listEveryLayerSet1 to every layer set as list
set numCntEveryLayerSet1 to (count of listEveryLayerSet1) as number
if numCntEveryLayerSet1 > 0 then
repeat with objLayerSet1 in listEveryLayerSet1
tell objLayerSet1
set listEveryArtLayer1 to every art layer as list
repeat with objArtLayer1 in listEveryArtLayer1
tell objArtLayer1
set all locked to false
end tell
end repeat
########2階層目
set listEveryLayerSet2 to every layer set as list
log listEveryLayerSet2
set numCntEveryLayerSet2 to (count of listEveryLayerSet2) as number
if numCntEveryLayerSet2 > 0 then
repeat with objLayerSet2 in listEveryLayerSet2
tell objLayerSet2
set listEveryArtLayer2 to every art layer as list
repeat with objArtLayer2 in listEveryArtLayer2
tell objArtLayer2
set all locked to false
end tell
end repeat
########3階層目
set listEveryLayerSet3 to every layer set as list
set numCntEveryLayerSet3 to (count of listEveryLayerSet3) as number
if numCntEveryLayerSet3 > 0 then
repeat with objLayerSet3 in listEveryLayerSet3
tell objLayerSet3
set listEveryArtLayer3 to every art layer as list
repeat with objArtLayer3 in listEveryArtLayer3
tell objArtLayer3
set all locked to false
end tell
end repeat
########4階層目
set listEveryLayerSet4 to every layer set as list
set numCntEveryLayerSet4 to (count of listEveryLayerSet4) as number
if numCntEveryLayerSet4 > 0 then
repeat with objLayerSet4 in listEveryLayerSet4
tell objLayerSet4
set listEveryArtLayer4 to every art layer as list
repeat with objArtLayer4 in listEveryArtLayer4
tell objArtLayer4
set all locked to false
end tell
end repeat
########5階層目
set listEveryLayerSet5 to every layer set as list
set numCntEveryLayerSet5 to (count of listEveryLayerSet5) as number
if numCntEveryLayerSet5 > 0 then
repeat with objLayerSet5 in listEveryLayerSet5
tell objLayerSet5
set listEveryArtLayer5 to every art layer as list
repeat with objArtLayer5 in listEveryArtLayer5
tell objArtLayer5
set all locked to false
end tell
end repeat
set all locked to false
end tell
end repeat
end if
################5階層目
set all locked to false
end tell
end repeat
end if
################4階層目
set all locked to false
end tell
end repeat
end if
################3階層目
set all locked to false
end tell
end repeat
end if
################2階層目
set all locked to false
end tell
end repeat
end if
################1階層目
end tell
end repeat
########レイヤーセットのネストの終了
end if
#######通常のROOTにあるレイヤ
set listEveryArtLayer to every art layer as list
repeat with objArtLayer in listEveryArtLayer
tell objArtLayer
set all locked to false
end tell
end repeat

end tell
end tell

|

[Photoshop]選択レイヤ以外をロック

レイヤグループ(Layer Set)の入れ子ネスト構造は5階層まで対応

#!/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

tell application "System Events"
set listAppList to title of (every process where background only is false)
end tell
repeat with objAppList in listAppList
set strAppList to objAppList as text
if strAppList is "スクリプトエディタ" then
tell application "Script Editor"
if frontmost is true then
try
tell application "System Events" to click menu item "ログを表示" of menu "表示" of menu bar item "表示" of menu bar 1 of application process "Script Editor"
end try
end if
end tell
end if
end repeat


tell application "Adobe Photoshop 2022"
###全面ドキュメントを定義
set objActivDoc to current document
###全面ドキュメント
tell objActivDoc
####アクティブレイヤ
set objActivLayer to current layer
####処理しないパターン
set onjClassOfActivLayer to class of objActivLayer
if onjClassOfActivLayer is equal to layer set then
return "選択レイヤがレイヤセットの時は処理しない"
else if background layer of objActivLayer is true then
return "選択レイヤが背景の時は処理しない"
end if
####レイヤ判定時にはIDを使うといいよ
####選択中のレイヤのID
####set numActivLayerID to id of objActivLayer
####
set listEveryLayerSet to every layer set as list
log listEveryLayerSet
##
set numCntEveryLayerSet to (count of listEveryLayerSet) as number
########ROOT
if numCntEveryLayerSet > 0 then
repeat with objLayerSet in listEveryLayerSet
tell objLayerSet
set listEveryArtLayer to every art layer as list
repeat with objArtLayer in listEveryArtLayer
tell objArtLayer
set all locked to true
end tell
end repeat
########1階層目
set listEveryLayerSet1 to every layer set as list
set numCntEveryLayerSet1 to (count of listEveryLayerSet1) as number
if numCntEveryLayerSet1 > 0 then
repeat with objLayerSet1 in listEveryLayerSet1
tell objLayerSet1
set listEveryArtLayer1 to every art layer as list
repeat with objArtLayer1 in listEveryArtLayer1
tell objArtLayer1
set all locked to true
end tell
end repeat
########2階層目
set listEveryLayerSet2 to every layer set as list
log listEveryLayerSet2
set numCntEveryLayerSet2 to (count of listEveryLayerSet2) as number
if numCntEveryLayerSet2 > 0 then
repeat with objLayerSet2 in listEveryLayerSet2
tell objLayerSet2
set listEveryArtLayer2 to every art layer as list
repeat with objArtLayer2 in listEveryArtLayer2
tell objArtLayer2
set all locked to true
end tell
end repeat
########3階層目
set listEveryLayerSet3 to every layer set as list
set numCntEveryLayerSet3 to (count of listEveryLayerSet3) as number
if numCntEveryLayerSet3 > 0 then
repeat with objLayerSet3 in listEveryLayerSet3
tell objLayerSet3
set listEveryArtLayer3 to every art layer as list
repeat with objArtLayer3 in listEveryArtLayer3
tell objArtLayer3
set all locked to true
end tell
end repeat
########4階層目
set listEveryLayerSet4 to every layer set as list
set numCntEveryLayerSet4 to (count of listEveryLayerSet4) as number
if numCntEveryLayerSet4 > 0 then
repeat with objLayerSet4 in listEveryLayerSet4
tell objLayerSet4
set listEveryArtLayer4 to every art layer as list
repeat with objArtLayer4 in listEveryArtLayer4
tell objArtLayer4
set all locked to true
end tell
end repeat
########5階層目
set listEveryLayerSet5 to every layer set as list
set numCntEveryLayerSet5 to (count of listEveryLayerSet5) as number
if numCntEveryLayerSet5 > 0 then
repeat with objLayerSet5 in listEveryLayerSet5
tell objLayerSet5
set listEveryArtLayer5 to every art layer as list
repeat with objArtLayer5 in listEveryArtLayer5
tell objArtLayer5
set all locked to true
end tell
end repeat
##set all locked to true
end tell
end repeat
end if
################5階層目
##set all locked to true
end tell
end repeat
end if
################4階層目
##set all locked to true
end tell
end repeat
end if
################3階層目
##set all locked to true
end tell
end repeat
end if
################2階層目
##set all locked to true
end tell
end repeat
end if
################1階層目
end tell
end repeat
########レイヤーセットのネストの終了
end if
#######通常のROOTにあるレイヤ
set listEveryArtLayer to every art layer as list
repeat with objArtLayer in listEveryArtLayer
tell objArtLayer
set all locked to true
end tell
end repeat
######ロック終了
####選択中のレイヤのみロック解除
tell objActivLayer
set all locked to false
end tell
end tell
end tell

|

[Photoshop]選択レイヤを『背景』レイヤに

#!/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

tell application "Adobe Photoshop 2022"
###全面ドキュメントを定義
set objActivDoc to current document
###全面ドキュメント
tell objActivDoc
####アクティブレイヤ
set objActivLayer to current layer
tell objActivLayer
####背景にする
set background layer to true
end tell
end tell
end tell

|

その他のカテゴリー

Acrobat Acrobat Annotation Acrobat Dialog Acrobat Form Acrobat JS Acrobat Open Acrobat Plugin Acrobat python Acrobat Reader Acrobat Sequ Acrobat Stamps Admin Admin Account Admin Apachectl Admin configCode Admin Device Management Admin LaunchServices Admin Locationd Admin loginitem Admin Maintenance Admin Permission Admin Pkg Admin Power Management Admin Printer Admin SetUp Admin SMB Admin System Information Admin Tools Admin Users Admin Volumes Adobe Apple AppleScript AppleScript Guide AppleScript Accessibility AppleScript AppKit AppleScript Applications AppleScript AppStore AppleScript Archive AppleScript Attributes AppleScript Automator AppleScript AVAsset AppleScript AVconvert AppleScript AVFoundation AppleScript AVURLAsset AppleScript BackUp AppleScript Barcode AppleScript Bash AppleScript Basic AppleScript Basic Path AppleScript Bluetooth AppleScript BOX AppleScript Browser AppleScript Calendar AppleScript CD/DVD AppleScript Choose AppleScript Chrome AppleScript CIImage AppleScript CloudStorage AppleScript Color AppleScript com.apple.LaunchServices.OpenWith AppleScript Console AppleScript Contacts AppleScript CotEditor AppleScript CURL AppleScript current application AppleScript Date&Time AppleScript delimiters AppleScript Desktop AppleScript Device AppleScript Disk AppleScript do shell script AppleScript Dock AppleScript DropBox AppleScript eMail AppleScript Encode Decode AppleScript Error AppleScript EXIFData AppleScript ffmpeg AppleScript File AppleScript Finder AppleScript Firefox AppleScript Folder AppleScript Fonts AppleScript GIF AppleScript HTML AppleScript Icon AppleScript Illustrator AppleScript Image Events AppleScript Image2PDF AppleScript ImageOptim Applescript iWork AppleScript Javascript AppleScript Jedit AppleScript Json AppleScript Label AppleScript List AppleScript locationd AppleScript LRC AppleScript LSSharedFileList AppleScript m3u8 AppleScript MakePDF AppleScript Map AppleScript Math AppleScript Microsoft AppleScript Microsoft Edge AppleScript Microsoft Excel AppleScript Mobileconfig AppleScript Mouse AppleScript Movie AppleScript Music AppleScript NetWork AppleScript Notes AppleScript NSArray AppleScript NSBitmapImageRep AppleScript NSBundle AppleScript NSCFBoolean AppleScript NSCharacterSet AppleScript NSColor AppleScript NSColorList AppleScript NSData AppleScript NSDictionary AppleScript NSError AppleScript NSEvent AppleScript NSFileAttributes AppleScript NSFileManager AppleScript NSFont AppleScript NSFontManager AppleScript NSImage AppleScript NSIndex AppleScript NSKeyedArchiver AppleScript NSKeyedUnarchiver AppleScript NSLocale AppleScript NSMutableArray AppleScript NSMutableDictionary AppleScript NSMutableString AppleScript NSNotFound AppleScript NSNumber AppleScript NSOpenPanel AppleScript NSPasteboard AppleScript NSPDFImageRep AppleScript NSpoint AppleScript NSPredicate AppleScript NSRange AppleScript NSRegularExpression AppleScript NSRunningApplication AppleScript NSScreen AppleScript NSSize AppleScript NSString AppleScript NSStringCompareOptions AppleScript NSTask AppleScript NSTimeZone AppleScript NSURL AppleScript NSURL File AppleScript NSURLBookmark AppleScript NSURLComponents AppleScript NSURLResourceKey AppleScript NSUserDefaults AppleScript NSUUID AppleScript NSView AppleScript NSWorkspace AppleScript Numbers AppleScript OAuth AppleScript ObjC AppleScript OneDrive AppleScript Osax AppleScript PDF AppleScript PDFAnnotationWidget AppleScript PDFContext AppleScript PDFDisplayBox AppleScript PDFDocumentPermissions AppleScript PDFKit AppleScript PDFnUP AppleScript PDFOutline AppleScript Photos AppleScript Photoshop AppleScript Plist System Events AppleScript PostScript AppleScript prefPane AppleScript Preview AppleScript Python AppleScript QR AppleScript QR Decode AppleScript QuickLook AppleScript QuickTime AppleScript record AppleScript Regular Expression AppleScript Reminders AppleScript ReName AppleScript Repeat AppleScript RTF AppleScript Safari AppleScript SaveFile AppleScript ScreenCapture AppleScript ScreenSaver AppleScript Script Editor AppleScript Script Menu AppleScript Shortcuts AppleScript Shortcuts Events AppleScript Sort AppleScript Sound AppleScript Spotlight AppleScript SRT AppleScript StandardAdditions AppleScript stringByApplyingTransform AppleScript System Events AppleScript System Settings AppleScript TemporaryItems AppleScript Terminal AppleScript Text AppleScript Text CSV AppleScript Text TSV AppleScript TextEdit AppleScript Translate AppleScript Trash AppleScript Twitter AppleScript UI AppleScript Unit Conversion AppleScript UTType AppleScript valueForKeyPath AppleScript Video AppleScript VisionKit AppleScript Visual Studio Code AppleScript webarchive AppleScript webp AppleScript Wifi AppleScript XML AppleScript XML EPUB AppleScript XML OPML AppleScript XML Plist AppleScript XML RSS AppleScript XML SVG AppleScript XML TTML AppleScript XML webloc AppleScript YouTube AppleScript Zero Suppress Applications Barcode OnLine Tools CityCode Design iPhone List Logs lsappinfo Memo Music perl PlistBuddy pluginkit postalcode ReadMe SF Symbols character id SF Symbols Entity sips Skype Slack sqlite TCC Tools Typography Video Wacom zoom