Execute Javascript jsx by action, a bug?

Engaged ,
Dec 27, 2021 Dec 27, 2021

Copy link to clipboard

Copied

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
TOPICS
Bug , Scripting

Views

97

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Dec 27, 2021 Dec 27, 2021

Copy link to clipboard

Copied

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.

 

aa14.png

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Dec 27, 2021 Dec 27, 2021

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Dec 28, 2021 Dec 28, 2021

Copy link to clipboard

Copied

LATEST

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

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Dec 28, 2021 Dec 28, 2021

Copy link to clipboard

Copied

Bei mir klappt es leider noch immer nicht. 

In Windows 10 (AI 26.0.2.) via Parallels 17, in macOS 10.15.7 oder macOS 11 mit AI 26.0.2 werden nur Menübefehle ausgeführt. Alles andere nicht.

Neues Beispiel:

// 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.
for (var i = 0; i < 2; i++) {
	var docRef = documents.add();
	var itemRef = docRef.pathItems.rectangle(600, 200, 150, 150); 
} 
// end of script 1

Damit bekomme ich nur zwei leere, neue Dokument angezeigt.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines