Skip to main content
Inspiring
October 1, 2020
Question

Copy to css with script

  • October 1, 2020
  • 1 reply
  • 401 views

So i'm trying to find the script that does the "Copy to css" because i would like to automate it within photoshop using a custom script. I've found this link on the forum but it doesn't provide a solution.
https://community.adobe.com/t5/photoshop/how-to-get-the-result-of-quot-layer-copy-css-quot-using-script/m-p/7353125?page=1 

I'am using photoshop 2020 on mac. Any ideas on where i can find it?

 

Many thanks

This topic has been closed for replies.

1 reply

Brainiac
October 1, 2020
What exactly do you want?
The ScriptListener gives this code when the Copy CSS command is executed.
This is it?
var d = new ActionDescriptor();
var r = new ActionReference();
r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
d.putReference(stringIDToTypeID("null"), r);
executeAction(stringIDToTypeID("copyLayerCSS"), d, DialogModes.NO);
 
Copying is done to the clipboard.
NH5EABAuthor
Inspiring
October 2, 2020

Thanks for your reply. I've build upon a custom photoshop panel following this tutorial: https://medium.com/adobetech/how-to-create-your-first-adobe-panel-in-6-easy-steps-f8bd4ed5778 

 

I'm trying to build an index.html from a .psd file. So now when a button is clicked in the panel it exports all layers to images and outputs a JSON that is used to build the .CSS file from. But maybe it could be done easier. So what i want to do is with the push of a button export all layers css to a single .css file. I'm not sure but i see your example is VBS script? Is it possible to see a javascript example? Thanks