It is currently August 18th, 2019, 2:04 pm

IfMatchAction question

Help with creating, editing & fixing problems with skins
roguetrip
Posts: 22
Joined: March 11th, 2019, 5:42 pm

IfMatchAction question

roguetrip » March 15th, 2019, 4:45 am

Been trying to get this down but can't get to happen.

Setup my Network Lan to change fontcolor when no network is seen. It will change color but I have to do a mousehover to get it to show No network. Then when network is back it changes color back to the original but won't show any IP's until you do a mousehover.

Code: Select all

	[Measure_IP_Web]
		Measure=Plugin
		Plugin=WebParser
		Url=http://checkip.dyndns.org
		RegExp="(?siU)Address: (.*)</body>"
		StringIndex=1
		Substitute="":"NO WAN"

	[Measure_IP_Lan]
		Measure=Plugin
		Plugin=SysInfo
		SysInfoType=IP_ADDRESS
		SysInfoData=#NIC#
		Substitute="127.0.0.1":"NO LAN","":"NO LAN"
		IfMatch="NO LAN"
		IfMatchAction=[!SetOption MeterLabelIPINFO FontColor #FCR#]
		IfNotMatchAction=[!SetOption MeterLabelIPINFO FontColor #FC1#]
		DynamicVariables=1
		
	[MeterLabelIPINFO]
		Meter=STRING
		MeterStyle=STYLE_RIGHT_BLUE
		MeasureName=Measure_IP_Lan
		MouseOverAction=[!SetOption MeterLabelIPINFO Text [Measure_IP_Web]][!Update]
		MouseLeaveAction=[!SetOption MeterLabelIPINFO Text [Measure_IP_Lan]][!Update]
		Y=#MWanISP#
		DynamicVariables=1
		
		
Been trying to crack this for a few nights and not having luck :-(


Thanks in advance for help.
roguetrip
Posts: 22
Joined: March 11th, 2019, 5:42 pm

Re: IfMatchAction question

roguetrip » March 15th, 2019, 5:01 am

Ok so if I do a "" escape it seems to work on the MouseLeaveAction but is this the best way??

Code: Select all

MouseLeaveAction=[!SetOption MeterLabelIPINFO Text ""][!Update]

I'm still wrapping my head around dynamicvariables, escaping variables and nesting :jawdrop
User avatar
balala
Rainmeter Sage
Posts: 8532
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: IfMatchAction question

balala » March 15th, 2019, 1:18 pm

roguetrip wrote:
March 15th, 2019, 4:45 am
Setup my Network Lan to change fontcolor when no network is seen. It will change color but I have to do a mousehover to get it to show No network. Then when network is back it changes color back to the original but won't show any IP's until you do a mousehover.
You have to escape the [Measure_IP_Web] and [Measure_IP_Lan] measure names into the MouseOverAction and MouseLeaveAction options of the [MeterLabelIPINFO] meter. Quotations would be good to be used around the measure names, especially that at least sometimes those values contain spaces.
With these remarks, the mentioned options would be:

Code: Select all

[MeterLabelIPINFO]
...
MouseOverAction=[!SetOption MeterLabelIPINFO Text "[*Measure_IP_Web*]"][!UpdateMeter "MeterLabelIPINFO"][!Redraw]
MouseLeaveAction=[!SetOption MeterLabelIPINFO Text "[*Measure_IP_Lan*]"][!UpdateMeter "MeterLabelIPINFO"][!Redraw]
Details: https://docs.rainmeter.net/manual/skins/option-types/#AsteriskEscape.
Also note here that besides adding the quotations and escaping the measure names, I also replaced the [!Update] bang with [!UpdateMeter "MeterLabelIPINFO"][!Redraw]. Because the !SetOption bang used into these two options are changing only the [MeterLabelIPINFO] meter, doesn't worth to update the whole skin. Updating the meter and redrawing the skin is completely enough.
And one more: would be great the users to get used to use quotations, whenever they are setting new values for any option / variable. That's why I also would add those quotations around the color codes set through the IfMatchAction and IfNotMatch action options of the [Measure_IP_Lan] measure:

Code: Select all

[Measure_IP_Lan]
...
IfMatchAction=[!SetOption MeterLabelIPINFO FontColor "#FCR#"]
IfNotMatchAction=[!SetOption MeterLabelIPINFO FontColor "#FC1#"]
Details here: https://forum.rainmeter.net/viewtopic.php?f=5&t=26350&p=137628&hilit=quote+enclose+option#p137628
roguetrip
Posts: 22
Joined: March 11th, 2019, 5:42 pm

Re: IfMatchAction question

roguetrip » March 16th, 2019, 12:44 am

Thank you, thank you, thank you.

I had looked at that options documentation so many times and had not caught on about escaping, I mean I tried the asterisk escape in one !Setoption but didn't work and dropped trying to use it.

I needed to look at all the bang commands for updatemeasure/updatemeter and redraw vs. update. Still not the clearest for a !redraw, When thinking of redraw it sounds like a image redraw not a text redraw, lol :)


Also looking at #CURRENTSECTION# misc variable looks to be a valid alternative? It works the same for me this way.

Code: Select all

MouseOverAction=[!SetOption MeterLabelIPINFO Text "[*Measure_IP_WAN*]"][!UpdateMeter "#CURRENTSECTION#"][!Redraw]
MouseLeaveAction=[!SetOption MeterLabelIPINFO Text "[*Measure_IP_LAN*]"][!UpdateMeter "#CURRENTSECTION#"][!Redraw]
OR

Code: Select all

MouseOverAction=[!SetOption #CURRENTSECTION# Text "[*Measure_IP_WAN*]"][!UpdateMeter #CURRENTSECTION#][!Redraw]
MouseLeaveAction=[!SetOption #CURRENTSECTION# Text "[*Measure_IP_LAN*]"][!UpdateMeter #CURRENTSECTION#][!Redraw]
Great info and link on the quoting issues.
User avatar
balala
Rainmeter Sage
Posts: 8532
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: IfMatchAction question

balala » March 16th, 2019, 7:30 am

roguetrip wrote:
March 16th, 2019, 12:44 am
Thank you, thank you, thank you.

I had looked at that options documentation so many times and had not caught on about escaping, I mean I tried the asterisk escape in one !Setoption but didn't work and dropped trying to use it.
You're welcome. I'm glad if it helped. Yes, the escape isn't an easy process, but over time you'll probably get used to use it.
roguetrip wrote:
March 16th, 2019, 12:44 am
I needed to look at all the bang commands for updatemeasure/updatemeter and redraw vs. update. Still not the clearest for a !redraw, When thinking of redraw it sounds like a image redraw not a text redraw, lol :)
I do like much more to always update not the whole skin, but only the needed measures / meters.
About the !Redraw bang, not the Image, String or any other meter is redrawn, but the skin. Or even better, the visual elements (meters) of the skin.
roguetrip wrote:
March 16th, 2019, 12:44 am
Also looking at #CURRENTSECTION# misc variable looks to be a valid alternative? It works the same for me this way.

Code: Select all

MouseOverAction=[!SetOption MeterLabelIPINFO Text "[*Measure_IP_WAN*]"][!UpdateMeter "#CURRENTSECTION#"][!Redraw]
MouseLeaveAction=[!SetOption MeterLabelIPINFO Text "[*Measure_IP_LAN*]"][!UpdateMeter "#CURRENTSECTION#"][!Redraw]
OR

Code: Select all

MouseOverAction=[!SetOption #CURRENTSECTION# Text "[*Measure_IP_WAN*]"][!UpdateMeter #CURRENTSECTION#][!Redraw]
MouseLeaveAction=[!SetOption #CURRENTSECTION# Text "[*Measure_IP_LAN*]"][!UpdateMeter #CURRENTSECTION#][!Redraw]
#CURRENTSECTION# is the name of the section (meter or measure) where it is used. When possible I use this variable instead of the name of the section, because when copying and pasting I don't have to rewrite the name if I'm using the same bangs on different sections. But how this does work, depends on the concrete case.
However here is a link, which explains where and when the quotes are required: https://forum.rainmeter.net/viewtopic.php?f=5&t=26350&p=137628&hilit=quote+enclose+option#p137628