I am trying to use Script Events to replicate Photoshop CS’s “Layer>New>Layer via Cut” or its keyboard equivalent of “Command, Shift, J”.
Yet I can’t seem to make it work? First I tried the keyboard shortcut approach. I then attempted to write a script that calls the Menu items.
Can anyone help me make either of these scripts work?
Thanks,
jeff
tell application "Adobe Photoshop CS"
activate
end tell
tell application "System Events"
keystroke "j" using {command shift}
end tell
tell application "Adobe Photoshop CS"
activate
end tell
tell application "System Events"
click the menu item "Layer via Cut" of menu item "New" of menu item "Layer" of menu bar 1
end tell
Otherwise, this will get you going for what you need to do (Remember you need a selection in your document):
tell application "Adobe Photoshop CS"
activate
end tell
tell application "System Events"
tell process "Adobe Photoshop CS"
click menu item "Layer via Cut" of menu "New Layer" of menu item "New" of menu "Layer" of menu bar item "Layer" of menu bar 1
end tell
end tell
N,
Thanks so much you got this part to work. AMAZING!
I can’t believe this is working?
I can start my Holiday now
FWIW,
The script does the following:
Using an active selection, on an active layer: This script will select the inverse and delete all the pixels even if they fall outside the canvas area.
PS does not have a way of doing that.
One may say, just use “Crop”. True, but sometimes other layers have pixel information that you may NOT want to delete that exists outside the canvas bounds.
The one limitation of this script, is that it will delete a layer mask if one exists on the layer.
Plus, the script has no warnings in it yet. I would like it to eventually throw a warning box up when there is no active selection.
(Other than that, this is a really nice, I will use it often)
-jeff
tell application "Adobe Photoshop CS"
activate
set theLayerName to name of current layer of document 1 as string
set the name of current layer of document 1 to "DeletedLayer"
end tell
tell application "System Events"
tell process "Adobe Photoshop CS"
click menu item "Layer via Cut" of menu "New Layer" of menu item "New" of menu "Layer" of menu bar item "Layer" of menu bar 1
end tell
end tell
tell application "Adobe Photoshop CS"
activate
delete layer "DeletedLayer" of document 1
set name of current layer of document 1 to theLayerName
end tell