Skip to main content
Known Participant
September 28, 2022
Question

How to Clear history just one log of script??

  • September 28, 2022
  • 3 replies
  • 532 views

I got what I was going to do today by jsx using xtool.
I don't know how to make it recorded as a single history.

activeDocument.suspendHistory("Aaron Grimes Effect", "applyVideoExosure()");
I found this in the Adobe community, but it doesn't seem to work when I paste it into a notepad...
The code I got with Xtool is as follows.
Every time run a script, i want only one recorded under the name "clean".

cTID = function(s) { return app.charIDToTypeID(s); };
sTID = function(s) { return app.stringIDToTypeID(s); };

function ContentAware() {
// Expand
function step1(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
desc1.putUnitDouble(cTID('By '), cTID('#Pxl'), 2);
desc1.putBoolean(sTID("selectionModifyEffectAtCanvasBounds"), false);
executeAction(cTID('Expn'), desc1, dialogMode);
};

// Fill
function step2(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
desc1.putEnumerated(cTID('Usng'), cTID('FlCn'), sTID("contentAware"));
desc1.putBoolean(sTID("contentAwareColorAdaptationFill"), true);
desc1.putBoolean(sTID("contentAwareRotateFill"), false);
desc1.putBoolean(sTID("contentAwareScaleFill"), false);
desc1.putBoolean(sTID("contentAwareMirrorFill"), false);
desc1.putUnitDouble(cTID('Opct'), cTID('#Prc'), 100);
desc1.putEnumerated(cTID('Md '), cTID('BlnM'), cTID('Nrml'));
executeAction(cTID('Fl '), desc1, dialogMode);
};

// Set
function step3(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putProperty(cTID('Chnl'), sTID("selection"));
desc1.putReference(cTID('null'), ref1);
desc1.putEnumerated(cTID('T '), cTID('Ordn'), cTID('None'));
executeAction(cTID('setd'), desc1, dialogMode);
};

step1(); // Expand
step2(); // Fill
step3(); // Set
};

 

//=========================================
// ContentAware.main
//=========================================
//


ContentAware.main = function () {
ContentAware();
};

ContentAware.main();

// EOF

"ContentAware.jsx"
// EOF

This topic has been closed for replies.

3 replies

Stephen Marsh
Community Expert
Community Expert
September 28, 2022

Your code doesn't work for me, even before it is placed in the function. What are the conditions required to make it run? Just an active selection?

 

This is what I meant:

 

function myScript() {
    
// Your code here

}
app.activeDocument.suspendHistory("Run script", "myScript()");

 

As in:

 

function myScript() {
    cTID = function (s) {
        return app.charIDToTypeID(s);
    };
    sTID = function (s) {
        return app.stringIDToTypeID(s);
    };
    function ContentAware() {
        // Expand
        function step1(enabled, withDialog) {
            if (enabled != undefined && !enabled)
                return;
            var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
            var desc1 = new ActionDescriptor();
            desc1.putUnitDouble(cTID('By '), cTID('#Pxl'), 2);
            desc1.putBoolean(sTID("selectionModifyEffectAtCanvasBounds"), false);
            executeAction(cTID('Expn'), desc1, dialogMode);
        };
        // Fill
        function step2(enabled, withDialog) {
            if (enabled != undefined && !enabled)
                return;
            var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
            var desc1 = new ActionDescriptor();
            desc1.putEnumerated(cTID('Usng'), cTID('FlCn'), sTID("contentAware"));
            desc1.putBoolean(sTID("contentAwareColorAdaptationFill"), true);
            desc1.putBoolean(sTID("contentAwareRotateFill"), false);
            desc1.putBoolean(sTID("contentAwareScaleFill"), false);
            desc1.putBoolean(sTID("contentAwareMirrorFill"), false);
            desc1.putUnitDouble(cTID('Opct'), cTID('#Prc'), 100);
            desc1.putEnumerated(cTID('Md '), cTID('BlnM'), cTID('Nrml'));
            executeAction(cTID('Fl '), desc1, dialogMode);
        };
        // Set
        function step3(enabled, withDialog) {
            if (enabled != undefined && !enabled)
                return;
            var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
            var desc1 = new ActionDescriptor();
            var ref1 = new ActionReference();
            ref1.putProperty(cTID('Chnl'), sTID("selection"));
            desc1.putReference(cTID('null'), ref1);
            desc1.putEnumerated(cTID('T '), cTID('Ordn'), cTID('None'));
            executeAction(cTID('setd'), desc1, dialogMode);
        };
        step1(); // Expand
        step2(); // Fill
        step3(); // Set
    };
    //=========================================
    // ContentAware.main
    //=========================================
    ContentAware.main = function () {
        ContentAware();
    };
    ContentAware.main();
    // EOF
    "ContentAware.jsx"
    // EOF
}
app.activeDocument.suspendHistory("Run script", "myScript()");

 

Original post and Gist edited to remove minor errors and add clarity.

janemiiAuthor
Known Participant
September 28, 2022

@Stephen Marsh  Thanks for reply...
Hmm... I think it's in parentheses, but there's an error. Am I an Stupid...?

function main () {
alert(
cTID = function(s) { return app.charIDToTypeID(s); };
sTID = function(s) { return app.stringIDToTypeID(s); };

function ContentAware() {
// Expand
function step1(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
desc1.putUnitDouble(cTID('By '), cTID('#Pxl'), 2);
desc1.putBoolean(sTID("selectionModifyEffectAtCanvasBounds"), false);
executeAction(cTID('Expn'), desc1, dialogMode);
};

// Fill
function step2(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
desc1.putEnumerated(cTID('Usng'), cTID('FlCn'), sTID("contentAware"));
desc1.putBoolean(sTID("contentAwareColorAdaptationFill"), true);
desc1.putBoolean(sTID("contentAwareRotateFill"), false);
desc1.putBoolean(sTID("contentAwareScaleFill"), false);
desc1.putBoolean(sTID("contentAwareMirrorFill"), false);
desc1.putUnitDouble(cTID('Opct'), cTID('#Prc'), 100);
desc1.putEnumerated(cTID('Md '), cTID('BlnM'), cTID('Nrml'));
executeAction(cTID('Fl '), desc1, dialogMode);
};

// Set
function step3(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putProperty(cTID('Chnl'), sTID("selection"));
desc1.putReference(cTID('null'), ref1);
desc1.putEnumerated(cTID('T '), cTID('Ordn'), cTID('None'));
executeAction(cTID('setd'), desc1, dialogMode);
};

step1(); // Expand
step2(); // Fill
step3(); // Set
};

 

//=========================================
// ContentAware.main
//=========================================
//


ContentAware.main = function () {
ContentAware();
};

ContentAware.main();

// EOF

"ContentAware.jsx"
// EOF);
}
app.activeDocument.suspendHistory("Run script", "main()");

 

 

Stephen Marsh
Community Expert
Community Expert
September 28, 2022

You misunderstood, delete the entire alert line, replacing it with your xtools converted code. The open and close brackets remain.

janemiiAuthor
Known Participant
September 28, 2022

Still error... 





function main () {
alert("This is a named self-invoking function!");
}
app.activeDocument.suspendHistory("Run script", "main()");

 


I erased the alert from the above phrase and pasted it inside (). But it didn't work. I guess it's because I don't know the basics. So sad =(

 

 

 

 

app.activeDocument.suspendHistory("Run script", "main(cTID = function(s) { return app.charIDToTypeID(s); };
sTID = function(s) { return app.stringIDToTypeID(s); };

function ContentAware() {
// Expand
function step1(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
desc1.putUnitDouble(cTID('By '), cTID('#Pxl'), 2);
desc1.putBoolean(sTID("selectionModifyEffectAtCanvasBounds"), false);
executeAction(cTID('Expn'), desc1, dialogMode);
};

// Fill
function step2(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
desc1.putEnumerated(cTID('Usng'), cTID('FlCn'), sTID("contentAware"));
desc1.putBoolean(sTID("contentAwareColorAdaptationFill"), true);
desc1.putBoolean(sTID("contentAwareRotateFill"), false);
desc1.putBoolean(sTID("contentAwareScaleFill"), false);
desc1.putBoolean(sTID("contentAwareMirrorFill"), false);
desc1.putUnitDouble(cTID('Opct'), cTID('#Prc'), 100);
desc1.putEnumerated(cTID('Md '), cTID('BlnM'), cTID('Nrml'));
executeAction(cTID('Fl '), desc1, dialogMode);
};

// Set
function step3(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putProperty(cTID('Chnl'), sTID("selection"));
desc1.putReference(cTID('null'), ref1);
desc1.putEnumerated(cTID('T '), cTID('Ordn'), cTID('None'));
executeAction(cTID('setd'), desc1, dialogMode);
};

step1(); // Expand
step2(); // Fill
step3(); // Set
};

 

//=========================================
// ContentAware.main
//=========================================
//


ContentAware.main = function () {
ContentAware();
};

ContentAware.main();

// EOF

"ContentAware.jsx"
// EOF)");

 

Stephen Marsh
Community Expert
Community Expert
September 28, 2022

The first code snippet in the following link will do that, just insert your action converted code inside the function braces, replacing the placeholder alert()

 

https://gist.github.com/MarshySwamp/8d94e12597fe101451a5412bf8f3510f