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

How to stop recording state with JSX code?

Explorer ,
Dec 02, 2018 Dec 02, 2018

Copy link to clipboard

Copied

I write a  jsx to record  action.But when i execute the code, the actions panel's state is still recording,so i want to stop recording.Here's the jsx code:

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

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

    var desc1 = new ActionDescriptor();

    var ref1 = new ActionReference();

    ref1.putClass(cTID('Actn'));

    desc1.putReference(cTID('null'), ref1);

    var ref2 = new ActionReference();

    ref2.putName(cTID('ASet'), "culture");

    desc1.putReference(cTID('At  '), ref2);

    var desc2 = new ActionDescriptor();

    desc2.putString(cTID('Nm  '), "action1");

    desc2.putInteger(cTID('FncK'), 0);

    desc1.putObject(cTID('Usng'), cTID('Actn'), desc2);

    executeAction(sTID('make'), desc1, DialogModes.NO);

1.png

TOPICS
Actions and scripting

Views

2.8K

Translate

Translate

Report

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

correct answers 1 Correct answer

People's Champ , Dec 04, 2018 Dec 04, 2018

ling54k 

 

My ultimate intention is to convert AM code to action.I don't know if that's possible, or if there's any other way.

Maybe this will help.

Using the ActionMaker object, you can create an Action from any AM code.

It is enough to use a.executeAction() in the script instead of executeAction().

 

 

/////////////////////////////////////////////////////////////////////////////////

