Hello, relatively new to interacting with photoshop via python, and I had a question.
for ease of typing:
ps_app = win32com.client.Dispatch( "Photoshop.Application")
I’m trying to change the foreground/background color in PS (to fill an empty layer). I first tried changing the (RGB.[Red/Green/Blue], HexValue ) Values for the existing ps_app.ForegroundColor/ps_app.BackgroundColor, which I could modify, but these changes would not propagate to the FG or BG colors in Photoshop.
My sense is that I need to create a new SolidColor object, change the color, and then assign it to be the PS foreground/background color. I found SolidColor as a child of the Photoshop object in the Visual C# Stuido Express Object Browser, but trying to access ps_app.SolidColor was to no avail.
I then started poking through my regedit, and under HKEY_CLASSES_ROOT I found “Photoshop.SolidColor”, so I tried
solidcolor = win32com.client.Dispatch( "Photoshop.SolidColor" )
which brings the photoshop window to the front, and then after a while, returns this error:
Traceback (most recent call last): File "<pyshell#162>", line 1, in <module> solidcolor = win32com.client.Dispatch( "Photoshop.SolidColor" ) File "C:\Python27\lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx) File "C:\Python27\lib\site-packages\win32com\client\dynamic.py", line 108, in _GetGoodDispatchAndUserName return (_GetGoodDispatch(IDispatch, clsctx), userName) File "C:\Python27\lib\site-packages\win32com\client\dynamic.py", line 85, in _GetGoodDispatch IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch) com_error: (-2146959355, 'Server execution failed', None, None)
I’m thinking this may just be my general lack of knowledge about interacting with applications through the COM, but any input would be helpful.