BlackChadhar wrote: ↑March 5th, 2023, 6:49 am
by 'cycles' I mean that whenever I left click the skin, it changes the colour variable value in a cycle of let's say 3.So if I click it once its on 1st stage, when I click it again its on 2nd stage, when I click it again its on 3rd stage and when I click it again its back to 1st stage.
You have to create a variable, which controls the colors. For instance add the following variable to the [Variables] section:
ColorOrd=0 (obviously you can use any name you want for this variable, this is just an example).
To can click the skin, you have to add the following option to the [Rainmeter] section. If you do add it, you can click anywhere to the skin in order to update the colors, but if there is a meter having defined another LeftMouseUpAction (so an operation which is executed when you click the meter), the action defined in the [Rainmeter] section (so the one which should update the color) doesn't work and instead of it, the operation defined for the click of the meter is executed. If you click outside of the meter, where no other LeftMouseUpAction is defined (exceptin the one defined in the [Rainmeter] section), th operation is executed but if you click to a meter having defined such an operation, the operation defined in the [Rainmeter] section is ignored.
So, assuming there is no left-click operation defined on meters of your skin, you can add the following option to the [Rainmeter] section:
LeftMouseUpAction=[!SetVariable ColorOrd "(([#ColorOrd]+1)%3)"][!UpdateMeasure "MeasureColor"][!Redraw]. Note here that updated a meter which is not defined so far, but will be immediately (I!m talking about the [MeasureColor] measure, updated by the
[!UpdateMeasure "MeasureColor"] bang of the above option).
Finally you have to add the previously updated, but not so far defined measure. Add it anywhere to your code:
Code: Select all
[MeasureColor]
Measure=Calc
Formula=#ColorOrd#
IfCondition=(#CURRENTSECTION#=0)
IfTrueAction=[!WriteKeyValue Variables Colour "255,255,255"][!Refresh *]
IfCondition2=(#CURRENTSECTION#=1)
IfTrueAction2=[!WriteKeyValue Variables Colour "64,64,64"][!Refresh *]
IfCondition3=(#CURRENTSECTION#=2)
IfTrueAction3=[!WriteKeyValue Variables Colour "0,0,0"][!Refresh *]
DynamicVariables=1
Note that I set three colors for the Colour variable,
255,255,255,
64,64,64 and finally
0,0,0. If you want to set other colors (and most probably you do want), alter the color codes appropriately.
I left the
[!Refresh *] bang besides the !WriteKeyValue bangs, because you said that:
BlackChadhar wrote: ↑March 5th, 2023, 6:49 am
The colour variables I am using is gonna be used by all the rainmeter skins I have installed so all the skins would have to be refreshed hence, I went with
[!Refresh *] bang.
Even if there are some other ways to get the variable into the other skins as well, for first this is the simplest way to achieve what you've described. However this is a less desirable approach,
refresh is a very big gun (paraphrasing jsmorely) and should be treated carefully.
BlackChadhar wrote: ↑March 5th, 2023, 6:49 am
I don't quite understand the
[!SetVariable] and
[!Update] bangs so didn't include those. What is the difference between
!WriteKeyVariable ,
!Refresh and
!SetVariable ,
!Update ,
!Redraw since the code was working even with just
!WriteKeyVariable and
!Refresh.
- !WriteKeyValue permanently writes an option to certain section of your skin. In this case the option in cause is a variable (Colour - the second parameter of the bang), written to the [Variables] section (the first parameter). The written value is the third parameter (it is 255,255,255, 64,64,64 or 0,0,0 accordingly in the above code). Finally the last parameter (the fourth one) is an optional parameter, which can be omitted and it represents the file in which the bang has to write the value. If this parameter is missing, the bang writes the value into the current file (in which it is used).
- !Refresh - Refreshes the skin. If you write a variable (or whatever other option) using the above !WriteKeyValue, the skin is not able to use this newly written value, unless you refresh it, with a !Refresh bang. As said above, this bang can be extremely destructive, because and option set by a !SetOption or variable set by a !SetVariable is immediately destroyd, when you refresh the skin. When it has to be used or when you should renounce to this bang, depends. Over time, if you keep working you'll better understand these details.
- !SetVariable - dynamically sets a value for a variable, which can and is used by the skin, until next time you set a new value of the variable with another !SetVariable, or you refresh the skin.
- !Update - The [!Update] bang updates the skin. But this bang has some variants:
- !UpdateMeter only updates certain meter, which is added by the parameter. Additionally the [!UpdateMeter *] bang updates all meteres.
- !UpdateMeasure only updates a measure (same way as a !UpdateMeter updates a meter). Additionally the [!UpdateMeasure *] bang can be used this time as well, to update all measures.
- !Redraw - Redreaws the skin. To understand why is this needed, I tell just just that when you updates some meters by !UpdateMeter bangs, you don't see any changes even if the meters are updates, unless you're redrawing the skin (for instance with this bang).
BlackChadhar wrote: ↑March 5th, 2023, 6:49 am
And the
!LeftMouseDownAction and
!RightMouseDownAction wont have a point as when I click on the skin to set a color and release it, the color will again change and I wont be able to keep the UpAction colors. I want to keep the written variables as changed until I change their values again using this skin.
Currently I can only have 2 colour presets on Left and Right clicks but I want to have multiple colour presets that I can go through with single clicks.I tried the if condition as well but couldn't get it to work.
There is no action like
!LeftMouseDownAction or
!RightMouseDownAction. The exclamation mark in this case is not needed. The operations are LeftMouseDownAction and RightMouseDownAction and these can be added to any meter.
To give you an example of what I meant:
Code: Select all
[Color]
...
ImageTint=#Colour#
LeftMouseDownAction=[!SetVariable Colour "255,0,0"][!UpdateMeter "Color"][!Redraw]
LeftMouseUpAction=[!SetVariable Colour "255,255,255"][!UpdateMeter "Color"][!Redraw]
DynamicVariables=1
When you click the meter, its ImageTint is set to red (
255,0,0 - the color used in the !SetVariable bang of the LeftMouseDownAction option). When you release the button, the same option is set to white (
255,255,255 - used in the LeftMouseUpAction). This way, if you click "normally", you get the meter red for a moment (while the button is hold down), then you get it white (when you release the button).
This can't be achieved with !WriteKeyValue bangs. It simply is impossible, due to the needed refreshes if you want to see the result of a !WriteKeyValue bang.
BlackChadhar wrote: ↑March 5th, 2023, 6:49 am
Edit: I tried working around with
!WriteKeyVariable ,
!Refresh and
!SetVariable ,
!Update ,
!Redraw. From what I have observed and understood is that the former rewrites the values of variables in text file whereas the latter just changes the values of variables temporarily for the running instance and these values will go back to normal when refreshed, correct me if I'm wrong.
There is nothing to correct. You're perfectly right, congratulations for the correct observations.