Copy link to clipboard
Copied
Hi, I've been searching for a way to copy the active layer name to the Windows Clipboard, I'm hoping this a quick solution. What I've managed to do so far is to open the layer properties dialog box, then hit 'CTRL+C' to copy the layer name (because the layer name is already highlighted at this step), and then this successfully copies the layer name to the Windows Clipboard.
But I find that when the system is under load, the layer properties dialog box is sometimes slow to open, and even so, it seems like it's an extra step that could be eliminated.
I searched through the keyboard shortcuts, and also through all the layer menus for a keyboard shortcut to just 'copy layer name to clipboard' but can't find anything.
Anyone know if there's a quick keyboard shortcut to do this or perhaps a quick script that will just copy the layer name?
Thanks in advance..
Bingo! Thanks Philip/csuebele/pixxxel, it was the 'clip.exe' that was the problem for me. I pasted it into system32 and now it works. This is awesome - now I'm able to show a tooltip with the layer name every time I change layers (with help from my other 3rd party app) - this is especially useful when working in fullscreen mode where you can't see the layers pallet. It updates your tooltip with the layer name every time you use the keyboard shortcuts to select different layers.
If anyone thinks t
...Copy link to clipboard
Copied
What do you want to do with it once you have it copied?
Copy link to clipboard
Copied
I'm running another 3rd party application that enables you to display the clipboard contents in a tooltip whenever you press a certain hotkey.
So whenever I'm in my photoshop document, I'll press 'z' (for example), and when 'z' is pressed, it will show a tooltip at my mouse cursor. So the plan is to somehow copy the layer name to the clipboard, then press z, and it will show my current layer at my mouse cursor as a tooltip. This could be useful when in fullscreen mode and the layers panel is not visible.
If I can find a way to do this, I'd gladly share my 3rd party app with the script (along with its script - it also uses its own scripting language) for it to do this - I'm sure it would be very helpful to other users as well. The first step is finding a way to copy the active layer name.
Copy link to clipboard
Copied
Here's a thread on ps-scripts.com that seemed to work on a Win system. I was going to say if you just wanted to do something inside PS, that would be no problem, as you most likely would not have to use the clipboard, but what you want to do does require that - I think.
Copy link to clipboard
Copied
thanks, one of those scripts seems to be doing something similar, but I couldn't see anything that copied the active layer name to the clipboard. I've copied the script and placed it here with a roughed0-out version of what I was trying to do (the script below is going nowhere, but I hope it gives an idea of what to do:)
var ref = getSelectedLayerName ;// trying to copy the active layer name to clipboard
var str="getSelectedLayerName";
var tempFile = File("~/desktop/TempVBS.vbs");
tempFile.open('w');
tempFile.writeln('set
loop');
tempFile.writeln('ie.document.parentwindow.clipboardData.setDa
ta "Text"," '+str+'"');
tempFile.close();
tempFile.execute();
getSelectedLayerName ;//after copying the layer name, then when hitting CTRL+V (paste) in notepad, the copied layer name will paste
Copy link to clipboard
Copied
here's actually a script that will display the active layer name in a message box. The catch is, it takes up to 3 seconds to run it -I wonder if there's a way to compress the script so it runs faster? Nonetheless here it is, so I'm wondering if there's a way to insert a "CTRL+C" somewhere in the script so it will just copy the layer name and skip the message box part at the end.....
var sLayers = getSelectedLayersIdx();
var Names = new Array();
for (var a in sLayers){
Names.push(getLayerNameByIndex( Number(sLayers) ) );
}
alert(Names.join('\n'));
function getLayerNameByIndex( idx ) {
var ref = new ActionReference();
ref.putIndex( charIDToTypeID( "Lyr " ), idx );
return executeActionGet(ref).getString(charIDToTypeID( "Nm " ));
};
function getSelectedLayersIdx(){
var selectedLayers = new Array;
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var desc = executeActionGet(ref);
if( desc.hasKey( stringIDToTypeID( 'targetLayers' ) ) ){
desc = desc.getList( stringIDToTypeID( 'targetLayers' ));
var c = desc.count
var selectedLayers = new Array();
for(var i=0;i<c;i++){
try{
activeDocument.backgroundLayer;
selectedLayers.push( desc.getReference( i ).getIndex() );
}catch(e){
selectedLayers.push( desc.getReference( i ).getIndex()+1 );
}
}
}else{
var ref = new ActionReference();
ref.putProperty( charIDToTypeID("Prpr") , charIDToTypeID( "ItmI" ));
ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
try{
activeDocument.backgroundLayer;
selectedLayers.push( executeActionGet(ref).getInteger(charIDToTypeID( "ItmI" ))-1);
}catch(e){
selectedLayers.push( executeActionGet(ref).getInteger(charIDToTypeID( "ItmI" )));
}
var vis = app.activeDocument.activeLayer.visible;
if(vis == true) app.activeDocument.activeLayer.visible = false;
var desc9 = new ActionDescriptor();
var list9 = new ActionList();
var ref9 = new ActionReference();
ref9.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
list9.putReference( ref9 );
desc9.putList( charIDToTypeID('null'), list9 );
executeAction( charIDToTypeID('Shw '), desc9, DialogModes.NO );
if(app.activeDocument.activeLayer.visible == false) selectedLayers.shift();
app.activeDocument.activeLayer.visible = vis;
}
return selectedLayers;
};
Copy link to clipboard
Copied
That does seem like a lot of code. I haven't done much with selectng multiple layers, but once you get your array of layers, how about something like
var layerNames = new Array()
for(var i;<layerArray.length;i++){
layerNames.push(docRef.artLayers[layerArray].name + '\n')
}
Copy link to clipboard
Copied
it's returning an error:
Error 61: Unclosed Token.
Line: 7
-> }
Copy link to clipboard
Copied
I guess you may need all that code after all.
Copy link to clipboard
Copied
thanks, I'll take a look at it.. I pasted yor quick code into the larger code and tried removing several '}' keys but unfortunately this looks like a more complicated scenario than I had thought.. I'm sure I'll find a workaround for it though, thanks..
Copy link to clipboard
Copied
Please try this method
app.system( "echo " + activeDocument.activeLayer.name + " | CLIP");
Copy link to clipboard
Copied
Philip Cord schrieb:
Please try this method
app.system( "echo " + activeDocument.activeLayer.name + " | CLIP");
Additionally, there is more in this thread:
Copy link to clipboard
Copied
thanks, I ran the following line of script and it did infact do something; it quickly opened and closed a dos-based window (I assume it was trying to copy the layer name at that point) but when pasting into notepad as a test, it didn't paste the layer name - it pasted whatever was previously in the clipboard.
If there's no workaround, no worries - your guys' help is greatly appreciated
app.system( "echo " + activeDocument.activeLayer.name + " | CLIP");
Copy link to clipboard
Copied
I tried it, and it worked.
Copy link to clipboard
Copied
it isn't working for me... I even tried emptying the clipboard first and then running just that one line of code, but for some reason it won't copy it to the clipboard.. good to know you got it working though, so it is possible.. now I just have to figure out why it's not working on this end..
Copy link to clipboard
Copied
actually the dos-type window that flashes very quickly when the script runs, it does indeed say the layer name, and it's followed by either the word 'clip' or 'off' - it's too fast so I can't completely make it out... but it's definitely saying the active layer name.. I think it's showing the layer name and then the word 'clip'.. but after it, the windows clipboard is still empty
Copy link to clipboard
Copied
You may not have clip.exe on your machine due to your OS version. This page should be of use as it does give a link to another version of clip.
Copy link to clipboard
Copied
Bingo! Thanks Philip/csuebele/pixxxel, it was the 'clip.exe' that was the problem for me. I pasted it into system32 and now it works. This is awesome - now I'm able to show a tooltip with the layer name every time I change layers (with help from my other 3rd party app) - this is especially useful when working in fullscreen mode where you can't see the layers pallet. It updates your tooltip with the layer name every time you use the keyboard shortcuts to select different layers.
If anyone thinks they'd find this handy, I'd me more than glad to share it... but it's using a different scripting software, so I may or may not be able to speak about it here. Shoot me a private message if I can't talk about it in here and you'd like to have it.