Skip to content

Instantly share code, notes, and snippets.

@oiehot
Created October 5, 2017 23:37
Show Gist options
  • Save oiehot/a8287c9bcdd4c413107cc9c4aba993dc to your computer and use it in GitHub Desktop.
Save oiehot/a8287c9bcdd4c413107cc9c4aba993dc to your computer and use it in GitHub Desktop.
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