Copy link to clipboard
Copied
I can check the availability of Save for web option using following script.
app.displayDialogs = DialogModes.NO;
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; }
}
When the executeAction API is executed in above script, following error message was occurred if the Save for web option is not available.
I want to suppress the occurring above error message.
Even if DialogModes.No argument was given to above executeAction API, above error message was occurred.
Can anyone please help me?
Copy link to clipboard
Copied
Have you tried putting the code in a try/catch block?
Copy link to clipboard
Copied
It is already in try-catch block. Would you please explain me?
Copy link to clipboard
Copied
You can change the title and text of the message.
localize("$$$/S4W/Alert/ModeNotSupported=Ha-ha");
localize("$$$/S4W/Alert/Error/Title=Hee-hee");
check_s4w();
Copy link to clipboard
Copied
It is easier to check in which color mode the current document is.
Copy link to clipboard
Copied
If your code is in a try/catch block, and you're still getting the message, then I would do sort of what r-bin suggested and put some code in to change it to the color mode that is acceptable. I'm not sure if it's still this way, but if you try and change to sRGB when you're already in that mode, it will throw an error. So the try catch block is good for that.