Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Trigger Save As... dialog with Javascript?

New Here ,
Mar 02, 2011 Mar 02, 2011

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?

TOPICS
Scripting
5.0K
Translate
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
Guide ,
Mar 02, 2011 Mar 02, 2011

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:

Picture 2.png

On choosing you get a second dialog (with limited options) for input:

Picture 1.png

Translate
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
Community Expert ,
Mar 02, 2011 Mar 02, 2011

Hi Mark, how about....

File.saveDialog ();
Translate
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
Guide ,
Mar 02, 2011 Mar 02, 2011

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…?

Translate
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
Community Expert ,
Mar 02, 2011 Mar 02, 2011
LATEST

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");
        }
Translate
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