Skip to main content
Known Participant
March 10, 2020
解決済み

Switching Sample Layers with shortcut key for Clone and Heal tool?

  • March 10, 2020
  • 返信数 1.
  • 2056 ビュー

Hello,

 

I'm looking to apply a short cut key that would toggle brush options to sample between the "Current Layer, Current & Below and All Layers" options when using clone stamp or heal stamps tools.

 

Is this optional?

 

Thanks in advance.

    このトピックへの返信は締め切られました。
    解決に役立った回答 r-bin

    OK ))

    try
        {
        var r = new ActionReference();
        r.putProperty(stringIDToTypeID("property"), stringIDToTypeID("tool"));
        r.putEnumerated(stringIDToTypeID("application"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
    
        var ret = executeActionGet(r);
    
        var options = ret.getObjectValue(stringIDToTypeID("currentToolOptions"));           
        var tool = ret.getEnumerationType(stringIDToTypeID("tool"));
    
        var s = options.getBoolean(charIDToTypeID("StmS"));
        var b = options.getBoolean(charIDToTypeID("StmB"));
    
        if (s && b)
            {
            options.putBoolean(charIDToTypeID("StmS"), false);
            options.putBoolean(charIDToTypeID("StmB"), false);
            }
        else
            {
            options.putBoolean(charIDToTypeID("StmS"), true);
            options.putBoolean(charIDToTypeID("StmB"), true);
            }
    
        var r = new ActionReference();
        r.putClass(tool);
    
        var d = new ActionDescriptor();
        d.putReference(stringIDToTypeID("null"), r);
        d.putObject(stringIDToTypeID("to"), stringIDToTypeID("null"), options);
    
        executeAction(stringIDToTypeID("set"), d, DialogModes.NO);
        }
    catch (e) { /*alert(e)*/  }
    
    

    返信数 1

    Legend
    March 11, 2020
    Here is the script. Assign a hotkey to it (to them).

    Remove the first lines of code to force selecting the healing brush.

     
    NoobNobods作成者
    Known Participant
    March 13, 2020

    Thank you, r-bin!

     

    How may I correctly write an "if" statement in the script to toggle between these 2 actions using the same hotkey?

     

    // Current layer

    options.putBoolean(charIDToTypeID("StmS"), false);

    options.putBoolean(charIDToTypeID("StmB"), false);

     

    // Current & below

    options.putBoolean(charIDToTypeID("StmS"), true);

    options.putBoolean(charIDToTypeID("StmB"), true);

    r-bin解決!
    Legend
    March 13, 2020

    OK ))

    try
        {
        var r = new ActionReference();
        r.putProperty(stringIDToTypeID("property"), stringIDToTypeID("tool"));
        r.putEnumerated(stringIDToTypeID("application"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
    
        var ret = executeActionGet(r);
    
        var options = ret.getObjectValue(stringIDToTypeID("currentToolOptions"));           
        var tool = ret.getEnumerationType(stringIDToTypeID("tool"));
    
        var s = options.getBoolean(charIDToTypeID("StmS"));
        var b = options.getBoolean(charIDToTypeID("StmB"));
    
        if (s && b)
            {
            options.putBoolean(charIDToTypeID("StmS"), false);
            options.putBoolean(charIDToTypeID("StmB"), false);
            }
        else
            {
            options.putBoolean(charIDToTypeID("StmS"), true);
            options.putBoolean(charIDToTypeID("StmB"), true);
            }
    
        var r = new ActionReference();
        r.putClass(tool);
    
        var d = new ActionDescriptor();
        d.putReference(stringIDToTypeID("null"), r);
        d.putObject(stringIDToTypeID("to"), stringIDToTypeID("null"), options);
    
        executeAction(stringIDToTypeID("set"), d, DialogModes.NO);
        }
    catch (e) { /*alert(e)*/  }