It is currently March 29th, 2024, 8:26 am

Get color rgb from mouse position

General topics related to Rainmeter.
User avatar
rbriddickk84
Rainmeter Sage
Posts: 276
Joined: February 17th, 2014, 12:39 pm
Location: Hungary

Get color rgb from mouse position

Post by rbriddickk84 »

Greetings! First of all, excuse me if this is some kind of repost!
My skin used to work with RainRGB 4.0, but somehow after Rainmeter update it isn't working as intended. So i just wondering about different solution,here is my idea:
There would be a rectangle,i think better 255 wide, and 255 in height.
Then somehow i would get the Mouse position with $MouseX$ and $MouseY$.
What is not clear for me yet is how (if it's possible) to get these values into RGB.

I mean somehow from the mouse X and Y position on the rectangle calculated some Matrix-like measure or something. Sorry if it's not clear how i describe it, my english is very bad!

My plan b. were this: 3 pieces of vertical png bar, r, g, b, and each one would be 255 in width, so i would get rgb's 3 channel separately. But that would be hard for the user to get the color which he/she likes visually.

If something not clear, please just ask, i will try to describe more specifically my idea.
I hope i will get to closer to the solution!

Thank you for the answers and for the help!!!
You do not have the required permissions to view the files attached to this post.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Get color rgb from mouse position

Post by jsmorley »

Just a couple of gotchas that might make this hard:

1) You can only get the current mouse position, in the context of the skin (not the screen X and Y, but the X and Y within the skin) when you actually click the mouse. There is no way to return the current mouse position while you are just hovering over something. That makes a "color picker" in Rainmeter itself a bit clumsy.

2) In Rainmeter proper, you can't "grab" or "detect" the color under the cursor. The only thing you would be able to do, and it would be a tad complicated, is to have some kind of formula that translates the current X and Y mouse coordinates (again, in the context of the skin) into a color. I'm not even sure that this formula might look like, but the goal at a high level would be to have X=40 and Y=90 translate to either a R,G,B or HEX color value.

The only other option would be some kind of plugin or addon that could grab the pixel color at some defined screen location, which you would pass to it with a combination of #CURRENTCONFIGX# / #CURRENTCONFIGY# and the mouse variables when you click on that color spectrum meter.
User avatar
rbriddickk84
Rainmeter Sage
Posts: 276
Joined: February 17th, 2014, 12:39 pm
Location: Hungary

Re: Get color rgb from mouse position

Post by rbriddickk84 »

Firstly thank you very much for your quick reply and help!
Yes, i know that $MouseX$ is counting relatively from the current skin's origin, that's what i need. If that would counted from screen origin, that would be useless for me.
The image would be only just for represent some visuals, actually it wouldn't be in fuction, just a bg. The main calculation would be in the background on a virtual "matrix".
The click is very good for me, i don't want to be hovered.
But i think i am on the right way now, i hope i can present here the solution, probably it will need some corrections in the script to make more efficient and resource friendly. :)
I don't need exact pixel color information, just woud be better then type in some r, g, b numbers from 0 to 255, who doesn't experienced in color codes at all.Just like my mom,i am happy that she can click on things, and open folders! :D
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Get color rgb from mouse position

Post by jsmorley »

BTW, I use RainRGB on my system, and have had no issue with it with the most current Rainmeter beta...
User avatar
rbriddickk84
Rainmeter Sage
Posts: 276
Joined: February 17th, 2014, 12:39 pm
Location: Hungary

Re: Get color rgb from mouse position

Post by rbriddickk84 »

jsmorley wrote:BTW, I use RainRGB on my system, and have had no issue with it with the most current Rainmeter beta...
I have just minor issues, working for me too, but it doesn't refresh my skin after the choosen color. It worked a few months ago, then now when i tried it was worked but not as the way it was.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Get color rgb from mouse position

Post by jsmorley »

rbriddickk84 wrote: I have just minor issues, working for me too, but it doesn't refresh my skin after the choosen color. It worked a few months ago, then now when i tried it was worked but not as the way it was.
Make sure you have the latest beta from http://rainmeter.net. We did have one very short-lived beta where that got broken.
User avatar
rbriddickk84
Rainmeter Sage
Posts: 276
Joined: February 17th, 2014, 12:39 pm
Location: Hungary

Re: Get color rgb from mouse position

Post by rbriddickk84 »

Okay ^^!
But i am eager to make this :D, i have the Red channel working, now the green comes. :)
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5384
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Get color rgb from mouse position

Post by eclectic-tech »

Kaelri created a small skin using a lua script to accomplish something similar.

Here is his 'TestColorSpectrum' skin for you to play with. I used a modified version in my Spiral Clock skin to set all the color options.
TestColorSpectrum_0.2.rmskin
You do not have the required permissions to view the files attached to this post.
Last edited by eclectic-tech on September 26th, 2015, 1:33 pm, edited 1 time in total.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5384
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Get color rgb from mouse position

Post by eclectic-tech »

jsmorley wrote:BTW, I use RainRGB on my system, and have had no issue with it with the most current Rainmeter beta...
The only issue I have had with RainRGB4 is writing the value Hex format if the current value is a variable (#Color1#)... RainRGB cannot determine the format (RGB or Hex) so it returns the color in Hex format.

This creates weird color issues if you try to add an Alpha value to the variable (#Color1#,128)...

Is it possible to add an option to specify the output format rather than having RainRGB 'test' for the format?

BTW, Love RainRGB4 ... use it all the time!
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Get color rgb from mouse position

Post by jsmorley »

eclectic-tech wrote: The only issue I have had with RainRGB4 is writing the value Hex format if the current value is a variable (#Color1#)... RainRGB cannot determine the format (RGB or Hex) so it returns the color in Hex format.

This creates weird color issues if you try to add an Alpha value to the variable (#Color1#,128)...

Is it possible to add an option to specify the output format rather than having RainRGB 'test' for the format?

BTW, Love RainRGB4 ... use it all the time!
I'm not entirely sure I follow you, but if I do, it's not really going to work. What RainRGB does is accept the "VarName" and "FileName" where it is going to eventually store the returned color value. It first reads the current value from that file, which has to be a valid color value in either HEX or RGB. It can't possibly "resolve" the value of a variable stored there, so in this example:

LeftMouseUpAction=["#@#Addons\RainRGB4.exe" "VarName=ValueColor" "FileName=#@#GeneralVariables.inc" "RefreshConfig=*"]

If what is there now in GeneralVariables.inc is

[Variables]
SomeColor=255,255,255,255
ValueColor=#SomeColor#

It can't possibly resolve that correctly. Only Rainmeter knows what #SomeColor# means, and there is no way to get AutoIt to resolve a Rainmeter variable.