It is currently March 28th, 2024, 3:06 pm

!WriteKeyValueGroup required

Get help with creating, editing & fixing problems with skins
User avatar
sl23
Posts: 1140
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

!WriteKeyValueGroup required

Post by sl23 »

I currently have a WiFi selector of sorts, but on refresh, it loses the FillColor it gains upon selection. I'd like it to keep the colour.

As it stands, I use a series of Bangs to reset the colour to non clicked before then setting the one clicked to it's selected colour, if that makes sense. It works fine as it is, but as I said, I'd like the selected button to show it is selected after a !Refresh.

I have this at present:

Code: Select all

[mIP]
Measure=Plugin
Plugin=WebParser.dll
Url=http://checkip.dyndns.org
UpdateRate=14400
RegExp="(?siU)Address: (.*)</body>"
StringIndex=1
Substitute="":"N/A"

[IP]
Meter=String
MeterStyle=sAllText | sHighlight
MeasureName=mIP
FontSize=7
Text=IP: %1
InlineSetting=Size | 8
InlinePattern=^.* (.*)$
LeftMouseUpAction=[!ToggleMeterGroup IP] [!UpdateMeter *] [!Redraw]
Hidden=1
Group=IP
X=117
Y=29

[sWiFiButton]
Shape=Rectangle 0,0,10,10,50 | Extend FillAlpha | StrokeWidth 2 | Extend StrokeAlpha
FillAlpha=FillColor #Color5#
StrokeAlpha=StrokeColor 128,255,0,0

MouseOverAction=[!SetOption #CURRENTSECTION# StrokeAlpha "StrokeColor 255,255,0,255"] [!UpdateMeter *][!Redraw]
MouseLeaveAction=[!SetOption #CURRENTSECTION# StrokeAlpha ""] [!UpdateMeter *] [!Redraw] 

LeftMouseUpAction=[!SetOptionGroup WiFi FillAlpha "FillColor #Color5#"][!SetOption #CURRENTSECTION# FillAlpha "FillColor #Color2#"][!CommandMeasure m#CURRENTSECTION#Run "Run"] [!WriteKeyValue #CURRENTSECTION# FillAlpha "FillColor #Color2#"]  [!UpdateMeasure mIP][!UpdateMeter IP][!UpdateMeter *] [!Redraw]

ToolTipText=[##CURRENTSECTION#Name]
DynamicVariables=1
Group=WiFi
Hidden=1
UpdateDivider=-1
X=20r
Y=r

[WiFi1]
Meter=Shape
MeterStyle=sWiFiButton
X=72
Y=10
FillAlpha=FillColor 128,255,0

[WiFi2]
Meter=Shape
MeterStyle=sWiFiButton
FillAlpha=FillColor 128,255,0

[WiFi3]
Meter=Shape
MeterStyle=sWiFiButton

[WiFi4]
Meter=Shape
MeterStyle=sWiFiButton

[WiFi5]
Meter=Shape
MeterStyle=sWiFiButton

[mWiFi1Run]
Measure=Plugin
Plugin=RunCommand
Program=PowerShell
Parameter=netsh wlan disconnect

[mWiFi2Run]
Measure=Plugin
Plugin=RunCommand
Program=PowerShell
Parameter=netsh wlan connect name="#WiFi2Name#"

[mWiFi3Run]
Measure=Plugin
Plugin=RunCommand
Program=PowerShell
Parameter=netsh wlan connect name="#WiFi3Name#"

[mWiFi4Run]
Measure=Plugin
Plugin=RunCommand
Program=PowerShell
Parameter=netsh wlan connect name="#WiFi4Name#"

[mWiFi5Run]
Measure=Plugin
Plugin=RunCommand
Program=PowerShell
Parameter=netsh wlan connect name="#WiFi5Name#"
Due to the !WriteKeyValue, as you can see, this gets added: FillAlpha=FillColor 128,255,0

If I could change this:
LeftMouseUpAction=[!SetOptionGroup WiFi FillAlpha "FillColor #Color5#"]
To this:
LeftMouseUpAction=[!WriteKeyValueGroup WiFi FillAlpha "FillColor #Color5#"]

All would be well. Is there any chance you could add Group to !WriteKeyValue please Mr JSMorley?
The only other way that I know is to write a separate !WriteKeyValue bang for each WiFi button.
Is there a simpler way?

PS, one other thing, why isn't the IP address being updated when I change WiFi or disconnect it?

Thanks for any help :thumbup:
Last edited by sl23 on August 28th, 2021, 8:54 pm, edited 1 time in total.
User avatar
death.crafter
Rainmeter Sage
Posts: 1399
Joined: April 24th, 2021, 8:13 pm
Contact:

Re: !WriteKeyValueGroup required

Post by death.crafter »

sl23 wrote: August 26th, 2021, 10:40 pm
Sounds good. But it's kinda impossible, given the way writekeyvalue works.

If you look at WriteKeyValue's parameters, they are in order, section, key, value and filepath. So, basically it writes stuff to a file. It doesn't care about what config it is. The default filepath parameter becomes #CURENTPATH##CURRENTFILE#.

So basically it can't do section groups, or config groups for that matter.

I have a simple Lua function that does this but I am not on my pc rn. So if you want I can share it tommorow.
User avatar
sl23
Posts: 1140
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: !WriteKeyValueGroup required

Post by sl23 »

Well, it's only writing to the skin's INI, so thank you for the offer, but I'll just write each option separately if there's not an easier solution.
User avatar
sl23
Posts: 1140
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: !WriteKeyValueGroup required

Post by sl23 »

I thought I would be able to get round this issue by using several !WriteKey commands, one for each button:

Code: Select all

LeftMouseUpAction=[!CommandMeasure m#CURRENTSECTION#Run "Run"] [!WriteKeyValue WiFi1 FillAlpha "FillColor #Color5#"][!WriteKeyValue WiFi2 FillAlpha "FillColor #Color5#"][!WriteKeyValue WiFi3 FillAlpha "FillColor #Color5#"][!WriteKeyValue WiFi4 FillAlpha "FillColor #Color5#"][!WriteKeyValue WiFi5 FillAlpha "FillColor #Color5#"][!WriteKeyValue #CURRENTSECTION# FillAlpha "FillColor #Color2#"] [!SetOption SelectedButton Text [##CURRENTSECTION#Name]]  [!UpdateMeasure mIP][!UpdateMeter IP][!UpdateMeter SSID] [!UpdateMeter *] [!Redraw]
;[!SetOptionGroup WiFi FillAlpha "FillColor #Color5#"][!SetOption #CURRENTSECTION# FillAlpha "FillColor #Color2#"]
ToolTipText=[##CURRENTSECTION#Name]
DynamicVariables=1
Group=WiFi
Hidden=1
UpdateDivider=-1
X=20r
Y=r
But for some reason, although it writes the info to the meters, the skin does not update to show the correct button selection.
Any idea why?

PS. I think it would be useful to be able to specify more than one meter per !WriteKey command using the | character.
For example: [!WriteKeyValue Wifi1|WiFi2|Wifi3|WiFi4|WiFi5 FillAlpha "FillColor #Color5#"]
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: !WriteKeyValueGroup required

Post by jsmorley »

sl23 wrote: August 28th, 2021, 2:27 pm I thought I would be able to get round this issue by using several !WriteKey commands, one for each button:

Code: Select all

LeftMouseUpAction=[!CommandMeasure m#CURRENTSECTION#Run "Run"] [!WriteKeyValue WiFi1 FillAlpha "FillColor #Color5#"][!WriteKeyValue WiFi2 FillAlpha "FillColor #Color5#"][!WriteKeyValue WiFi3 FillAlpha "FillColor #Color5#"][!WriteKeyValue WiFi4 FillAlpha "FillColor #Color5#"][!WriteKeyValue WiFi5 FillAlpha "FillColor #Color5#"][!WriteKeyValue #CURRENTSECTION# FillAlpha "FillColor #Color2#"] [!SetOption SelectedButton Text [##CURRENTSECTION#Name]]  [!UpdateMeasure mIP][!UpdateMeter IP][!UpdateMeter SSID] [!UpdateMeter *] [!Redraw]
;[!SetOptionGroup WiFi FillAlpha "FillColor #Color5#"][!SetOption #CURRENTSECTION# FillAlpha "FillColor #Color2#"]
ToolTipText=[##CURRENTSECTION#Name]
DynamicVariables=1
Group=WiFi
Hidden=1
UpdateDivider=-1
X=20r
Y=r
But for some reason, although it writes the info to the meters, the skin does not update to show the correct button selection.
Any idea why?
Anything you "write" will only be seen when the file in question is reloaded in the skin, which will only happen when you fully "refresh" the skin.
User avatar
sl23
Posts: 1140
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: !WriteKeyValueGroup required

Post by sl23 »

Oh damn! Ok thanks I'll try another approach, if I can find one :rofl:
User avatar
sl23
Posts: 1140
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: !WriteKeyValueGroup required

Post by sl23 »

Well, I'm trying to now write a variable which works, then use IfMatch to set the colour, which isn't working. I suspect it's to do with the Substitute again, but I just don't understand which value I should use, String or Number???

JSMorley, you said before that measures return numerical and string values, is that all of them or some of them?
In particular, the SSID is the culprit here. I'm trying to Substitute the SSID, which in the About window shows a number (0) or the string (sl.23-TT). But I'm using a Variable here so that it is dynamic. Nothing seems to work. Can I even use a Variable here?

Code: Select all

[mSSID]
Measure=Plugin
Plugin=WiFiStatus
WiFiInfoType=SSID
Substitute="-1":"No WiFi","0":"#CurrentNetwork#"

IfMatch=No WiFi
IfMatchAction=[!SetOption WiFiIcon Text "[\xEB5E]"][!SetOption WiFi1 FillColor "#Color2#"] [!UpdateMeter *] [!Redraw]
IfNotMatchAction=[!SetOption WiFiIcon Text "[\xE701]"][!SetOption WiFi1 FillColor "#Color5#"] [!UpdateMeter *] [!Redraw]

IfMatch2=#WiFi2Name#
IfMatchAction2=[!SetOption WiFi2 FillColor "#Color2#"] [!UpdateMeter *] [!Redraw]
IfNotMatchAction2=[!SetOption WiFi2 FillColor "#Color5#"] [!UpdateMeter *] [!Redraw]

IfMatch3=#WiFi3Name#
IfMatchAction3=[!SetOption WiFi3 FillColor "#Color2#"] [!UpdateMeter *] [!Redraw]
IfNotMatchAction3=[!SetOption WiFi3 FillColor "#Color5#"] [!UpdateMeter *] [!Redraw]

DynamicVariables=1
User avatar
death.crafter
Rainmeter Sage
Posts: 1399
Joined: April 24th, 2021, 8:13 pm
Contact:

Re: !WriteKeyValueGroup required

Post by death.crafter »

sl23 wrote: August 28th, 2021, 3:37 pm Well, I'm trying to now write a variable which works, then use IfMatch to set the colour, which isn't working. I suspect it's to do with the Substitute again, but I just don't understand which value I should use, String or Number???

JSMorley, you said before that measures return numerical and string values, is that all of them or some of them?
In particular, the SSID is the culprit here. I'm trying to Substitute the SSID, which in the About window shows a number (0) or the string (sl.23-TT). But I'm using a Variable here so that it is dynamic. Nothing seems to work. Can I even use a Variable here?

Code: Select all

[mSSID]
Measure=Plugin
Plugin=WiFiStatus
WiFiInfoType=SSID
Substitute="-1":"No WiFi","0":"#CurrentNetwork#"

IfMatch=No WiFi
IfMatchAction=[!SetOption WiFiIcon Text "[\xEB5E]"][!SetOption WiFi1 FillColor "#Color2#"] [!UpdateMeter *] [!Redraw]
IfNotMatchAction=[!SetOption WiFiIcon Text "[\xE701]"][!SetOption WiFi1 FillColor "#Color5#"] [!UpdateMeter *] [!Redraw]

IfMatch2=#WiFi2Name#
IfMatchAction2=[!SetOption WiFi2 FillColor "#Color2#"] [!UpdateMeter *] [!Redraw]
IfNotMatchAction2=[!SetOption WiFi2 FillColor "#Color5#"] [!UpdateMeter *] [!Redraw]

IfMatch3=#WiFi3Name#
IfMatchAction3=[!SetOption WiFi3 FillColor "#Color2#"] [!UpdateMeter *] [!Redraw]
IfNotMatchAction3=[!SetOption WiFi3 FillColor "#Color5#"] [!UpdateMeter *] [!Redraw]

DynamicVariables=1
I think IfMatch is evaluated before substitution. Or may be it's something else.
User avatar
sl23
Posts: 1140
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: !WriteKeyValueGroup required

Post by sl23 »

I don't think it is, because the part where it changes the icon is determined by the text substitution:

Code: Select all

Substitute="-1":"No WiFi"
IfMatch=No WiFi
IfMatchAction=[!SetOption WiFiIcon Text "[\xEB5E]"] [!UpdateMeter *] [!Redraw]
IfNotMatchAction=[!SetOption WiFiIcon Text "[\xE701]"] [!UpdateMeter *] [!Redraw]
User avatar
death.crafter
Rainmeter Sage
Posts: 1399
Joined: April 24th, 2021, 8:13 pm
Contact:

Re: !WriteKeyValueGroup required

Post by death.crafter »

sl23 wrote: August 28th, 2021, 3:55 pm I don't think it is, because the part where it changes the icon is determined by the text substitution:

Code: Select all

Substitute="-1":"No WiFi"
IfMatch=No WiFi
IfMatchAction=[!SetOption WiFiIcon Text "[\xEB5E]"] [!UpdateMeter *] [!Redraw]
IfNotMatchAction=[!SetOption WiFiIcon Text "[\xE701]"] [!UpdateMeter *] [!Redraw]
Well, then I would suggest to check for typos. And using [!UpdateMeter *] is not recommended since you change only one meter.
Post Reply