Copy link to clipboard
Copied
Hi~
I use method 'doc.trim(TrimType.TRANSPARENT)' to trim the activelayer, but it popout confirm panel which i want to skip with default 'OK' button clicked.what should i do?
Thanks very much if someone can give a clue.
best wishes!
Copy link to clipboard
Copied
Wrong topic ...
Copy link to clipboard
Copied
Tell us the correct name of topic for this thread.
Copy link to clipboard
Copied
I don't get that message with:
app.activeDocument.trim(TrimType.TRANSPARENT);
You could try this raw Script Listener code:
var idtrim = stringIDToTypeID( "trim" );
var desc856 = new ActionDescriptor();
var idtrimBasedOn = stringIDToTypeID( "trimBasedOn" );
var idtrimBasedOn = stringIDToTypeID( "trimBasedOn" );
var idtransparency = stringIDToTypeID( "transparency" );
desc856.putEnumerated( idtrimBasedOn, idtrimBasedOn, idtransparency );
var idtop = stringIDToTypeID( "top" );
desc856.putBoolean( idtop, true );
var idbottom = stringIDToTypeID( "bottom" );
desc856.putBoolean( idbottom, true );
var idleft = stringIDToTypeID( "left" );
desc856.putBoolean( idleft, true );
var idright = stringIDToTypeID( "right" );
desc856.putBoolean( idright, true );
executeAction( idtrim, desc856, DialogModes.NO );
Or the same code as a function if you need to use it multiple times:
trimTransparency();
function trimTransparency() {
var s2t = function (s) {
return app.stringIDToTypeID(s);
};
var descriptor = new ActionDescriptor();
descriptor.putEnumerated( s2t( "trimBasedOn" ), s2t( "trimBasedOn" ), s2t( "transparency" ));
descriptor.putBoolean( s2t( "top" ), true );
descriptor.putBoolean( s2t( "bottom" ), true );
descriptor.putBoolean( s2t( "left" ), true );
descriptor.putBoolean( s2t( "right" ), true );
executeAction( s2t( "trim" ), descriptor, DialogModes.NO );
}
Copy link to clipboard
Copied
weird,some error occured, said invalid paramaters
Copy link to clipboard
Copied
You may also need to globally suppress dialogs:
// Save the current dialog display settings
var savedDisplayDialogs = app.displayDialogs;
// Turn off the dialogs
app.displayDialogs = DialogModes.NO;
// Do your stuff…
// Restore the dialogs
app.displayDialogs = savedDisplayDialogs;
Copy link to clipboard
Copied
When i set this value ,error occured with msg: invalid paramaters
Copy link to clipboard
Copied
I'm not sure why you are getting a pop-up, or why you are getting errors.
You could always install Scripting Listener on your computer and see if you get different results.
Copy link to clipboard
Copied
Reset preferences and try again.
Copy link to clipboard
Copied
I think i got why this happed. When i filter layers empty or background, and undo last trim,this window stop to pop up.