It is currently July 12th, 2020, 3:54 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 »

eclectic-tech wrote:Hi rbriddickk84 :welcome: Can you re-post your original app? In the site update, a lot of attachments got left behind... :D
Hey there :welcome:
Well i also overwrote it xD, but fortunately i posted here back then:

https://forum.rainmeter.net/viewtopic.php?f=119&t=19565


Or which original you meant? :)
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 »

The post in this thread had a link that no longer worked...
Got it from your other post, Thanks! :thumbup:
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 »

eclectic-tech wrote:The post in this thread had a link that no longer worked...
Got it from your other post, Thanks! :thumbup:
Cool, but that is my other stuff, i rewrite it from scratch, it similar, but i have different techniques now. :)
So i pasted my code, i don't know why that don't want to work.
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: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!
I used the 'set.inc' from your first skin as a replacement for 'set.txt' to test your new code...

I had several errors immediately logged when the skin loads; these were all related to variables used in your formulas and IfCondition that are not defined.

By adding the variables below to 'set.txt', I eliminated all error messages, and the code seems to work for me.
Added:

Code: Select all

mx=0
my=0
aa=0
rr=0
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 there! :)

Sorry, but my old skin is not relevant, because i don't use the exact variables, and stuffs. :) That's why i wrote that before that i started to build up from scratch, ;) But i didn't attached the txt here, that is true, sorry for that!
In my new skin, i have and had set.txt with those variables in it, but didn't worked and not working still for me.

But the txt file shouldn't be causing this, because every mouse click the skin just updating the inner variables, but the second calculation of the Red measure, where i do this: "#rtx# - #ax#" it simply not calculating. :(

That is the strange thing. I will attach the whole project here so you can see everything.
You do not have the required permissions to view the files attached to this post.