Instantly share code, notes, and snippets.

Embed
What would you like to do?
PS Paste in Place with Python
import comtypes.client
app = comtypes.client.CreateObject('Photoshop.Application.60') # CS6
def paste_in_place():
# var idpast = charIDToTypeID( "past" );
idpast = app.CharIDToTypeID('past')
# var desc862 = new ActionDescriptor();
desc862 = comtypes.client.CreateObject('Photoshop.ActionDescriptor.60')
# var idinPlace = stringIDToTypeID( "inPlace" );
idinPlace = app.StringIDToTypeID('inPlace')
# desc862.putBoolean( idinPlace, true );
desc862.PutBoolean(idinPlace, True)
# var idAntA = charIDToTypeID( "AntA" );
idAntA = app.CharIDToTypeID('AntA')
# var idAnnt = charIDToTypeID( "Annt" );
idAnnt = app.CharIDToTypeID('Annt')
# var idAnno = charIDToTypeID( "Anno" );
idAnno = app.CharIDToTypeID('Anno')
# desc862.putEnumerated( idAntA, idAnnt, idAnno );
desc862.PutEnumerated(idAntA, idAnnt, idAnno)
# var idAs = charIDToTypeID( "As " );
idAs = app.CharIDToTypeID('As ')
# var idPxel = charIDToTypeID( "Pxel" );
idPxel = app.CharIDToTypeID('Pxel')
# desc862.putClass( idAs, idPxel );
desc862.PutClass(idAs, idPxel)
# executeAction( idpast, desc862, DialogModes.NO );
dialogMode = 3 # None
app.ExecuteAction(idpast, desc862, dialogMode)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment