问题
Okay, I understand that charIDToTypeID converts a string into the ID photoshop can actually use but I'm seeing ones I cannot find reference for:
var idLyr = charIDToTypeID( "Lyr " );
var idOrdn = charIDToTypeID( "Ordn" );
var idTrgt = charIDToTypeID( "Trgt" );
What is "Lyr ", "Ordn" and "Trgt" - I googled to find reference but they don't show up in the adobe reference info: http://cssdk.host.adobe.com/sdk/1.0/docs/WebHelp/app_notes/photoshop.htm
I'm trying to find out how this person wrote there code and I'm wondering how they choose to use those IDs when there is no reference to them online.
回答1:
This code was not "written", per se, but was automatically generated by the Script Listener plugin.
Not all of the properties and methods of the Photoshop API are available in the object model, however they are usually still accessible. To use these undocumented features you can install the script listener plugin and perform the actions in Photoshop. The script listener will generate code reflecting the actions you've performed.
For example, there are no explicit methods or properties for the Brush object, but using the script listener, you can open Photoshop, manually adjust the brush size property, and the script listener will automatically generate working, albeit cryptic, code. Any action you perform will be recorded by the script listener so take care not to perform too many actions or you will have a hard time narrowing down the results to those specific methods.
Anyway, I tend to use it as a last resort, but anytime you're dealing with undocumented methods in the Photoshop API, the script listener becomes a necessary evil. Don't assume a method or property isn't available just because it isn't documented. Hope that helps.
回答2:
This is the site that I usually reference for charIDToTypeID:
http://web.archive.org/web/20140121053819/http://www.pcpix.com/Photoshop/char.htm
(Note linked content is from 2013)
Using this, you can find the string representations from the ScriptListener plug-in. In your case, this is what they mean...
phClassLayer -> 1283027488 -> "Lyr " layer
phTypeOrdinal -> 1332896878 -> "Ordn" ordinal
phEnumTarget -> 1416783732 -> "Trgt" targetEnum
来源:https://stackoverflow.com/questions/13893844/charidtotypeid-photoshop-javascript