Skip to content

Instantly share code, notes, and snippets.

@tbuchok
Last active December 18, 2015 03:29
Show Gist options
  • Save tbuchok/5718139 to your computer and use it in GitHub Desktop.
Save tbuchok/5718139 to your computer and use it in GitHub Desktop.
Talking to Photoshop over TCP
(function() {
var loop = true,
tcp = new Socket,
psd = app.activeDocument; // i.e., `psd` is the current open document in Photoshop.
var run = function() {
// Server is running a port 1234:
while(loop) {
var connection = tcp.poll();
if (connection != null) {
connection.writeln('name: ' + psd.name); // The name of the PSD when it was created.
connection.close();
delete connection;
loop = false; // end execution of the script
}
}
};
if (tcp.listen(1234) && psd) run();
}());
$ nc localhost 1234 # prints the name of the PSD, from the Photoshop TCP server!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment