While PsDotNet surfaces everything that the COM library exposes, there may be functionality that is missing. Additionally, there may be a need to automate 3rd party plug-ins. PsDotnet Listener is a standalone application that is intended to help developers extend what PsDotNet can do. It provides the developer the ability to echo back simplified C# code snippets as actions are performed in Photoshop. These snippets can then be copied and pasted directly into a C# project using PsDotNet and used and modified as necessary.

PsDotNet_Listener

How it works

The Listener uses the ScriptListener.8li plugin provided by Adobe with a custom parser to generate usable C# code.

For example, the Listener will turn this:

Into this:

One of the goals was to make the code more concise and easier to read. You will notice the the C# utilizes a number of classes like PsKey or PsClass to help making things more readable. These resolve to the values that Photoshop uses internally without having to call charIDToTypeId for example. Here is a specific example taken from above:

Is converted to:

Simple Example

By way of a quick example, there currently is no way to switch Tools directly via PsDotNet(since this was not exposed in the COM library). But you could get the following usable code by having the Listener running and switch to the Rectangle Marquee Tool:

Now if we switch to the Elliptical Marquee Tool the only thing that really changes(besides the variable names) is on the 2nd line with the usage of “marqueeEllipTool”:

From this we could start constructing a method where we could simply pass in the name of the tool we want to select and have a single method for doing switching to all of the different tools. This is an very simple example, but where this can come in quite handy is with 3rd party plugins that you may want to script.

3rd Party Plugins

The Listener will echo back all of the actions that Photoshop is enabled to. This means that all actions, including ones for 3rd party plugins, will converted and presented for use. For example this is the output from NVidia’s NormalMapFilter to take a heightmap and turn it into a normal map:

Or xNormal Dilation filter:

Or xNormal HeightToNormals:

Requirements

As was mentioned above, the Listener uses the ScriptListener.8li plugin provided by Adobe. This needs to be added to the Plug-Ins directory under the version you intend to run. For Photoshop versions CS3-CS5 Adobe included this as part of the installation. Starting with CS6 it was no longer included and you need to download it. Download page is here:http://www.adobe.com/devnet/photoshop/scripting.html

You will see the following error if the version of Photoshop you are trying to use is not setup properly:

listener_error

Usage

To start logging output from Photoshop simply do the following steps:

  1. Start PsDotNet.Listener.exe
  2. Select version of Photoshop you would like to use and click Connect
  3. Click Start\Stop Logging button
  4. Start doing actions in Photoshop
  • Clicking Clear Log button will clear the ScriptingListenerJS.log and ScriptingListenerVB.log files on your desktop. Doing this occasionally is a good thing. Especially if things feel a bit sluggish.
  • Clicking the switch in each section will toggle between original and converted output.
  • Clicking the clipboard button will copy it to output the clipboard.