It is currently March 29th, 2024, 6:55 am

Cycling through Mouse Actions

Get help with creating, editing & fixing problems with skins
User avatar
BlackChadhar
Posts: 34
Joined: March 4th, 2023, 8:16 am

Cycling through Mouse Actions

Post by BlackChadhar »

I am editing a honeycomb skin to my preferences and planned to create a skin that when clicked, changes the value of color variables in the settings file. I researched a lot but ended up with the LeftMouseUpAction and RightMouseUpAction. Is there any way that I can change the values a variable takes in cycles ? Any help would be appreciated <3
This is the entire code:

Code: Select all

[Variables]
@include=#@#Setting.inc

[Color]
Meter=Image
ImageName=#@#Images\Color.png
ImageTint=#Colour#
H=#Dimensions#
LeftMouseUpAction=[!WriteKeyValue Variables Colour "255, 255, 255" "C:\Users\Admin\Documents\Rainmeter\Skins\Clear Honeycomb\@Resources\Setting.inc"] [!Refresh *]
RightMouseUpAction=[!WriteKeyValue Variables Colour "64, 64, 64" "C:\Users\Admin\Documents\Rainmeter\Skins\Clear Honeycomb\@Resources\Setting.inc"] [!Refresh *]

[Rainmeter]
Update=1000

[Metadata]
Name=Color
Author=Budif
Information=
License=
Version=
Last edited by balala on March 4th, 2023, 12:22 pm, edited 1 time in total.
Reason: Please use <code> tags whenever are posting codes. It's the </> button.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Cycling through Mouse Actions

Post by balala »

BlackChadhar wrote: March 4th, 2023, 8:28 am I am editing a honeycomb skin to my preferences and planned to create a skin that when clicked, changes the value of color variables in the settings file. I researched a lot but ended up with the LeftMouseUpAction and RightMouseUpAction. Is there any way that I can change the values a variable takes in cycles ?
!WriteKeyValue writes the value into the skin or the specified file (in this case into the @Resources\Setting.inc file). But this doesn't makes the skin to use the newly written variable. Since you've added !Refresh bangs to both options, RightMouseUpAction and LeftMouseUpAction, you get the skin refreshed whenever are you clicking either with one or the other button and this should let the skin to use the set values. The skin definitely uses these values set when you click with either button, so am not sure what do you mean by "takes in cycles". But I ssueme you'd like not to refresh the skin on every click, especially that refresh is a less desirable operation.
If this is right, it can be easily made, by using some !SetVariable bangs beside !WriteKeyValues and omitting the refreshes. This way when you click, the new value of the variable is written immediately to the appropriate file, but since you removed the !Refresh bangs, you don't get the skin refreshed. The !SetVariable bangs set dynamically the new values for the same variable and let the skin to use them immediately. Note that the !SetVariable bang requires to add a DynamicVariables=1 option to the meter in which it is used (in this case to the [Color] meter), so make sure not to forget it.
With this, the following options should be altered as you can see bellow and the new option has to be added:

Code: Select all

[Color]
...
LeftMouseUpAction=[!WriteKeyValue Variables Colour "255,255,255" "#@#Setting.inc"][!SetVariable Colour "255,255,255"][!UpdateMeter "Color"][!Redraw]
RightMouseUpAction=[!WriteKeyValue Variables Colour "64,64,64" "#@#Setting.inc"][!SetVariable Colour "64,64,64"]
DynamicVariables=1
Take into account the following as well:
  • The above not posted options have not to be altered, leave them unchanged.
  • I removed the spaces from the color codes. Those spaces are not needed and even if it's true they don1t cause troubles, it's much better (and safer probably) not to have them.
  • I replaced the full path of the Settings.inc file (in which the variable has to be written) by #@#Setting.inc. Ranmeter references to the @Resources folder by the #@# variable, don't have to specify the full path. Rainmeter knows what does this mean.
  • I removed the [!Refresh *] bang (and this way the skin is not refreshed when you click) and added two other bangs: [!UpdateMeter "Color"] and [!Redraw]. These are used to immediately update the meter when you click and redraw the skin, to can see the result of your click with no delay. If needed, using these bangs you can add further LeftMouseDownAction and RightMouseDownAction options to the meter as well, to can use different colors when you press and when you release the button of the mouse (just an idea, if you are interested).