function ActionMaker(set_name, act_name)

    {

    try {

        this.set_name = set_name;

        th

...

Votes

Translate

Translate
Adobe
Advocate ,
Dec 03, 2018 Dec 03, 2018

Copy link to clipboard

Copied

eventually replace this

DialogModes.NO

with this DialogModes.All

Votes

Translate

Translate

Report

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
Explorer ,
Dec 03, 2018 Dec 03, 2018

Copy link to clipboard

Copied

Sorry,you may not understand what I mean.

Votes

Translate

Translate

Report

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
People's Champ ,
Dec 03, 2018 Dec 03, 2018

Copy link to clipboard

Copied

Do you just want to create an empty action? If so, then in principle it is possible, but difficult. It is not clear why this is necessary.

Votes

Translate

Translate

Report

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
Explorer ,
Dec 03, 2018 Dec 03, 2018

Copy link to clipboard

Copied

Hi r-bin

Thanks for your reply.I don't want to create an empty ,the jsx file has some AM code after  making an action.My ultimate intention is to convert AM code to action.I don't know if that's possible, or if there's any other way.But if i use this way which is making an action through

jsx,how to stop recording mode will be a problem.

Votes

Translate

Translate

Report

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 ,
Dec 03, 2018 Dec 03, 2018

Copy link to clipboard

Copied

What advantage or benefit is there in converting AM code into an action compared to recording an action the regular way? Is this meant to be an interactive/variable user driven process controlled from a script?

 

Perhaps look into xtools for inspiration:

 

xtools / v2.3

 

ActionDescriptorToJavascript.jsx

ActionDescriptorToXML.jsx

ActionEvalDemo.jsx

ActionFileBrowser.jsx

ActionFileFromSLCode.jsx

ActionFileFromXML.jsx

ActionFileToJavascript.jsx

ActionFileToXML.jsx

ActionLister.js

ActionSetRunner.js

ActionsPaletteToFiles.jsx

ActionToJavascript.jsx

ActionToXML.jsx

Votes

Translate

Translate

Report

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
Explorer ,
Dec 04, 2018 Dec 04, 2018

Copy link to clipboard

Copied

LATEST

Thank you for your reply. It may be helpful to me.

Votes

Translate

Translate

Report

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
People's Champ ,
Dec 04, 2018 Dec 04, 2018

Copy link to clipboard

Copied

ling54k 

 

My ultimate intention is to convert AM code to action.I don't know if that's possible, or if there's any other way.

Maybe this will help.

Using the ActionMaker object, you can create an Action from any AM code.

It is enough to use a.executeAction() in the script instead of executeAction().

 

 

/////////////////////////////////////////////////////////////////////////////////

function ActionMaker(set_name, act_name)

    {

    try {

        this.set_name = set_name;

        this.act_name = act_name;

 

        this.data = new Array();

        }

    catch (e) { alert(e); throw(e);  }

    }

 

/////////////////////////////////////////////////////////////////////////////////

ActionMaker.prototype.executeAction = function(event, desc)

    {

    try

        {

        this.data.push([event, desc]);

 

        executeAction(event, desc, DialogModes.NO);

        }

    catch (e) { alert(e); throw(e);  }

    }

 

/////////////////////////////////////////////////////////////////////////////////

ActionMaker.prototype.load = function()

    {

    try {

        var file = new File(Folder.temp.fsName + "\\" + "tmp.atn");

 

        var len = this.data.length;

 

        var l0 = (len>>24) & 0xFF;

        var l1 = (len>>16) & 0xFF;

        var l2 = (len>>8 ) & 0xFF;

        var l3 = (len    ) & 0xFF;

 

        file.open("w");

        file.encoding = "BINARY";

 

        file.write(String.fromCharCode(0,0,0,16)); // dword version

 

        file.write(string_to_bin(this.set_name));  // unicode set name

        file.write(String.fromCharCode(0));        // byte  set is expanded

        file.write(String.fromCharCode(0,0,0,1));  // dword number of actions in action set

        file.write(String.fromCharCode(0,0));      // word  index of action

        file.write(String.fromCharCode(0));        // byte  shift key needed for keyboard shortcut

        file.write(String.fromCharCode(0));        // byte  ctrl key needed for keyboard shortcut

        file.write(String.fromCharCode(0,0));      // word  color index

 

        file.write(string_to_bin(this.act_name));     // unicode action name

        file.write(String.fromCharCode(0));           // byte  action is expanded

        file.write(String.fromCharCode(l0,l1,l2,l3)); // dword number of items in action

 

        for (var i = 0; i < len; i++)

            {

            file.write(String.fromCharCode(0));        // byte  item is expanded in the Actions palette

            file.write(String.fromCharCode(1));        // byte  item is enabled

            file.write(String.fromCharCode(0));        // byte  dialogs should be displayed

            file.write(String.fromCharCode(0));        // byte  options for displaying dialogs

 

            file.write("long");

            file.write(typeIDToCharID(this.data[i][0])); // charID of event

            file.write(String.fromCharCode(0,0,0,0));    // dword len and dictionary name

 

            if (this.data[i][1] && this.data[i][1].count)

                {

                file.write(String.fromCharCode(0xFF,0xFF,0xFF,0xFF)); // long -1 if have descriptor

                file.write(this.data[i][1].toStream().substr(4));

                }

            else

                {

                file.write(String.fromCharCode(0,0,0,0));

                }

            }

 

        file.close();

 

        app.load(file);

 

        file.remove();

 

        function string_to_bin(x)

            {  

            try {

                var d = new ActionDescriptor();

                d.putString(0, x);

                return d.toStream().substr(34);

                }

            catch (e) { alert(e); }       

            }

        }

    catch (e) { alert(e); throw(e);  }

    }

 

 

////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////////

var a = new ActionMaker("SET", "ACTION");

 

    // Some AM Code. Use a.executeAction() instead of executeAction()

 

    // ctrl-j

    var d = new ActionDescriptor();

    a.executeAction(stringIDToTypeID("copyToLayer"), d, DialogModes.NO);

 

    // cteate mask

    var d = new ActionDescriptor();

    d.putClass(stringIDToTypeID("new"), stringIDToTypeID("channel"));

    var r = new ActionReference();

    r.putEnumerated(stringIDToTypeID("channel"), stringIDToTypeID("channel"), stringIDToTypeID("mask"));

    d.putReference(stringIDToTypeID("at"), r);

    d.putEnumerated(stringIDToTypeID("using"), stringIDToTypeID("userMaskEnabled"), stringIDToTypeID("hideAll"));

    a.executeAction(stringIDToTypeID("make"), d, DialogModes.NO);

   

    // hide layer

    var d = new ActionDescriptor();

    var list = new ActionList();

    var r = new ActionReference();

    r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));

    list.putReference(r);

    d.putList(stringIDToTypeID("null"), list);

    a.executeAction(stringIDToTypeID("hide"), d, DialogModes.NO);

 

    // show layer

    var d = new ActionDescriptor();

    var list = new ActionList();

    var r = new ActionReference();

    r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));

    list.putReference(r);

    d.putList(stringIDToTypeID("null"), list);

    a.executeAction(stringIDToTypeID("show"), d, DialogModes.NO);

   

    // ctrl-j

    var d = new ActionDescriptor();

    a.executeAction(stringIDToTypeID("copyToLayer"), d, DialogModes.NO);

 

    // delete mask

    var d = new ActionDescriptor();

    var r = new ActionReference();

    r.putEnumerated(stringIDToTypeID("channel"), stringIDToTypeID("channel"), stringIDToTypeID("mask"));

    d.putReference(stringIDToTypeID("null"), r);

    a.executeAction(stringIDToTypeID("delete"), d, DialogModes.NO);

   

   

a.load(); // load action

Votes

Translate

Translate

Report

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
Explorer ,
Dec 04, 2018 Dec 04, 2018

Copy link to clipboard

Copied

Wow, that's great.Thanks in advance!

Votes

Translate

Translate

Report

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