Last active
December 18, 2015 03:29
-
-
Save tbuchok/5718139 to your computer and use it in GitHub Desktop.
Talking to Photoshop over TCP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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(); | |
}()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ 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