one click hex code to clipboard ( access windows clipboard )

Photoshop Script Snippets - Note: Full Scripts go in the Photoshop Scripts Forum

Moderators: Tom, Kukurykus

andrewluetgers

one click hex code to clipboard ( access windows clipboard )

Post by andrewluetgers »

Whipped this up quickly for work, I got tired of pulling up the color pallet to copy the hex value of the color I wanted to paste into CSS. Now all you do is click with the eyedropper. Thats it! the hex code of the new foreground color is placed into the windows clipboard it even converts to shorthand when applicable. Thanks to this forum for the info to do this and Matt for the shorthand code and overall code cleanup. Enjoy. This script requires AutoIt 3, http://www.autoitscript.com/autoit3/

One of the nice things that this script illustrates is using an event to fire off a script that writes an executable file to then access AutoIt's functionality to then access the windows clipboard. See the code below. Installation notes along with the js files in the zip file attached

This pathway opens a lot of doors. I'll be working on a partner script for getting font colors with the selection of a text layer. This will be a bit tricky because layer styles come into play. For my purposes I'll just consider color overlay and assume 100% transparency. That one will be coming soon (hopefully). I'll post it below.

One question, does anyone know if you can use AutoIt directly from the JS without writing the VBS file?


// ====== foregroundToClipboardEvent.js ========
var eventFile = new File("/c/PSAutomation/foregroundToClipboard.js");
app.notifiers.add("setd", eventFile, "Clr ");
//
//
// ====== foregroundToClipboard.js ========
try {
var color2 = '', color = app.foregroundColor.rgb.hexValue.toLowerCase();

//construct the vbs file passing in the color hex value and execute it to place the value into the clipboard.
var vbs = new File("/c/PSAutomation/valueToClipboard.vbs");
vbs.open("w");
vbs.writeln('Option Explicit');
vbs.writeln('Dim oAutoIt');
vbs.writeln('Set oAutoIt = WScript.CreateObject("AutoItX3.Control")');
for (var i=0; i<color.length; i++) {
var v = color.charAt(i);
if (i==0 || i==2 || i==4)
if (v == color.charAt(i+1)) color2 += v;
}
if (color2.length == 3) color = color2;
vbs.writeln('oAutoIt.ClipPut("'+color+'")');
vbs.writeln('WScript.Quit');
vbs.close();
vbs.execute();
} catch(e) {};
Skrippy

one click hex code to clipboard ( access windows clipboard )

Post by Skrippy »

andrewluetgers wrote:One question, does anyone know if you can use AutoIt directly from the JS without writing the VBS file?

Example I'm using with an AI exe:

Code: Select allvar upload = new File("/c/upload picture to ImageShack.exe");

upload.execute();