Python/ photoshop COM problem( re: SolidColor )


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\", line 95, in Dispatch
    dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
  File "C:\Python27\lib\site-packages\win32com\client\", line 108, in _GetGoodDispatchAndUserName
    return (_GetGoodDispatch(IDispatch, clsctx), userName)
  File "C:\Python27\lib\site-packages\win32com\client\", 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.



Hey Tyler. You have the right idea, creating a new SolidColor object and then assigning it to ForegroundColor.

That “server execution failed” error is typically a timeout, due to the server not responding or being busy (like it’s in a modal user dialog or something). So it sounds like dispatching “Photoshop.Application” works fine, it’s just SolidColor that does not?

Do you have more than one release of Photoshop installed? When you use the regular “Photoshop.Whatever” ID it generally uses the most recent release for that application. I’m wondering if somehow the SolidColor dispatch is trying to use a different release than the one you used for the app object. A release that isn’t running.

You can also access the COM servers using the release-specific ID like this:

new_color = win32com.client.Dispatch( 'Photoshop.SolidColor.11' )

Photoshop CS4 is “11”, CS5 is “12”, etc. Try that using the release number for your release and see what happens?


yeah. Did that once, and it worked. and now just


works without the version number.

so thanks :slight_smile:


So the problem is back, and the ‘Photoshop.SolidColor.12’ trick isn’t working. I have a feeling it’s related to this:

and I’m going ot try uninstalling my 32 bit photoshop to test that theory. any thoughts before I take the axe to my install tomorrow after work?


Try switching to comtypes over win32com. I had to do some python photoshop stuff at work a while ago, and I found comtypes interfaced a lot better than win32com.


kay, heading out to the day job. Will let you know how this works in ~ 10 hrs


I don’t know if I’m just not reading the docs right, but with comtypes even the standard PS com client throws the same errors that I was getting with only SolidColor before when I have 32-bit photoshop open. I just got both working when I have x64 open, but this seems like a major bug. I’m not sure if the bug’s on my end or Adobe’s but I’m kind of inclined to think it’s on theirs.


I just started to get an error with the same error code[Error -2146959355] in python with comtypes photoshop tool that has been working for a while. It works fine my machine and my secondary test machine, I’m wondering the the artist’s machine is too slow and it’s timing out.


So, 4 years later I run into this problem again (Error -2146959355) while building another set of Photoshop Tools. It took me a while to figure it out again, and it looks like the problem arises when you have multiple versions of Photoshop installed. Uninstalling everything but the one main installation of Photoshop fixes that error.


when you have multiple versions of photoshop installed you have to do some additional work.
we support both Creative Cloud 2014 and CS5.



I tried that exact line of code but it didn’t resolve my problem. I looked in the registry as well to try and make sure I was grabbing the right application id, but trying the varying ‘Photoshop.Application.XX’ options proved ineffective for resolving my Error -2146959355. Ultimately I had to uninstall the 32-bit installation of Photoshop.

I suspect that the “Photoshop.Application.80” works for different versions of Photoshop, but maybe not in the case of two different bit-depth installations of the same version.