Table of Contents

Introduction
Who Should Read This?
How Does It Work?
Download(s)
System and Software Requirements
Adobe Photoshop Reserved Words

Tutorials
Overview
  1. Starting a Flex Project
  2. Hello World Panel
  3. Placing the CSXS Library

  4. Shortcut Buttons Panel
    1. JavaScript
    2. Design the Panel
    3. ActionScript
    4. Photoshop Persistent
    5. CSXS Logger AIR Debugger (Optional)

  5. Setting Up Script Listener

  6. Color Picker Panel
    1. JavaScript
    2. Design the Panel
    3. Find Character ID Code to Register Events
    4. ActionScript
    5. Create Custom Icons

  7. Flickr Search Panel
    1. Design the Panel
    2. Create a Flickr Service
    3. Design a Custom Module
    4. Modify Panel's Properties
    5. Connect on Preferences

  8. Per Layer Metadata Panel
    1. View Metadata
    2. JavaScript
    3. Find Character ID Code to Register Events
    4. Designing the Panel
    5. ActionScript
    6. Using Photomerge
Other Samples
Best Practices
Frequently Asked Questions
Acronyms and Definitions
Links
Adobe® Photoshop® Panel Developer's Guide

Per Layer Metadata Panel: Find Character ID Code to Register Events

The third part of the Per Layer Metadata Panel is finding the character ID code associated with actions/events in Adobe Photoshop. The actions/events that the developer will obtain is opening an image, converting the background layer to a regular layer, creating a new layer, selecting a different layer, and converting a regular layer to a background layer. The result is a JavaScript (JSX) output log showing the functions and character ID code of the actions/events committed by the user.

Instructions:

  1. Complete Setting Up Script Listener.
  2. Open Adobe Photoshop.
  3. Open PerLayerMetadataMiddle.jpg under the samples\sample pictures folder included with the Adobe Photoshop Panel Developer's Guide.
  4. Go to Layer > New > Layer from Background....
  5. Under Name:, type in Original and press OK.
  6. Go to Layer > New > Layer....
  7. Under Name:, type in New Layer and press OK.
  8. Go to the Layers Panel or go to Window > Layers or press F7.
  9. Select the layer called Original
  10. Go to Layer > New > Background from Layer.
  11. Close Adobe Photoshop.
  12. Open ScriptingListenerJS.log on the Desktop with a text editor.
  13. The code within ScriptingListenerJS.log should be similar to below:
    // =======================================================
    var idOpn = charIDToTypeID( "Opn " );
        var desc1 = new ActionDescriptor();
        var idnull = charIDToTypeID( "null" );
        desc1.putPath( idnull, new File( "~/samples/sample pictures/PerLayerMetadataMiddle.JPG" ) );
    executeAction( idOpn, desc1, DialogModes.NO );
    
    // =======================================================
    var idsetd = charIDToTypeID( "setd" );
        var desc2 = new ActionDescriptor();
        var idnull = charIDToTypeID( "null" );
            var ref1 = new ActionReference();
            var idLyr = charIDToTypeID( "Lyr " );
            var idBckg = charIDToTypeID( "Bckg" );
            ref1.putProperty( idLyr, idBckg );
        desc2.putReference( idnull, ref1 );
        var idT = charIDToTypeID( "T   " );
            var desc3 = new ActionDescriptor();
            var idNm = charIDToTypeID( "Nm  " );
            desc3.putString( idNm, "Original" );
            var idOpct = charIDToTypeID( "Opct" );
            var idPrc = charIDToTypeID( "#Prc" );
            desc3.putUnitDouble( idOpct, idPrc, 100.000000 );
            var idMd = charIDToTypeID( "Md  " );
            var idBlnM = charIDToTypeID( "BlnM" );
            var idNrml = charIDToTypeID( "Nrml" );
            desc3.putEnumerated( idMd, idBlnM, idNrml );
        var idLyr = charIDToTypeID( "Lyr " );
        desc2.putObject( idT, idLyr, desc3 );
    executeAction( idsetd, desc2, DialogModes.NO );
    
    // =======================================================
    var idMk = charIDToTypeID( "Mk  " );
        var desc4 = new ActionDescriptor();
        var idnull = charIDToTypeID( "null" );
            var ref2 = new ActionReference();
            var idLyr = charIDToTypeID( "Lyr " );
            ref2.putClass( idLyr );
        desc4.putReference( idnull, ref2 );
        var idUsng = charIDToTypeID( "Usng" );
            var desc5 = new ActionDescriptor();
            var idNm = charIDToTypeID( "Nm  " );
            desc5.putString( idNm, "New Layer" );
        var idLyr = charIDToTypeID( "Lyr " );
        desc4.putObject( idUsng, idLyr, desc5 );
    executeAction( idMk, desc4, DialogModes.NO );
    
    // =======================================================
    var idslct = charIDToTypeID( "slct" );
        var desc6 = new ActionDescriptor();
        var idnull = charIDToTypeID( "null" );
            var ref3 = new ActionReference();
            var idLyr = charIDToTypeID( "Lyr " );
            ref3.putName( idLyr, "Original" );
        desc6.putReference( idnull, ref3 );
        var idMkVs = charIDToTypeID( "MkVs" );
        desc6.putBoolean( idMkVs, false );
    executeAction( idslct, desc6, DialogModes.NO );
    
    // =======================================================
    var idMk = charIDToTypeID( "Mk  " );
        var desc7 = new ActionDescriptor();
        var idnull = charIDToTypeID( "null" );
            var ref4 = new ActionReference();
            var idBckL = charIDToTypeID( "BckL" );
            ref4.putClass( idBckL );
        desc7.putReference( idnull, ref4 );
        var idUsng = charIDToTypeID( "Usng" );
            var ref5 = new ActionReference();
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref5.putEnumerated( idLyr, idOrdn, idTrgt );
        desc7.putReference( idUsng, ref5 );
    executeAction( idMk, desc7, DialogModes.NO );
    		

    Code Walkthrough: There are five parts of the code generated by actions/events made in Adobe Photoshop:

    1. Open the PerLayerMetadataMiddle.jpg file under the samples\sample pictures folder.
    2. Convert the background layer to a layer called Original.
    3. Make a new layer called New Layer.
    4. Select the layer called Original.
    5. Make the layer called Original to a background layer.

    There is a special four character ID code placed as a parameter of the function charIDToTypeID found on the first line of each part of the code. The character ID key to call the actions/events described earlier are Opn, setd, Mk, and slct. The two character ID code will be used later in the tutorial.
    Note: Other actions or events could also contain the Opn, setd, Mk, and slct parameter although a different block of code is produced.

  14. Close the text editor.
Continue to Designing the Panel