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

Script can't run correctly when it starts by action

New Here ,
May 21, 2024 May 21, 2024

Hi all. I have one strange problem.
1. I have a script which delete actions and upload new versions of deleted

function deleteActionSet(actionSetName) {
    try {
        var iddelete = charIDToTypeID("Dlt ");
        var desc = new ActionDescriptor();
        var ref = new ActionReference();
        ref.putName(charIDToTypeID("ASet"), actionSetName);
        desc.putReference(charIDToTypeID("null"), ref);
        executeAction(iddelete, desc, DialogModes.NO);
    } catch (e) {
        alert(e.message)
    }
}
deleteActionSet("Set1");
deleteActionSet("Set2");

app.load(new File("C:/Program Files/Adobe/My Tools/Actions/Set1Updated.atn"));
app.load(new File("C:/Program Files/Adobe/My Tools/Actions/Set2Updated.atn"));

alert("UPDATED!");

2. I have an action which launch this script

So i have a problem with launching script using actions. After launching action my old actions was deleted and "UPDATE!" message  was showed and thats all. I don't see new, updated, actions. But if i starting script by File-Scripts-Browse it works correctly. Old actions deleting and new adding and i don't know why and how can i fix it.
Sorry for my Eng.

TOPICS
Actions and scripting , Windows
194
Translate
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
Adobe
Mentor ,
Jul 17, 2025 Jul 17, 2025
LATEST

The action file cannot be loaded while another action is being recorded or played (that's why you can delete actions when manually executing a script, but not when it is recorded as a command for another action).

 

The simplest thing to do is to place the script file in the Presets\Scripts\ folder of Photoshop. After it appears in the Scripts menu, assign a hotkey to it using standard Photoshop tools.

 

A more complex way is to execute your function asynchronously via BridgeTalk (Photoshop will send the function code to a separate thread and execute it without blocking the action):

asyncDeleteActionSet()

function asyncDeleteActionSet(actionSetName) {
    var bt = new BridgeTalk(),
        f = ";f();",
        z = updateActionSet.toSource();
    bt.target = BridgeTalk.getSpecifier('photoshop');
    bt.body = "var f=" + z + f;
    bt.send()
    function updateActionSet() {
        function deleteActionSet(actionSetName) {
            try {
                var iddelete = charIDToTypeID("Dlt ");
                var desc = new ActionDescriptor();
                var ref = new ActionReference();
                ref.putName(charIDToTypeID("ASet"), actionSetName);
                desc.putReference(charIDToTypeID("null"), ref);
                executeAction(iddelete, desc, DialogModes.NO);
            } catch (e) {
                alert(e.message)
            }
        }
        deleteActionSet("Set 1");
        deleteActionSet("Set 2");
        app.load(new File("C:/Program Files/Adobe/My Tools/Actions/Set1Updated.atn"));
        app.load(new File("C:/Program Files/Adobe/My Tools/Actions/Set2Updated.atn"));
        alert("UPDATED!");
    }
}
Translate
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