Trigger Save As... dialog with Javascript?
Copy link to clipboard
Copied
I have a script that makes some significant changes to an Illustrator file and would like to have a "Save As..." dialog pop up at the end of the script to give the user a chance to save the changes in a location of their choosing.
I know how to trigger a Save As dialog box with AppleScript using GUI scripting, is there a way of doing this with Javascript?
Explore related tutorials & articles
Copy link to clipboard
Copied
In short I think you answer is NO… There is no 'showing dialog' parameter in either language. You can prompt for a location pretty much the same as 'choose folder' in AppleScript. You can however construct your own dialog using ScriptUI and have the user input some options and a place to save. I am currently working on these myself for use my scripts… Here is an example of some for Photoshop…
First dialog offers a selection of File Format to use:
On choosing you get a second dialog (with limited options) for input:
Copy link to clipboard
Copied
Hi Mark, how about....
File.saveDialog ();
Copy link to clipboard
Copied
I had forgotten about that one Carlos… Yes I suppose you could use that although it does require typing a new name… Im not so keen but each to there own…
var f = File.saveDialog('Save Where?',''); if (f!=null) app.activeDocument.saveAs(f,undefined);
And pass an options object if there is something you want to change…?
Copy link to clipboard
Copied
yeah, that does require to type a name. To have a name already preselected we can use the saveDlg() function
#target Illustrator
var idoc = app.activeDocument;
var fileName = idoc.fullName;
var thisFile = new File(fileName);
var saveFile = thisFile.saveDlg();
if (saveFile)
{
alert("clicked Ok");
idoc.saveAs (saveFile);
}
else
{
alert("clicked Cancel");
}

