Copy link to clipboard
Copied
I want to check the availability Save for web option for Photoshop CC 2107, 2015.5 and 2014.
I have found the script for only CC2017 as follows.
var r = new ActionReference();
r.putEnumerated(stringIDToTypeID("application"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
var d = new ActionDescriptor();
d.putReference(stringIDToTypeID("null"), r);
d.putString (stringIDToTypeID("command"), "getCommandEnabled");
d.putDouble(stringIDToTypeID("commandID"), 1695 );
var s4w_enabled = executeAction(stringIDToTypeID("uiInfo"), d, DialogModes.NO).getObjectValue(stringIDToTypeID("result")).getBoolean(stringIDToTypeID("enabled"));
alert(s4w_enabled);
But I want the script for 2015.5 and 2014 as well.
Can anyone please help?
Copy link to clipboard
Copied
Tested on CS6.
Allows to save even when 32bit mode, when the menu is not available. In other cases, correctly identified incompatible modes.
Get rid of save_for_web message in case of incompatible mode will not succeed.
You can send photoshop pressing Esc using AutoIt program.
Then the message window closes itself.
app.displayDialogs = DialogModes.NO;
var file = new File("C:\\A0\\1.jpg"); // set here path to your file
var op = new ExportOptionsSaveForWeb();
with (op)
{
// set here options e.g.:
// format = SaveDocumentType.JPEG;
}
if (!check_s4w())
{
alert("Can't save!!");
}
else
{
activeDocument.exportDocument(file, ExportType.SAVEFORWEB, op);
alert("OK");
}
function check_s4w()
{
try {
var d = new ActionDescriptor();
var d1 = new ActionDescriptor();
d1.putEnumerated(charIDToTypeID("Op "), charIDToTypeID("SWOp"), charIDToTypeID("OpRe"));
d.putObject(stringIDToTypeID("using"), stringIDToTypeID("SaveForWeb"), d1);
var ret = executeAction(stringIDToTypeID("export"), d, DialogModes.NO);
return ret.count?true:false;
}
catch (e) { return false; }
}
Copy link to clipboard
Copied
Thank you very much r-bin.
It is working for all the Photoshop versions.
But the following error message was occurred from executeAction() function, when the Save for web option is not available.
Do you have an idea to prevent the occurring above error message box. Only just Can't save!! alert box should be occurred?
Thanks for consideration.