Please try this out and let me know if you got what you intended.
User avatar
BlackChadhar
Posts: 34
Joined: March 4th, 2023, 8:16 am

Re: Cycling through Mouse Actions

Post by BlackChadhar »

balala wrote: March 4th, 2023, 2:46 pm !WriteKeyValue writes the value into the skin or the specified file (in this case into the @Resources\Setting.inc file). But this doesn't makes the skin to use the newly written variable. Since you've added !Refresh bangs to both options, RightMouseUpAction and LeftMouseUpAction, you get the skin refreshed whenever are you clicking either with one or the other button and this should let the skin to use the set values. The skin definitely uses these values set when you click with either button, so am not sure what do you mean by "takes in cycles". But I ssueme you'd like not to refresh the skin on every click, especially that refresh is a less desirable operation.
If this is right, it can be easily made, by using some !SetVariable bangs beside !WriteKeyValues and omitting the refreshes. This way when you click, the new value of the variable is written immediately to the appropriate file, but since you removed the !Refresh bangs, you don't get the skin refreshed. The !SetVariable bangs set dynamically the new values for the same variable and let the skin to use them immediately. Note that the !SetVariable bang requires to add a DynamicVariables=1 option to the meter in which it is used (in this case to the [Color] meter), so make sure not to forget it.
With this, the following options should be altered as you can see bellow and the new option has to be added:

Code: Select all

[Color]
...
LeftMouseUpAction=[!WriteKeyValue Variables Colour "255,255,255" "#@#Setting.inc"][!SetVariable Colour "255,255,255"][!UpdateMeter "Color"][!Redraw]
RightMouseUpAction=[!WriteKeyValue Variables Colour "64,64,64" "#@#Setting.inc"][!SetVariable Colour "64,64,64"]
DynamicVariables=1
Take into account the following as well:
  • The above not posted options have not to be altered, leave them unchanged.
  • I removed the spaces from the color codes. Those spaces are not needed and even if it's true they don1t cause troubles, it's much better (and safer probably) not to have them.
  • I replaced the full path of the Settings.inc file (in which the variable has to be written) by #@#Setting.inc. Ranmeter references to the @Resources folder by the #@# variable, don't have to specify the full path. Rainmeter knows what does this mean.
  • I removed the [!Refresh *] bang (and this way the skin is not refreshed when you click) and added two other bangs: [!UpdateMeter "Color"] and [!Redraw]. These are used to immediately update the meter when you click and redraw the skin, to can see the result of your click with no delay. If needed, using these bangs you can add further LeftMouseDownAction and RightMouseDownAction options to the meter as well, to can use different colors when you press and when you release the button of the mouse (just an idea, if you are interested).
Please try this out and let me know if you got what you intended.
Hi! Thanks for the reply but 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. 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. 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.
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.

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. The main question of cycling through specific variable values on click still remains though.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Cycling through Mouse Actions

Post by balala »

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.
User avatar
BlackChadhar
Posts: 34
Joined: March 4th, 2023, 8:16 am

Re: Cycling through Mouse Actions

Post by BlackChadhar »

