It is currently July 12th, 2020, 4:20 pm

Get color rgb from mouse position

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

Re: Get color rgb from mouse position

Post by rbriddickk84 »

Thank you,but i try to avoid Lua script becouse i cannot write scripts in it, i don't know that script language. :)
But slowly i think i can make it in Rainmeter script. ^^

But thank you for the help!!!
User avatar
eclectic-tech
Rainmeter Sage
Posts: 4040
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:...

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.
You understood...
RainRGB returns Hex formatted color codes when it cannot determine the original format... I have learned to work with it, but being able to tell RainRGB what format you want returned would be beneficial.

Thanks!
User avatar
jsmorley
Developer
Posts: 21016
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Get color rgb from mouse position

Post by jsmorley »

Ok eclectic-tech, I'll take a look at that.
User avatar
rbriddickk84
Rainmeter Sage
Posts: 208
Joined: February 17th, 2014, 12:39 pm
Location: Hungary

Re: Get color rgb from mouse position

Post by rbriddickk84 »

Yes! I made it! ^^
I finished this color chooser. Probably i made a lots of unusefull fragments in the code, and possibly it could be reduced and be more resource efficient, but i would recommend some help in that, if someone feel the challenge. :)
I attached in a zip file the ini and the image. The DynamicVariables section still a little bit mystery for me to when it must use it, and where can be leave out from a measure or meter.
You do not have the required permissions to view the files attached to this post.
User avatar
jsmorley
Developer
Posts: 21016
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Get color rgb from mouse position

Post by jsmorley »

Nice work... ;-)
User avatar
rbriddickk84
Rainmeter Sage
Posts: 208
Joined: February 17th, 2014, 12:39 pm
Location: Hungary

Re: Get color rgb from mouse position

Post by rbriddickk84 »

jsmorley wrote:Nice work... ;-)
Thank you very much! ^^
I planned to write the values in text file, and refreshes the whole skin after every click, so it will be fewer variables in use, and fewer skin refresh ratio. Evem not so many DynamicVariables. :)
But some point it not refreshes some values around the blue areas, but now i'm working on that.

Should i publish this on somewhere else on thie forum as an idea?
User avatar
jsmorley
Developer
Posts: 21016
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Get color rgb from mouse position

Post by jsmorley »

Once you are happy with it, you can post it in a "share your creations" thread, or if you want to verbally expand a bit on the approach used, it might make a good "create a color picker in Rainmeter" post in "tip and tricks".
User avatar
rbriddickk84
Rainmeter Sage
Posts: 208
Joined: February 17th, 2014, 12:39 pm
Location: Hungary

Re: Get color rgb from mouse position

Post by rbriddickk84 »

If it worth to share, i happily would do it! :)
Probably i will do both, just do some debugging first, it was really late night when i came for the final solutions. :D
Thank you for your quick response and for you help! ^^
User avatar
rbriddickk84
Rainmeter Sage
Posts: 208
Joined: February 17th, 2014, 12:39 pm
Location: Hungary

Re: Get color rgb from mouse position

Post by rbriddickk84 »

Hi again! :)

I decided to take another challenge to rewrite the whole RGB picker project of mine, and planned to this will be fully re-skinnable, scaleable, and more precise.
But in the beginning i have some issues, and now i don't have a single clue, what and where goes wrong my script.

Here is the code:

Code: Select all

[Rainmeter]
Update=100
AccurateText=1

[Variables]
@Include=#CURRENTPATH#set.txt

fx=#mx#
fy=#my#

rtx=#rr#
gtx=#gg#
btx=#bb#
rx=#rr#
gx=#gg#
bx=#bb#
ax=#aa#

#rgbspectrum image size:
alx=200
aly=85

[--------------------- ### -----------------------------]

[detectingArea]
Meter=Image
SolidColor=0,0,0,1
X=0
Y=0
W=#alx#
H=#aly#
LeftMouseDownAction=[!SetVariable fx $MouseX$][!SetVariable fy $MouseY$]
DynamicVariables=1

[--------------------- Calculations 1 -----------------------------]

#Converts coordinates to percentages:
[ConvX]
Measure=Calc
Group=cls
Formula=(#fx#/#alx#)*765
DynamicVariables=1
;UpdateDivider=-1

[Brightness]
Measure=Calc
Group=cls
Formula=((#fy#/#aly#)*510)-255
IfCondition=(Brightness <> #ax#)
IfTrueAction=[!SetVariable ax [Brightness]]
DynamicVariables=1
;UpdateDivider=-1

[BaseRed]
Measure=Calc
Group=cls
Formula=(Abs(ConvX - 382))-127
IfCondition=(BaseRed < 0)
IfTrueAction=[!SetVariable rtx "0"]
DynamicVariables=1
;UpdateDivider=-1

[Rdss]
Measure=Calc
Group=cls
Formula=(#rtx# - #ax#)
IfCondition=(Rdss > 255)
IfTrueAction=[!SetVariable rx 255]
IfCondition2=(Rdss < 0)
IfTrueAction2=[!SetVariable rx 0]
IfCondition3=(Rdss <> #rtx#) && (Rdss > 0) && (Rdss < 255) 
IfTrueAction3=[!SetVariable rx [Rdss]]
DynamicVariables=1
;UpdateDivider=-1
Now every Calc measures are working as intended, but the last "[Rdss]" didn't do what i want.
Honestly maybe i am missing some obvious thing, or i don't know, but this drives me nuts now, i am searching for bug 2 hours now in this small part of the script. I didn't linked the other Blue and Green part of the code, because somehow this got "bugged".
"#rx#" would be the final variable of the RGB color code, "#rtx#" is the temporary variable for calculating the base red color without the brightness control. "#rr#" is stored in a text file for refresh reasons.

Any help i appretiate!
User avatar
eclectic-tech
Rainmeter Sage
Posts: 4040
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Get color rgb from mouse position

Post by eclectic-tech »

rbriddickk84 wrote:Yes! I made it! ^^
I finished this color chooser. Probably i made a lots of unusefull fragments in the code, and possibly it could be reduced and be more resource efficient, but i would recommend some help in that, if someone feel the challenge. :)
I attached in a zip file the ini and the image. The DynamicVariables section still a little bit mystery for me to when it must use it, and where can be leave out from a measure or meter.
Hi rbriddickk84 :welcome: Can you re-post your original app? In the site update, a lot of attachments got left behind... :D