It is currently April 20th, 2024, 10:37 am

Conditional Mouse Actions?

Get help with creating, editing & fixing problems with skins
YuriKircovich
Posts: 9
Joined: July 4th, 2017, 4:44 am

Conditional Mouse Actions?

Post by YuriKircovich »

I've looked around, read the documentation, and I believe I have an adequate understanding of the rainmeter language, but I'm having trouble with something I thought would have been simple. Currently I have the Honeycomb rainmeter skins that I've tweaked a bit to my liking, where when I hover over the skin icons, they change the image in the centerpiece of my desktop. The relevant code looks like this:

Code: Select all

MouseOverAction=[!ActivateConfig "Honeycomb + GGL\chrome\Background" "background.ini"][!DeactivateConfig "SomeSkin\SubSkin" "Skin.ini"]
MouseLeaveAction=[!DeactivateConfig "Honeycomb + GGL\chrome\Background" "background.ini"][!ActivateConfig "SomeSkin\SubSkin" "Skin.ini"]
What I want to do is have another button that, instead of linking to something or somewhere, activates a slideshow in the centerpiece rather than just changing the image. A slideshow I can handle. The problem arises when I hover over the other icons again, because now I want them to deactivate and reactivate the slideshow instead of the centerpiece image "Skin.ini" until I click the button again to turn off the slideshow. I was hoping to find an easy way to set a conditional operation for a mouse action, but I've turned up empty handed so far. Basically just something similar in function to:

Code: Select all

if (ConditionalValue == true)
{
	MouseOverAction(doThing);
	MouseLeaveAction(doThing);
	}
else
{
	MouseOverAction(doOtherThing);
	MouseLeaveAction(doOtherThing);
	}
User avatar
balala
Rainmeter Sage
Posts: 16148
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Conditional Mouse Actions?

Post by balala »

YuriKircovich wrote:I was hoping to find an easy way to set a conditional operation for a mouse action, but I've turned up empty handed so far. Basically just something similar in function to:

Code: Select all

if (ConditionalValue == true)
{
	MouseOverAction(doThing);
	MouseLeaveAction(doThing);
	}
else
{
	MouseOverAction(doOtherThing);
	MouseLeaveAction(doOtherThing);
	}
I hope I didn't misunderstand your request. Sorry if I however did, but here is an approach of what I've understood.

According to this, first you need a variable. Let's name it MyVar. Create it under the [Variables] section:

Code: Select all

[Variables]
MyVar=0
We'll need to change the value of this variable when we're clicking the button:

Code: Select all

[ButtonMeter]
...
LeftMouseUpAction=[!SetVariable MyVar "(1-#MyVar#)"][!UpdateMeasure "MeasureMyVar"][!UpdateMeter "#CURRENTSECTION#"]
DynamicVariables=1
(just note that, because MyVar is set up dynamically, we need the added DynamicVariables=1 option). The [MeasureMyVar] measure will be created below.
Now we can set up the appropriate actions through a Calc measure, with proper IfConditions:

Code: Select all

