Making a RGB to HEX and vice versa converter with keyboard inputs
Posted: February 20th, 2018, 9:23 pm
Okay so, hello ! I'm trying to build a little project a bit complicated for me, simple newbie. Namely, I'm trying to make a small converter that I could click on to turn RGB codes into HEX values and vice versa, each depending of one button. I checked this https://forum.rainmeter.net/viewtopic.php?t=21130 this https://docs.rainmeter.net/manual/plugins/inputtext/#Bangs and this https://forum.rainmeter.net/viewtopic.php?p=98462#p98462 as well as this https://forum.rainmeter.net/viewtopic.php?t=18353 but I swear, my brain gotta be a big noodle cause I can't get the code to work-
aesthetically, it looks fine
and the text input meters do pop up when I click on the buttons so that's fine. but after it's the text result display side that is wonky- so I'm assuming I hecked up the setting of variables and I have no idea how to fix this
anyway, code ahead !
(huge chunks of codes stolen from the sources above, especially the conversion stuff)
anyway, if anyone could help me on that one to fix my diggy dang variables, it'd be awesome ! thanks !
aesthetically, it looks fine
and the text input meters do pop up when I click on the buttons so that's fine. but after it's the text result display side that is wonky- so I'm assuming I hecked up the setting of variables and I have no idea how to fix this
anyway, code ahead !
Code: Select all
[Variables]
CurrentInput=""
CurrentInput2=""
Maths=""
Maths2=""
[MeterInputBepsi]
Meter=String
X=0
Y=75
W=160
H=18
FontSize=10
FontColor=170,170,170,255
SolidColor=27,27,27,255
Padding=5,6,5,4
StringStyle=Italic
AntiAlias=1
Text=do your thing my dude
Group=Nonchangingstuff
[Body]
Meter=IMAGE
ImageName=#@#background.png
Group=Nonchangingstuff
Hidden=1
[Hex]
Meter=IMAGE
ImageName=#@#hex.png
LeftMouseUpAction=[!CommandMeasure MeasureInput "ExecuteBatch 1"]
DynamicVariables=1
X=110
Y=10
[Rgb]
Meter=IMAGE
ImageName=#@#rgb.png
LeftMouseUpAction=[!CommandMeasure MeasureInput2 "ExecuteBatch 2"]
DynamicVariables=1
X=110
Y=36
[Button]
Meter=IMAGE
ImageName=#@#reset button.png
ImageAlpha=1
DynamicVariables=1
X=110
Y=10
MouseOverAction=[!ShowMeterGroup Nonchangingstuff][!ShowMeterGroup Random][!Redraw]
MouseLeaveAction=[!HideMeterGroup Nonchangingstuff][!HideMeterGroup Random][!Redraw]
[MeasureInput]
Measure=Plugin
Plugin=InputText
X=4
Y=79
W=161
H=19
FontSize=12
FontColor=255,255,255,255
SolidColor=47,47,47,255
FocusDismiss=1
DefaultValue=#CurrentInput#
OnDismissAction=[!SetVariable CurrentInput ""][!Redraw]
Command1=[!SetVariable Maths "$UserInput$"][!Redraw]
[MeasureInput2]
Measure=Plugin
Plugin=InputText
X=4
Y=79
W=161
H=19
FontSize=12
FontColor=255,255,255,255
SolidColor=47,47,47,255
FocusDismiss=1
DefaultValue=#CurrentInput#
OnDismissAction=[!SetVariable CurrentInput2 ""]
Command2=[!SetVariable Maths2 "$UserInput$"]
[MeasureR]
Measure=String
String=#Maths#
RegExpSubstitute=1
Substitute="^(\d{1,3}),(\d{1,3}),(\d{1,3})$":"\1"
[MeasureG]
Measure=String
String=#Maths#
RegExpSubstitute=1
Substitute="^(\d{1,3}),(\d{1,3}),(\d{1,3})$":"\2"
[MeasureB]
Measure=String
String=#Maths#
RegExpSubstitute=1
Substitute="^(\d{1,3}),(\d{1,3}),(\d{1,3})$":"\3"
[MeasureRemainderR1]
Measure=Calc
Formula=( [MeasureR] % 16 )
Substitute="10":"a","11":"b","12":"c","13":"d","14":"e","15":"f"
[MeasureQuotientR1]
Measure=Calc
Formula=(( [MeasureR] - MeasureRemainderR1 ) / 16 )
[MeasureRemainderR2]
Measure=Calc
Formula=( MeasureQuotientR1 % 16 )
Substitute="10":"a","11":"b","12":"c","13":"d","14":"e","15":"f"
[MeasureRemainderG1]
Measure=Calc
Formula=( [MeasureG] % 16 )
Substitute="10":"a","11":"b","12":"c","13":"d","14":"e","15":"f"
[MeasureQuotientG1]
Measure=Calc
Formula=(( [MeasureG] - MeasureRemainderG1 ) / 16 )
[MeasureRemainderG2]
Measure=Calc
Formula=( MeasureQuotientG1 % 16 )
Substitute="10":"a","11":"b","12":"c","13":"d","14":"e","15":"f"
[MeasureRemainderB1]
Measure=Calc
Formula=( [MeasureB] % 16 )
Substitute="10":"a","11":"b","12":"c","13":"d","14":"e","15":"f"
[MeasureQuotientB1]
Measure=Calc
Formula=(( [MeasureB] - MeasureRemainderB1 ) / 16 )
[MeasureRemainderB2]
Measure=Calc
Formula=( MeasureQuotientB1 % 16 )
Substitute="10":"a","11":"b","12":"c","13":"d","14":"e","15":"f"
[MeasureConverted]
Measure=String
String=#[MeasureRemainderR2][MeasureRemainderR1][MeasureRemainderG2][MeasureRemainderG1][MeasureRemainderB2][MeasureRemainderB1]
DynamicVariables=1
[MeasureR1bis]
Measure=String
String=#Maths2#
RegExpSubstitute=1
Substitute="^#(.)(.)(.)(.)(.)(.)$":"\1","a":"10","b":"11","c":"12","d":"13","e":"14","f":"15"
[MeasureR2bis]
Measure=String
String=#Maths2#
RegExpSubstitute=1
Substitute="^#(.)(.)(.)(.)(.)(.)$":"\2","a":"10","b":"11","c":"12","d":"13","e":"14","f":"15"
[MeasureG1bis]
Measure=String
String=#Maths2#
RegExpSubstitute=1
Substitute="^#(.)(.)(.)(.)(.)(.)$":"\3","a":"10","b":"11","c":"12","d":"13","e":"14","f":"15"
[MeasureG2bis]
Measure=String
String=#Maths2#
RegExpSubstitute=1
Substitute="^#(.)(.)(.)(.)(.)(.)$":"\4","a":"10","b":"11","c":"12","d":"13","e":"14","f":"15"
[MeasureB1bis]
Measure=String
String=#Maths2#
RegExpSubstitute=1
Substitute="^#(.)(.)(.)(.)(.)(.)$":"\5","a":"10","b":"11","c":"12","d":"13","e":"14","f":"15"
[MeasureB2bis]
Measure=String
String=#Maths2#
RegExpSubstitute=1
Substitute="^#(.)(.)(.)(.)(.)(.)$":"\6","a":"10","b":"11","c":"12","d":"13","e":"14","f":"15"
[MeasureRbis]
Measure=Calc
Formula=( 16 * [MeasureR1bis] + [MeasureR2bis] )
DynamicVariables=1
[MeasureGbis]
Measure=Calc
Formula=( 16 * [MeasureG1bis] + [MeasureG2bis] )
DynamicVariables=1
[MeasureBbis]
Measure=Calc
Formula=( 16 * [MeasureB1bis] + [MeasureB2bis] )
DynamicVariables=1
[MeasureConvertedbis]
Measure=String
String=[MeasureRbis],[MeasureGbis],[MeasureBbis]
DynamicVariables=1
[styleTwo]
StringAlign=Center
StringCase=Upper
StringStyle=Bold
StringEffect=Shadow
FontEffectColor=0,0,0,255
FontColor=255,255,255,255
FontFace=Courier New
AntiAlias=1
[MeterCode]
Meter=STRING
MeasureName=MeasureConverted
MeterStyle=styleTwo
FontSize=8
X=55
Y=10
Text=RGB: #Maths##CRLF#HEX: %1
Group=Nonchangingstuff
Hidden=1
[MeterCodebis]
Meter=STRING
MeasureName=MeasureConvertedbis
MeterStyle=styleTwo
FontSize=8
X=55
Y=35
Text=HEX: #Maths2##CRLF#RGB: %1
Group=Nonchangingstuff
Hidden=1
anyway, if anyone could help me on that one to fix my diggy dang variables, it'd be awesome ! thanks !