photoshop-python-api icon indicating copy to clipboard operation
photoshop-python-api copied to clipboard

COMError on doJavaScript

Open wallneradam opened this issue 2 years ago • 10 comments

Describe the bug I'm trying to run javascript with doJavaScript, but i t throws a com error.

To Reproduce Just run the example: https://loonghao.github.io/photoshop-python-api/examples/#eval-javascript

Desktop (please complete the following information):

  • OS: Windows 10
  • Photoshop-2020
  • Python Version: 3.9.12

Additional context The traceback:

  Traceback (most recent call last):
  File "F:\Orthogroup\PSAuto\venv\lib\site-packages\comtypes\automation.py", line 791, in Invoke
    self.__com_Invoke(dispid, riid_null, _lcid, _invkind, byref(dp),
_ctypes.COMError: (-2147352567, 'Kivétel történt.', (None, None, None, 0, None))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "F:\Orthogroup\PSAuto\test.py", line 11, in <module>
    app.doJavaScript(jsx)
  File "F:\Orthogroup\PSAuto\venv\lib\site-packages\photoshop\api\application.py", line 396, in doJavaScript
    return self.app.doJavaScript(javascript, Arguments, ExecutionMode)
  File "F:\Orthogroup\PSAuto\venv\lib\site-packages\comtypes\client\dynamic.py", line 121, in __getattr__
    result = self._comobj.Invoke(dispid, _invkind=flags)
  File "F:\Orthogroup\PSAuto\venv\lib\site-packages\comtypes\automation.py", line 799, in Invoke
    raise COMError(hresult, text, details)
_ctypes.COMError: (-2147352567, 'Kivétel történt.', ('Nem megengedett argumentum - 1-es argumentum\n- Hiányzik egy kötelező érték', 'Adobe Photoshop', None, 0, -2147220262))

wallneradam avatar Mar 28 '22 21:03 wallneradam

@wallneradam

Looks like it's because of the character 'Kivétel történt.'

Can you test other text content? just to be sure if it's causing it

loonghao avatar Mar 29 '22 08:03 loonghao

Looks like it's because of the character 'Kivétel történt.'

@loonghao It means Exception occurred in Hungarian. It is not my input. I just run the example program. It is a Hungarian machine with Hungarian PS, I can't change language of the system.

wallneradam avatar Mar 29 '22 08:03 wallneradam

Looks like it's because of the character 'Kivétel történt.'

@loonghao It means Exception occurred in Hungarian. It is not my input. I just run the example program. It is a Hungarian machine with Hungarian PS, I can't change language of the system.

Very strange, I want you to help me test other examples, wondering if none of the other examples work or only this one.

loonghao avatar Apr 04 '22 16:04 loonghao

It is often when there is an "error in photoshop-side" in your code that COMError emerges. For example, when you use executeActionGet but the ActionReference you use matches no object, COMError will happen. I suggest your testing the javascript with ExtendScript Toolkit.

TsXor avatar Aug 02 '22 14:08 TsXor

@TsXor No, as you can see from the error message, it is because of system language.

wallneradam avatar Aug 02 '22 14:08 wallneradam

@TsXor No, as you can see from the error message, it is because of system language.

It is just error message. On system with Chinsese language, it will show Exception occurred in Chinese!

TsXor avatar Aug 02 '22 15:08 TsXor

@TsXor As I wrote, I tested it with the examples of the project: https://loonghao.github.io/photoshop-python-api/examples/#eval-javascript So it should be good.

wallneradam avatar Aug 02 '22 15:08 wallneradam

@TsXor As I wrote, I tested it with the examples of the project: https://loonghao.github.io/photoshop-python-api/examples/#eval-javascript So it should be good.

Then we should find where is wrong. Try that js. js okay -> something wrong with "communication", for example, encoding js wrong -> some js functions may be deprecated, or the js is not copied properly

TsXor avatar Aug 02 '22 15:08 TsXor

Also, did ps alert anything?

TsXor avatar Aug 02 '22 15:08 TsXor

this is because the 'doJavaScript' should be 'DoJavaScript' with uppercase 'D'.

akarcode avatar Nov 12 '22 20:11 akarcode