[MeasureMyVar]
Measure=Calc
Formula=#MyVar#
IfCondition=(#CURRENTSECTION#=1)
IfTrueAction=[!SetOption METER-NAME MouseOverAction "[THE-BANGS-FOR-MOUSEOVERACTION-WHEN-BUTTON-CLICKED]"][!SetOption METER-NAME MouseLeaveAction "[THE-BANGS-FOR-MOUSELEAVEACTION-WHEN-BUTTON-CLICKED]"][!UpdateMeter "METER-NAME"][!Redraw]
IfFalseAction=[!SetOption METER-NAME MouseOverAction "[THE-BANGS-FOR-MOUSEOVERACTION-WHEN-BUTTON-NOT-CLICKED]"][!SetOption METER-NAME MouseLeaveAction "[THE-BANGS-FOR-MOUSELEAVEACTION-WHEN-BUTTON-NOT-CLICKED]"][!UpdateMeter "METER-NAME"][!Redraw]
DynamicVariables=1
The IfTrueAction respectively IfFalseAction will set up different bangs to the MouseOverAction and MouseLeaveAction options, depending on the value of the MyVar variable (and thus of the fact if the button was or was not clicked).
With this Calc measure, you can completely remove the MouseOverAction and MouseLeaveAction options from the appropriate meter, because anyway, they are set up dynamically, according to the value of the variable.
Please let me know if this solution match your needs.
YuriKircovich
Posts: 9
Joined: July 4th, 2017, 4:44 am

Re: Conditional Mouse Actions?

Post by YuriKircovich »

Hello, thanks for the help! From what I understand your suggestion should work correctly, but I can't seem to get it right. It's probably because I don't understand how skins properly call each other, or maybe I just misunderstood what you wrote. Here's the full code that I'm working with.

Honeycomb + GGL\betta betta.ini

Code: Select all

[Variables]
HoverVar=0

[betta]
Meter=Image
ImageName=#@#Images\betta.png
H=90
MouseOverAction=[!ActivateConfig "Honeycomb + GGL\betta\Background" "background.ini"]
MouseLeaveAction=[!DeactivateConfig "Honeycomb + GGL\betta\Background" "background.ini"]
LeftMouseUpAction=[!SetVariable HoverVar "(1-#HoverVar#)"][!UpdateMeasure "MeasureHoverVar"][!UpdateMeter "#CURRENTSECTION#"]
DynamicVariables=1

[MeasureHoverVar]
Measure=Calc
Formula=#HoverVar#
IfCondition=(#CURRENTSECTION#=1)
IfTrueAction=[!SetOptionGroup HoverButton MouseOverAction ""][!SetOptionGroup HoverButton MouseLeaveAction ""][!UpdateMeterGroup HoverButton][!Redraw]
IfFalseAction=[!SetOptionGroup HoverButton MouseOverAction "[!ActivateConfig "Honeycomb + GGL\chrome\Background" "background.ini"][!DeactivateConfig "FortCarroll\TitleCard" "TitleCard.ini"]"][!SetOptionGroup HoverButton MouseLeaveAction "[!DeactivateConfig "Honeycomb + GGL\chrome\Background" "background.ini"][!ActivateConfig "FortCarroll\TitleCard" "TitleCard.ini"]"][!UpdateMeterGroup HoverButton][!Redraw]
Honeycomb + GGL\chrome chrome.ini (Using this specific button for testing. Currently has "Group=HoverButton" set in Rainmeter.ini. I eventually intend to have more buttons under this group name.)

Code: Select all

[chrome]
DynamicVariables=1
Meter=Image
ImageName=#@#Images\chrome.png
H=90
MouseOverAction=[!ActivateConfig "Honeycomb + GGL\chrome\Background" "background.ini"][!DeactivateConfig "FortCarroll\TitleCard" "TitleCard.ini"]
MouseLeaveAction=[!DeactivateConfig "Honeycomb + GGL\chrome\Background" "background.ini"][!ActivateConfig "FortCarroll\TitleCard" "TitleCard.ini"]
LeftMouseUpAction=["C:\Program Files (x86)\Google\Chrome\Application\chrome"]
Some of what I've written is mostly for testing purposes. I don't have the actual slideshow set up to reference, but I have a placeholder skin that isn't written. I just have it set up that once the button is clicked, the icons shouldn't call their background skins and instead do nothing when hovered. Also, I need the !SetOptionGroup bangs to dynamically append rather than replace, otherwise the other buttons wont be able to call their own backgrounds.
User avatar
balala
Rainmeter Sage
Posts: 16148
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Conditional Mouse Actions?

Post by balala »

First what belongs to the HoverButton group? I don't see those sections. Are they placed into the betta betta.ini file, or in chrome chrome.ini? I suppose they should be in the betta betta.ini, beacuse if these files are both in the same config (Honeycomb + GGL), you can't load them simultaneously, so you can't set an option from one, to the other.
A second fact is that you're not using correctly the quotation marks. Eg the first two bangs used on the IfFalseAction option of the [MeasureHoverVar] measure, are these: [!SetOptionGroup HoverButton MouseOverAction [color=#FF0000]"[/color][!ActivateConfig [color=#FF0000]"[/color]Honeycomb + GGL\chrome\Background" "background.ini"][!DeactivateConfig "FortCarroll\TitleCard" "TitleCard.ini"]"]. Problem is that an open quote is closed by the next one. In the first bang, I marked with red the first two quotes of the first !SetOptionGroup bang. This bang will set to the MouseOverAction option of the HoverButton group, just the [!ActivateConfig part contained between the first two quotes, which definitely isn1t enough. In such cases you should use the magic quotes. According to this trick, your [MeasureHoverVar] measure should look like:

Code: Select all

[MeasureHoverVar]
Measure=Calc
Formula=#HoverVar#
IfCondition=(#CURRENTSECTION#=1)
IfTrueAction=[!SetOptionGroup HoverButton MouseOverAction ""][!SetOptionGroup HoverButton MouseLeaveAction ""][!UpdateMeterGroup "HoverButton"][!Redraw]
IfFalseAction=[!SetOptionGroup HoverButton MouseOverAction """[!ActivateConfig "Honeycomb + GGL\chrome\Background" "background.ini"][!DeactivateConfig "FortCarroll\TitleCard" "TitleCard.ini"]"""][!SetOptionGroup HoverButton MouseLeaveAction """[!DeactivateConfig "Honeycomb + GGL\chrome\Background" "background.ini"][!ActivateConfig "FortCarroll\TitleCard" "TitleCard.ini"]"""][!UpdateMeterGroup "HoverButton"][!Redraw]
DynamicVariables=1
Note the tripled quotes (these are named "magic quotes") around the values which will be set by the !SetOptionGroup bangs of the IfFalseAction option. I also added some quotes around the HoverButton measurename, in the [!UpdateMeterGroup "HoverButton"] bangs. These quotes are not absolutely required, the bangs will work well without them, but it seems a good practice to get used to use them. A third added thing is the DynamicVariables=1 option. You're setting dynamically the value of the HoverVar variable and in such cases, the measure won't see the dynamically set values of the variable, without this option.

And one more. This issue won't cause great problems, but you have to know that the !DeactivateConfig bang doesn't require a "File" parameter, as !ActivateConfig or !ToggleConfig do. Eg [!ActivateConfig "Honeycomb + GGL\chrome\Background" "background.ini"] is correct (supposing the config and file names are correct), but in the !DeactivateConfig bang, the last parameter (marked red) isn't required: [!DeactivateConfig "Honeycomb + GGL\chrome\Background" [color=#FF0000]"background.ini"[/color]]. It isn't, because when you're deactivating a config, Rainmeter will deactivate the loaded file and it always knows which one is loaded. But when you want to activate one, Rainmeter cann't know which one would you like to load (if there are more).

All these being said, please test again the code and let me know if it is working better.
YuriKircovich
Posts: 9
Joined: July 4th, 2017, 4:44 am

Re: Conditional Mouse Actions?

Post by YuriKircovich »

I'm sorry about the miscommunication on the config file names. I was writing "Honeycomb + GGL\betta betta.ini" trying to indicate the "betta.ini" file inside the "Honeycomb + GGL\betta" directory. Also, I'm sorry about the quotation problem as well, it was silly of me to overlook. As well, I have the "Honeycomb + GGL\chrome" config group name labeled in the "Rainmeter.ini" file under the config name section. I tried moving the group name declaration to other sections, such as under [Rainmeter] in chrome.ini, and under [chrome] in chrome.ini. This might just be me misunderstanding how group naming works. So, as you might discern from that, I still haven't gotten it working.
RainmeterDir.PNG
The image has some things missing and present that you told me to fix because it's older and I had gone through several testing iterations since (such as DynamicVariables=1 missing from [MeasureHoverVar]).
You do not have the required permissions to view the files attached to this post.
User avatar
balala
Rainmeter Sage
Posts: 16148
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Conditional Mouse Actions?

Post by balala »

Ok, please pack the whole Honeycomb + GGL config and upload it, to can check.
YuriKircovich
Posts: 9
Joined: July 4th, 2017, 4:44 am

Re: Conditional Mouse Actions?

Post by YuriKircovich »

Here's the package for Honeycomb, as well as the custom Fort Carroll one I have for testing purposes.

https://www.dropbox.com/sh/uoa7qcic2tcng19/AAB2T3Y7KvJebh8ULUpt61CDa?dl=0

Sorry for all the hassle this has been. I really hope it's not something simple I've overlooked.
User avatar
balala
Rainmeter Sage
Posts: 16148
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Conditional Mouse Actions?

Post by balala »

Let's go step by step.
First, as I said before:
balala wrote:what belongs to the HoverButton group?
(sorry for quoting myself).
Because I can't even find such a group of meters. You have bangs, to dynamically set MouseOverAction, respectively MouseLeaveAction options to the meters belonging to the HoverButton group, but where is this group? I couldn't identify any meter belonging to it.
Also can't find when the Slideshow.ini should be activated.
Due to all these, right now it's very unclear for me what should happen. Please give some further details.
YuriKircovich
Posts: 9
Joined: July 4th, 2017, 4:44 am

Re: Conditional Mouse Actions?

Post by YuriKircovich »

I'm sorry, the version I gave you probably doesn't have the group names listed. I was reading the documentation regarding group declarations at the time, and it states to place the group name "Group=HoverButton" under the [Rainmeter] section of the config (chrome.ini), which I did and that didn't work.

After that I went into Rainmeter.ini and added the group name under the config's section, which also didn't work.

I also thought that there was something I misunderstood and put the group name under [chrome] in chrome.ini, which didn't work once again.

I removed the lines that didn't work as I went along to prevent any redundancy and possible errors. That's why there wouldn't be any group names labeled in the package I gave you because I already tested them, but to be clear "chrome.ini" should be part of the group HoverButton, and eventually the rest of the buttons as well.

As for slideshow.ini, I haven't added it betta.ini because as of currently it does nothing, so having the relevant areas where it should be empty, which is effectively the same, but I can see why that would be confusing to read. The relevant sections should read as follows:

Code: Select all

IfTrueAction=[!SetOptionGroup HoverButton MouseOverAction """[!ActivateConfig "Honeycomb + GGL\betta\Slideshow" "slideshow.ini"]"""][!SetOptionGroup HoverButton MouseLeaveAction """[!DeactivateConfig "Honeycomb + GGL\betta\Slideshow"]"""][!UpdateMeterGroup HoverButton][!Redraw]
Sorry for the lack of details.
User avatar
balala
Rainmeter Sage
Posts: 16148
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Conditional Mouse Actions?

Post by balala »

YuriKircovich wrote:I'm sorry, the version I gave you probably doesn't have the group names listed. I was reading the documentation regarding group declarations at the time, and it states to place the group name "Group=HoverButton" under the [Rainmeter] section of the config (chrome.ini), which I did and that didn't work.

After that I went into Rainmeter.ini and added the group name under the config's section, which also didn't work.
In such cases, from my experience I'd say that a complete restart of Rainmeter many times can help. Not "Refresh all" or any other action, but a complete restart of Rainmeter.
YuriKircovich wrote:I also thought that there was something I misunderstood and put the group name under [chrome] in chrome.ini, which didn't work once again.
This definitely is not a good idea, won't help.
YuriKircovich wrote:I removed the lines that didn't work as I went along to prevent any redundancy and possible errors. That's why there wouldn't be any group names labeled in the package I gave you because I already tested them, but to be clear "chrome.ini" should be part of the group HoverButton, and eventually the rest of the buttons as well.

As for slideshow.ini, I haven't added it betta.ini because as of currently it does nothing, so having the relevant areas where it should be empty, which is effectively the same, but I can see why that would be confusing to read. The relevant sections should read as follows:

Code: Select all

IfTrueAction=[!SetOptionGroup HoverButton MouseOverAction """[!ActivateConfig "Honeycomb + GGL\betta\Slideshow" "slideshow.ini"]"""][!SetOptionGroup HoverButton MouseLeaveAction """[!DeactivateConfig "Honeycomb + GGL\betta\Slideshow"]"""][!UpdateMeterGroup HoverButton][!Redraw]
Ok, please definitivate your code, then pack and upload it again.