What's new
Photoshop Gurus Forum

Welcome to Photoshop Gurus forum. Register a free account today to become a member! It's completely free. Once signed in, you'll enjoy an ad-free experience and be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Scripting modify active color without going through any menu (via shortcuts / scripts)


twable

New Member
Messages
2
Likes
0
hi

how can I modify the current color via keystrokes (either with a shortcut or a script) ? like adding or substracting 1 to the R G B values


thanks in advance, cheers
 

revnart

Power User
Messages
362
Likes
327
Here is the script that gets actual foreground Color and ads + 1 to each until 255 (just paste it into notepad and save as jsx file):
JavaScript:
#target photoshop 

var Color = app.foregroundColor;

var newR = Math.round(foregroundColor.rgb.red) + 1;
var newG = Math.round(foregroundColor.rgb.green) + 1;
var newB = Math.round(foregroundColor.rgb.blue) + 1;

if(newR > 255){
    newR = 255;
}

if(newG > 255){
    newG = 255;
}

if(newB > 255){
    newB = 255;
}


Color.rgb.red = newR;
Color.rgb.green = newG;
Color.rgb.blue = newB;

app.foregroundColor = Color;

and here is version for subtracting by 1 until 0:

JavaScript:
#target photoshop 

var Color = app.foregroundColor;

var newR = Math.round(foregroundColor.rgb.red) - 1;
var newG = Math.round(foregroundColor.rgb.green) - 1;
var newB = Math.round(foregroundColor.rgb.blue) - 1;

if(newR < 0){
    newR = 0;
}

if(newG < 0){
    newG = 0;
}

if(newB < 0){
    newB = 0;
}


Color.rgb.red = newR;
Color.rgb.green = newG;
Color.rgb.blue = newB;

app.foregroundColor = Color;

hope that helps ;)
 

revnart

Power User
Messages
362
Likes
327
Hope that this is what you need ;) Just remember - It will work in LAB or CMYK mode but it will still increase RGB values by 1 not C,M,Y or K for example ;)
 

Top