StrokesPlus.net Forum
»
General Discussion
»
Scripts
»
SCRIPT REQUEST: Is it possible to pick color with S+?
Rank: Member
Groups: Approved
Joined: 6/28/2019(UTC) Posts: 15 Location: Southwest China Thanks: 2 times Was thanked: 1 time(s) in 1 post(s)
|
Hi Rob, I don't know much coding, so I came for help.
Is S+ possible to pick the color of a pixel in hex color code ?
I tried searching the forum and got no good results (wrong keywords maybe?).
If affirmative, what's the script like? Thanks for your generosity!
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,360 Location: Tampa, FL Thanks: 28 times Was thanked: 421 time(s) in 357 post(s)
|
Here's a script I use. Once started, it shows a text popup of the location and color as you move the mouse. Once you click the left button, it copies the hex color code to the clipboard. I have it show other info normally, but I commented those lines out - you can uncomment them if you'd like. Code:var currpt = sp.GetCurrentMousePoint();
var pxcolor = sp.GetPixelColorFromPoint(currpt);
var info = new DisplayTextInfo();
info.Message = "x: "+currpt.X+" y: " + currpt.Y+"\nRGB: "+pxcolor.R+"."+pxcolor.G+"."+pxcolor.B;
info.Duration = 1000;
info.MessageAlignment = "left";
info.Location = (currpt.X+10)+','+(currpt.Y-100);
info.MessageFont = new Font("Segoe UI Semibold", 12);
info.BackColor = "black";
info.Padding = 0;
info.ClipToWorkingArea = false;
sp.DisplayText(info);
var chex = "";
while (!(sp.GetKeyState(vk.LBUTTON) & 0x8000)) {
currpt = sp.GetCurrentMousePoint();
pxcolor = sp.GetPixelColorFromPoint(currpt);
pxcolorAbove = sp.GetPixelColorFromPoint(new Point(currpt.X, currpt.Y - 100));
var rhex = Number(pxcolor.R).toString(16);
if (rhex.length < 2) {
rhex = "0" + rhex;
};
var ghex = Number(pxcolor.G).toString(16);
if (ghex.length < 2) {
ghex = "0" + ghex;
};
var bhex = Number(pxcolor.B).toString(16);
if (bhex.length < 2) {
bhex = "0" + bhex;
};
var rhexAbove = Number(pxcolorAbove.R).toString(16);
if (rhexAbove.length < 2) {
rhexAbove = "0" + rhexAbove;
};
var ghexAbove = Number(pxcolorAbove.G).toString(16);
if (ghexAbove.length < 2) {
ghexAbove = "0" + ghex;
};
var bhexAbove = Number(pxcolorAbove.B).toString(16);
if (bhexAbove.length < 2) {
bhexAbove = "0" + bhex;
};
chex = "#" + rhex + ghex + bhex;
info.Message = "x: "+currpt.X+" y: " + currpt.Y
//info.Message += "\nAt Cursor - RGB: "+pxcolor.R+","+pxcolor.G+","+pxcolor.B;
info.Message += "\nAt Cursor - hex: " + chex
//info.Message += "\nAbove (100px) - RGB: "+pxcolorAbove.R+","+pxcolorAbove.G+","+pxcolorAbove.B;
//info.Message += "\nAbove (100px) - hex: #" + rhex + ghex + bhex;
info.Location = (currpt.X+10)+','+(currpt.Y-100);
sp.DisplayTextUpdate(info); //Refresh the existing text and location, instead of closing and reopening the popup
sp.Sleep(10);
}
clip.SetText(chex);
sp.DisplayTextClose();
|
2 users thanked Rob for this useful post.
|
|
|
Rank: Member
Groups: Approved
Joined: 6/28/2019(UTC) Posts: 15 Location: Southwest China Thanks: 2 times Was thanked: 1 time(s) in 1 post(s)
|
|
|
|
|
Rank: Advanced Member
Groups: Translators, Approved Joined: 7/17/2021(UTC) Posts: 135
Thanks: 35 times Was thanked: 18 time(s) in 15 post(s)
|
This is really helpful! Wish there was a way to view a zoomed in magnified view of the cursor to get accurate color but this is super helpful on its own.
Thanks Rob
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,360 Location: Tampa, FL Thanks: 28 times Was thanked: 421 time(s) in 357 post(s)
|
Could be modified to increase the font size and/or change the background color to match the point below the cursor....
|
|
|
|
StrokesPlus.net Forum
»
General Discussion
»
Scripts
»
SCRIPT REQUEST: Is it possible to pick color with S+?
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.
Important Information:
The StrokesPlus.net Forum uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close