Skip to content

Instantly share code, notes, and snippets.

@zemax
Last active August 29, 2015 14:06
Show Gist options
  • Save zemax/ca7724ffd05b8f347c4b to your computer and use it in GitHub Desktop.
Save zemax/ca7724ffd05b8f347c4b to your computer and use it in GitHub Desktop.
/**
* Copy the text content of the active layer in the clipboard
* Author: Maxime Cousinou
*
* Installation:
* - Copy the script in your Photoshop/Presets/Scripts directory
* - Create an Action with a keyboard shorcut for quick access (cf http://www.tranberry.com/photoshop/photoshop_scripting/tips/script_shortcut.html)
**/
var activeLayer = app.activeDocument.activeLayer;
if (activeLayer.kind == LayerKind.TEXT) {
var txt = activeLayer.textItem.contents;
// Remove F*cking ETX char
txt = txt.replace(/\x03/g, '\n');
const keyTextData = app.charIDToTypeID('TxtD');
const ktextToClipboardStr = app.stringIDToTypeID( "textToClipboard" );
var textStrDesc = new ActionDescriptor();
textStrDesc.putString( keyTextData, txt );
executeAction( ktextToClipboardStr, textStrDesc, DialogModes.NO );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment