Skip to main content
Parts4Arts
Inspiring
December 27, 2021
Question

Execute Javascript jsx by action, a bug?

  • December 27, 2021
  • 1 reply
  • 438 views

Actually it should be possible to execute a Javascript (jsx) by an action. So it would be possible to assign a keyboard shortcut to a Javascript.

 

Unfortunately, I found out that only menu commands are executed by a javascript that is executed by an action and other commands like "Alert" are ignored.

 

Is there a trick so that the complete javascript is executed?

 

Found in Illustrator 26.0.2 and 24.3.0 under macOS 10.15.7 (german).

 

This is my very simple javascript to test this problem:

// Script 1
#target illustrator
app.preferences.setBooleanPreference("ShowExternalJSXWarning",false); // A trick to do a drag-and-drop without warning – you can delete this two lines, it makes no diffenrent.

app.executeMenuCommand("open");
alert("End of script.");
// end of script 1
This topic has been closed for replies.

1 reply

pixxxelschubser
Community Expert
Community Expert
December 27, 2021

Hallo Jens,

funktioniert bei mir wie erwartet unter Windows 10 mit Illu 25.4 und 26.0.2. Die Aktion zeigt den Alert - egal, ob sie über die Aktionen-Palette oder direkt über einen Shortcut gestartet wird.

 

Silly-V
Legend
December 27, 2021

Try to do the same thing but have no open document when you run this.

There may be a chance that it does not work when there's no document.

This can be worked-around by always opening some dummy document and closing it after running the script of interest..

Parts4Arts
Inspiring
December 28, 2021

Hello, I have an empty AI-File and than run my javascript, which works. But via Action it will do not all commands in macOS 10.15.7, macOS 11 with AI 26.0.2.

(new script example: see below.)