Skip to main content
rarur97798982
Inspiring
April 11, 2018
Answered

Is there any possible way to open an application from illustrator using javascript?

  • April 11, 2018
  • 2 replies
  • 876 views

Hi all,

I am new in this scripting inside illustrator. I am not even sure, if my question is blunder or not.
I have a requirement, that I need to open another application by running the javascript from illustrator. Is this possible?

Thanks in advance.

This topic has been closed for replies.
Correct answer pixxxelschubser

Hi ,

you can open a file in the wished application eg photoshop

#target Illustrator

var psfile = new File('~/Desktop/YourFilename.jpg');

if (psfile.exists) { photoshop.open(psfile); }

else { alert('file does not exist');}

Have fun

2 replies

pixxxelschubser
Community Expert
pixxxelschubserCommunity ExpertCorrect answer
Community Expert
April 12, 2018

Hi ,

you can open a file in the wished application eg photoshop

#target Illustrator

var psfile = new File('~/Desktop/YourFilename.jpg');

if (psfile.exists) { photoshop.open(psfile); }

else { alert('file does not exist');}

Have fun

rarur97798982
Inspiring
April 13, 2018

HI, That worked. In indesign there is an option by which we can select any image and be opened with photoshop. Is there any chance of opening the image in photoshop from illustrator by using the script?

Inspiring
April 17, 2018
function unique(ain) {
	var seen = {}
	var aout = []
	for(var i = 0; i < ain.length; i++) {
		var elt = ain[i]
		if (!seen[elt]) {
			aout.push(elt)
			seen[elt] = true 
		}
	}
	return aout
}

var doc = app.activeDocument;
var listImageFiles = [];
var i, in_file;
for(i = 0; i < doc.placedItems.length; i++) {
	in_file = doc.placedItems[i].file;
	listImageFiles.push(in_file);
	listImageFiles = unique(listImageFiles);
}
   
var ii;
for(ii = 0; ii < listImageFiles.length; ii++) {
	photoshop.open(listImageFiles[ii]);
}

 

First we put all placed images with full path into an array.

Then we use the unique function to remove any images placed more than once from the array.

In the end we open all files stored in the array in Photoshop.

 

To prevent errors make sure Photoshop is already running because the script is faster than app startup 🙂

Srishti_Bali
Legend
April 12, 2018