loonghao / photoshop-python-api

Python API for Photoshop.
https://loonghao.github.io/photoshop-python-api/
MIT License
632 stars 71 forks source link

COMError on doJavaScript #137

Open wallneradam opened 2 years ago

wallneradam commented 2 years ago

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):

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))
loonghao commented 2 years ago

@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

wallneradam commented 2 years ago

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.

loonghao commented 2 years ago

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.

TsXor commented 2 years ago

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.

wallneradam commented 2 years ago

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

TsXor commented 2 years ago

@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!

wallneradam commented 2 years ago

@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.

TsXor commented 2 years ago

@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 commented 2 years ago

Also, did ps alert anything?

akarcode commented 1 year ago

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