lohriialo / photoshop-scripting-python

Scripting in Photoshop is used to automate a wide variety of repetitive task or as complex as an entire new feature
485 stars 95 forks source link

TypeError: 'Layers' object is not subscriptable #18

Open MFRS opened 1 year ago

MFRS commented 1 year ago

I cannot select a layer, this is my code

` import win32com.client as win32 import os from comtypes.client import GetActiveObject, CreateObject

try: adobe_app = win32.GetActiveObject("Photoshop.Application") except: adobe_app = win32.gencache.EnsureDispatch('Photoshop.Application') try:

cd = adobe_app.Open(filepath)

        cd = adobe_app.ActiveDocument
    except:
        cd = adobe_app.ActiveDocument
        # cd = adobe_app.ActiveDocument
    currentTextLayer = cd.Layers[0]
    print(currentTextLayer)

`

Any suggestions?

adepierre commented 1 year ago

Just got the same error. I solved it by replacing Layers['name'] by Layers.Item('name')