I made all the changes you listed and my rainmeter broke down entirely, I had to end task from task manager, delete the config file and load up rainmeter again. I tried several code positions and the issue seems to be with the measure [MeasureColor]
Edit: I found out that it goes in an infinite refresh loop
The refresh bang can be placed somewhere else afterwards but the main issue I am facing right now is the changing of the values of the variable #Colour#.
Edit 2: I messed around a bit and finally got the skin right and now I am facing a different issue, every time the skins are refreshed to change their colors, 2 skins with the same image as meter image (Not sure if this has something to do with it) stay one refresh behind. Like their skin state is one stage behind, once manually refreshed they display the same colors as others but when using this custom skin to change the colors, the two skins just don't stay in the same phase as others, if this makes sense. I won't be changing colors very often but would still like to solve this error and know what's causing it.
This is the config file:

Code: Select all

[Variables]
@include=#@#Setting.inc
Order=0

[Color]
Meter=Image
ImageName=#@#Images\Color.png
ImageTint=#Colour#
H=#Dimensions#
DynamicVariables=1

[MeasureColor]
Measure=Calc
Formula=#Order#
IfCondition=(#CURRENTSECTION#=2)
IfTrueAction=[!WriteKeyValue Variables Colour "255,255,255" "#@#Setting.inc"]
IfCondition2=(#CURRENTSECTION#=1)
IfTrueAction2=[!WriteKeyValue Variables Colour "64,64,64" "#@#Setting.inc"]
IfCondition3=(#CURRENTSECTION#=0)
IfTrueAction3=[!WriteKeyValue Variables Colour "0,0,0" "#@#Setting.inc"]
DynamicVariables=1
UpdateDivider=-1

[Rainmeter]
Update=1000
LeftMouseUpAction=[!WriteKeyValue Variables Order "((#Order#+1)%3)"][!UpdateMeasure "MeasureColor"][!Refresh *]

[Metadata]
Name=Color
Author=Budif
Information=
License=
Version=

I used the !MouseOverAction to change the color of the icon temporarily and !MouseLeaveAction to refresh causing the skin to go back to its normal color.
balala wrote: March 5th, 2023, 9:24 pmThere is nothing to correct. You're perfectly right, congratulations for the correct observations.
Thank you so much for all the explanations <3
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Cycling through Mouse Actions

Post by balala »

BlackChadhar wrote: March 6th, 2023, 1:29 pm I made all the changes you listed and my rainmeter broke down entirely, I had to end task from task manager, delete the config file and load up rainmeter again. I tried several code positions and the issue seems to be with the measure [MeasureColor]
Edit: I found out that it goes in an infinite refresh loop
Perfectly right. My bad, didn't test enough the code before posting it. Sorry for all the trouble caused.
But the basic idea is that this is one of the causes I told, why refreshes should be avoided. It can give you (me?, us? anyone!) lot of headaches.
So, replace the [MeasureColor] measure with the following one:

Code: Select all

[MeasureColor]
Measure=Calc
Formula=#ColorOrd#
IfCondition=(#CURRENTSECTION#=0)
IfTrueAction=[!SetVariable Colour "255,255,255"][!UpdateMeter "Color"][!Redraw]
IfCondition2=(#CURRENTSECTION#=1)
IfTrueAction2=[!SetVariable Colour "64,64,64"][!UpdateMeter "Color"][!Redraw]
IfCondition3=(#CURRENTSECTION#=2)
IfTrueAction3=[!SetVariable Colour "0,0,0"][!UpdateMeter "Color"][!Redraw]
DynamicVariables=1
See that this time there is no refresh at all. Even if with this solution, the Colour variable won't be used by the other skins which should use it, there is some solution to this problem as well. But since this time there is no refresh involved, the issue is fixed (I hope, at least).
But there are some other mistakes (or at least weird things) in the last posted code as well:
  • The LeftMouseUpAction option of the [Color] meter has a major problem in its !WriteKeyValue bang. Namely you've used the bang in the following form: [!WriteKeyValue Variables Order "(([#Order#]+1)%3)"]. The problem is with the red marked Order variable. Its form is a mix of the two ways of how a variable can be written and as such, it doesn't work. A variable can be written either in its "classic" form (#Order#) or as a Nesting variable ([#Order] - see that in this case the second # is missing). I used the second form of the variable in the LeftMouseUpAction option I proposed to be added to the [Rainmeter] section, because the old (or classic) form can't be used there. The reason why it can't be, is that for this form to work it requires to set the dynamic variables, adding a DynamicVariables=1 option to the meter or measure on which it is used. But unfortunately the [Rainmeter] section is not a measure, nor a meter and it doesn't support dynamic variables. However the nesting form of the variable ([#Order]) doesn't require this setting and as such it can be used even on the [Rainmeter] section.
    I assume when you've copied, then pasted the bang into the mentioned LeftMouseUpAction of the [Color] meter and have altered the bang, converting it from !SetVariable to !WriteKeyValue, you mistakenly added the extra # character, which from that point prevents the bang to correctly write the value. So, the form of the option should be one of the followings:
    • LeftMouseUpAction=[!WriteKeyValue Variables Order "(([#Order]+1)%3)"][!Refresh]
    • LeftMouseUpAction=[!WriteKeyValue Variables Order "((#Order#+1)%3)"][!Refresh]
    In both options I removed the [!UpdateMeasure "MeasureColor"] bang, because since you refresh the skin (with the [!Refresh] bang) there is no need to update the [MeasureColor] measure. This update is done in vain...
  • The MouseLeaveAction=[!Refresh] option is quite weird. I'd renounce to it. With it, whenever are you leaving the meter a refresh of the skin is done. Not a good idea, too many refreshes.
Taking into account all this, I post an altered version of the code, which doesn't refresh at all the skin. In all cases (in the IfTrueAction options of the [MeasureColor] measure, in the LeftMouseUpAction option of the [Color] meter and additionally in the commented out MouseOverAction and MouseLeaveAction option of the same [Color] meter - for these commented out options see the bellow point as well) I used both bangs: !WriteKeyValue to permanently write the variable into the [Variables] section (and this way even if manually refresh the skin, it keeps the last color) and !SetVariable, to get the skin reacting to the click immediately and dynamically, without a refresh:

Code: Select all

[Rainmeter]
Update=1000

[Metadata]
Name=Color
Author=Budif
Information=
License=
Version=

[Variables]
@include=#@#Setting.inc
Colour=255,255,255
Order=1

[Color]
Meter=Image
ImageName=#@#Images\Color.png
ImageTint=#Colour#
H=#Dimensions#
LeftMouseUpAction=[!WriteKeyValue Variables Order "((#Order#+1)%3)"][!SetVariable Order "((#Order#+1)%3)"][!UpdateMeasure "MeasureColor"]
;MouseOverAction=[!SetVariable Colour "#Hover#"][!UpdateMeter "#CURRENTSECTION#"][!Redraw]
;MouseLeaveAction=[!SetVariable Colour "#Colour#"][!UpdateMeter "#CURRENTSECTION#"][!Redraw]
;MouseLeaveAction=[!Refresh]
DynamicVariables=1

[MeasureColor]
Measure=Calc
Formula=#Order#
IfCondition=(#CURRENTSECTION#=0)
IfTrueAction=[!WriteKeyValue Variables Colour "255,255,255" "#@#Setting.inc"][!SetVariable Colour "255,255,255"][!UpdateMeter "Color"][!Redraw]
IfCondition2=(#CURRENTSECTION#=1)
IfTrueAction2=[!WriteKeyValue Variables Colour "64,64,64" "#@#Setting.inc"][!SetVariable Colour "64,64,64"][!UpdateMeter "Color"][!Redraw]
IfCondition3=(#CURRENTSECTION#=2)
IfTrueAction3=[!WriteKeyValue Variables Colour "0,0,0" "#@#Setting.inc"][!SetVariable Colour "0,0,0"][!UpdateMeter "Color"][!Redraw]
DynamicVariables=1
As told above, there are some commented out options in the [Color] meter. I explained above why has been commented out the original MouseLeaveAction. I added a new one, which finally has been commented out as well, along with the appropriate MouseOverAction. You can try adding them back, but me personally definitely would renounce to the original MouseLeaveAction.
As previously explained, the above skin / code doesn't let to alter a variable outside of this. If needed, this is possible, even without refreshing all skins. Refresh should be avoided as much as possible, for the previously explained reasons.
BlackChadhar wrote: March 6th, 2023, 1:29 pm Thank you so much for all the explanations <3
You're welcome. I'm glad if succeeded to make you understand anything from what have I explained. But did I succeed?
User avatar
BlackChadhar
Posts: 34
Joined: March 4th, 2023, 8:16 am

Re: Cycling through Mouse Actions

Post by BlackChadhar »

balala wrote: March 6th, 2023, 7:19 pm Perfectly right. My bad, didn't test enough the code before posting it. Sorry for all the trouble caused.
But the basic idea is that this is one of the causes I told, why refreshes should be avoided. It can give you (me?, us? anyone!) lot of headaches.
Nah Nah. Thanks to you I got the formula and IfCondition working which I couldn't get to myself. Now I understand better why Refresh bang should be avoided.
balala wrote: March 6th, 2023, 7:19 pm The LeftMouseUpAction option of the [Color] meter has a major problem in its !WriteKeyValue bang. Namely you've used the bang in the following form: [!WriteKeyValue Variables Order "(([#Order#]+1)%3)"]. The problem is with the red marked Order variable. Its form is a mix of the two ways of how a variable can be written and as such, it doesn't work. A variable can be written either in its "classic" form (#Order#) or as a Nesting variable ([#Order] - see that in this case the second # is missing). I used the second form of the variable in the LeftMouseUpAction option I proposed to be added to the [Rainmeter] section, because the old (or classic) form can't be used there. The reason why it can't be, is that for this form to work it requires to set the dynamic variables, adding a DynamicVariables=1 option to the meter or measure on which it is used. But unfortunately the [Rainmeter] section is not a measure, nor a meter and it doesn't support dynamic variables. However the nesting form of the variable ([#Order]) doesn't require this setting and as such it can be used even on the [Rainmeter] section.
I assume when you've copied, then pasted the bang into the mentioned LeftMouseUpAction of the [Color] meter and have altered the bang, converting it from !SetVariable to !WriteKeyValue, you mistakenly added the extra # character, which from that point prevents the bang to correctly write the value.
I see. I thought maybe you missed a # and thats why the code wasn't working so I added it but when I later found out about the Refresh loop I forgot about this # . Didn't knew there were different types of writing a variable. Thanks <3
balala wrote: March 6th, 2023, 7:19 pm The MouseLeaveAction=[!Refresh] option is quite weird. I'd renounce to it. With it, whenever are you leaving the meter a refresh of the skin is done. Not a good idea, too many refreshes.
Since I change the color of the meter image while hovering over it, I thought if I just Refresh when leaving the skin will go back to normal. Ty for the advice <3
balala wrote: March 6th, 2023, 7:19 pm Taking into account all this, I post an altered version of the code, which doesn't refresh at all the skin. In all cases (in the IfTrueAction options of the [MeasureColor] measure, in the LeftMouseUpAction option of the [Color] meter and additionally in the commented out MouseOverAction and MouseLeaveAction option of the same [Color] meter - for these commented out options see the bellow point as well) I used both bangs: !WriteKeyValue to permanently write the variable into the [Variables] section (and this way even if manually refresh the skin, it keeps the last color) and !SetVariable, to get the skin reacting to the click immediately and dynamically, without a refresh:
Thanks <3. Question: Is there some significance to the ';' placed before the MouseOverAction and MouseLeaveAction ? Also is 2 of same MouseActions ,here MouseLeaveAction, not allowed ?
balala wrote: March 6th, 2023, 7:19 pm You're welcome. I'm glad if succeeded to make you understand anything from what have I explained. But did I succeed?
Yeah, very much. Creating this skin and your help has made me understand Rainmeter way better than before. Thanks again <3

Code: Select all

MouseOverAction=[!SetVariable Colour "#Hover#"][!UpdateMeter "#CURRENTSECTION#"][!Redraw]
MouseLeaveAction=[!SetVariable Colour "#Colour#"][!UpdateMeter "#CURRENTSECTION#"][!Redraw]
Edit: For the MouseOverAction, the variable Colour would take the value of #Hover# so while changing it back during MouseLeaveAction would do nothing as the variable Colour does not have its original value since its not refreshed. So instead of changing the value for variable Colour, I just changed the meter option ImageTint, this way the variable Colour retains its original value and can be used to make the skin colour go back to normal during MouseLeaveAction

Code: Select all

[Color]
Meter=Image
ImageName=#@#Images\Color.png
ImageTint=#Colour#
H=#Dimensions#
LeftMouseUpAction=[!WriteKeyValue Variables Order "((#Order#+1)%3)"][!SetVariable Order "((#Order#+1)%3)"][!UpdateMeasure "MeasureColor"][!Refresh *]
MouseOverAction=[!SetOption #CURRENTSECTION# ImageTint "#Hover#"][!UpdateMeter "#CURRENTSECTION#"][!Redraw]
MouseLeaveAction=[!SetOption #CURRENTSECTION# ImageTint "#Colour#"][!UpdateMeter "#CURRENTSECTION#"][!Redraw]
DynamicVariables=1
The rest of the code is same and there is only one Refresh bang this time in the entire code, that is at the end of LeftMouseUpAction so all the skins are refreshed after the colour variable has changed values and not after MouseOver or MouseLeave. The skin is finally working as intended. Thanks a lot <3
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Cycling through Mouse Actions

Post by balala »

BlackChadhar wrote: March 7th, 2023, 5:46 am Nah Nah. Thanks to you I got the formula and IfCondition working which I couldn't get to myself. Now I understand better why Refresh bang should be avoided.
:thumbup:
BlackChadhar wrote: March 7th, 2023, 5:46 am I see. I thought maybe you missed a # and thats why the code wasn't working so I added it but when I later found out about the Refresh loop I forgot about this # . Didn't knew there were different types of writing a variable. Thanks <3
Yep, the #Order# is the classic form of how a variable can be used. As previously explained, if you set a value for the variable, using a !SetVariable bang, you have to add a DynamicVariables=1 option to any measure or / and meter where you want to use the dynamically set value. Since the [Rainmeter] section doesn't support dynamic variables, this form of the variable can't be used on this section.
The nested form of the variable ([#Order]) is a newer form, introduced recently. It has the advantage that can be used on the [Rainmeter] section as well.
Here you have some details about all this.
BlackChadhar wrote: March 7th, 2023, 5:46 am Thanks <3. Question: Is there some significance to the ';' placed before the MouseOverAction and MouseLeaveAction ? Also is 2 of same MouseActions ,here MouseLeaveAction, not allowed ?
The semicolon (;), added to the beginning of an option (and only on the beginning), is used to comment out the option. Such an option is completely ignored by Rainmeter, as if it doesn't exist. This is similar to the -- symbol in some programming languages (in C or Lua, for instance), with the only difference that the semicolon can be used for commenting out an option, only ON THE BEGINNING of an option. This is completely logic, because there are some options (TransformationMatrix for instance) which contain semicolon in middle and this is why this symbol is commenting out an option only if you start the option with it.
BlackChadhar wrote: March 7th, 2023, 5:46 am Yeah, very much. Creating this skin and your help has made me understand Rainmeter way better than before. Thanks again <3
You're welcome once again. :thumbup:
BlackChadhar wrote: March 7th, 2023, 5:46 am Edit: For the MouseOverAction, the variable Colour would take the value of #Hover# so while changing it back during MouseLeaveAction would do nothing as the variable Colour does not have its original value since its not refreshed. So instead of changing the value for variable Colour, I just changed the meter option ImageTint, this way the variable Colour retains its original value and can be used to make the skin colour go back to normal during MouseLeaveAction
Extremely good point, congratulations once again. You're getting better and better. Recommend you to keep working. Rainmeter is a great tool, which will give you a lot of satisfaction.
BlackChadhar wrote: March 7th, 2023, 5:46 am The rest of the code is same and there is only one Refresh bang this time in the entire code, that is at the end of LeftMouseUpAction so all the skins are refreshed after the colour variable has changed values and not after MouseOver or MouseLeave. The skin is finally working as intended. Thanks a lot <3
Yep, but you told once that you added the refreshes to can use the set variable into other skins as well. With the solution we have so far, with dynamically set variables, this is not possible. Do you need help on this as well?
User avatar
BlackChadhar
Posts: 34
Joined: March 4th, 2023, 8:16 am

Re: Cycling through Mouse Actions

Post by BlackChadhar »

balala wrote: March 7th, 2023, 4:57 pm Yep, the #Order# is the classic form of how a variable can be used. As previously explained, if you set a value for the variable, using a !SetVariable bang, you have to add a DynamicVariables=1 option to any measure or / and meter where you want to use the dynamically set value. Since the [Rainmeter] section doesn't support dynamic variables, this form of the variable can't be used on this section.
The nested form of the variable ([#Order]) is a newer form, introduced recently. It has the advantage that can be used on the [Rainmeter] section as well.
The semicolon (;), added to the beginning of an option (and only on the beginning), is used to comment out the option. Such an option is completely ignored by Rainmeter, as if it doesn't exist. This is similar to the -- symbol in some programming languages (in C or Lua, for instance), with the only difference that the semicolon can be used for commenting out an option, only ON THE BEGINNING of an option. This is completely logic, because there are some options (TransformationMatrix for instance) which contain semicolon in middle and this is why this symbol is commenting out an option only if you start the option with it.
I see. Thanks for the info <3
balala wrote: March 7th, 2023, 4:57 pm Extremely good point, congratulations once again. You're getting better and better. Recommend you to keep working. Rainmeter is a great tool, which will give you a lot of satisfaction.
Ty Ty <3 I have been researching on Rainmeter for a few days now and honestly, this tool is just EPIC. You can literally customize your desktop as you imagine and its not too hard once you start messing around with it for a while. 10/10 Tool
balala wrote: March 7th, 2023, 4:57 pm Yep, but you told once that you added the refreshes to can use the set variable into other skins as well. With the solution we have so far, with dynamically set variables, this is not possible. Do you need help on this as well?
I planned to create a skin that changes the value of colour variable which is used by all the skins, so I just had to change its value in a loop and refresh all the skins which the current solution does perfectly. I'll try creating more skins soon. Ty for all the help <3
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Cycling through Mouse Actions

Post by balala »

BlackChadhar wrote: March 8th, 2023, 9:33 am I see. Thanks for the info <3

Ty Ty <3 I have been researching on Rainmeter for a few days now and honestly, this tool is just EPIC. You can literally customize your desktop as you imagine and its not too hard once you start messing around with it for a while. 10/10 Tool
:thumbup:
BlackChadhar wrote: March 8th, 2023, 9:33 am I planned to create a skin that changes the value of colour variable which is used by all the skins, so I just had to change its value in a loop and refresh all the skins which the current solution does perfectly. I'll try creating more skins soon. Ty for all the help <3
There are some other solutions as well, for instance by using the !SetVariableGroup bang, which can dynamically set value for the variable into all skins belonging to a group. This also could avoid the need of refreshes. If you are interested please let me know.