It is currently April 26th, 2024, 7:26 pm

"#@#" Shown as full path when read as nested variable.

Get help with creating, editing & fixing problems with skins
User avatar
_3D_
Posts: 16
Joined: July 25th, 2020, 12:46 pm
Location: London, UK.

"#@#" Shown as full path when read as nested variable.

Post by _3D_ »

My somewhat over engineered variable editor:

Image

The editor itself is for my still in development RainTask skin, which has 26 buttons on the upper part, with another 8 surrounding each one.

So i made a (hopefully) visually intuitive editor to access and edit the mouse click up down etc actions for all of those, it works amazingly well for something I have made but I ran in to this issue:

When it reads the variable from the file, it shows the #@# variable as a literal path, as can be seen in the image.

Here is the code for row 4, it sets the displayed text to a value as derived from a nested variable:

Code: Select all

[Variables]
ButtonN=4
MouseButton=LMD

Code: Select all

[CurrentValue4]
Meter=String
X=40
Y=654
W=945
H=32
MeterStyle=CurrentValueStyle
Text=[#B#ButtonN#_4_#MouseButton#]
DynamicVariables=1
MouseOverAction=[!SetOption B4 SolidColor "0,50,0,200"][!UpdateMeter B4][!Redraw]
MouseLeaveAction=[!SetOption B4 SolidColor "0,0,0,1"][!UpdateMeter B4][!Redraw]
LeftMouseUpAction=[!CommandMeasure ChangeVariable4 "ExecuteBatch 1"]
I was expecting the text to be displayed as:

Code: Select all

#@#Scripts\FF_Left_Window.exe
Instead of:

Code: Select all

C:\`Custom\Apps\Rainmeter\Skins\RainTask\@Resources\Scripts\FF_Left_Window.exe
I'm guessing the issue is perhaps with the nested variable, or maybe I need to use a 'Substitute' line somewhere, I did try adding this line to the meter:

Code: Select all

Substitute="#@#":"#*@*#"
I was hoping the escape would perhaps make it more literal since that trick worked in another config, but it was just a rough guess and didn't work, also i have no clues on how Rainmeter resolves these paths, any input would greatly appreciated.
Last edited by _3D_ on August 19th, 2020, 5:17 pm, edited 1 time in total.
Yellow on white is seldom a good idea.
My DeviantArt Page
User avatar
Yincognito
Rainmeter Sage
Posts: 7174
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: "#@#" Shown as full path when read as nested variable.

Post by Yincognito »

_3D_ wrote: August 19th, 2020, 3:47 pmWhen it reads the variable from the file, it shows the #@# variable as a literal path, as can be seen in the image.

I was expecting the text to be displayed as:

Code: Select all

#@#Scripts\FF_Left_Window.exe
Instead of:

Code: Select all

C:\`Custom\Apps\Rainmeter\Skins\RainTask\@Resources\Scripts\FF_Left_Window.exe
I'm guessing the issue is perhaps with the nested variable, or maybe I need to use a 'Substitute' line somewhere, I did try adding this line to the meter:

Code: Select all

Substitute="#@#":"#*@*#"
I was hoping the escape would perhaps make it more literal since that trick worked another config, but it was just a rough guess and didn't work, also i have no clues on how Rainmeter resolve these paths, any input would greatly appreciated.
The substitute you're looking for is (this can be further refined, if needed):

Code: Select all

RegExpSubstitute=1
Substitute="^.*@Resources\\":"#*@*#"
but it has to be applied on measures, and not meters (like you attempted to).

Now on the issue itself, this happens because variables are resolved at skin load or refresh, see here, so once you input that #@# variable unescaped, it will be replaced with the actual path no matter what, simply because that replacement happens before anything else does. In other words, the only 2 solutions I see for this is either:
- input the variable in the escaped form
- use the above substitute in the measure that gets that variable mix you have

EDIT: Just noticed your nesting is not quite appropriate, so here is a code sample (substitution variant):

Code: Select all

[Variables]
B8_4_LMD=#@#Scripts\FF_Left_Window.exe
ButtonN=4
MouseButton=LMD

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
BackgroundMode=2
SolidColor=47,47,47,255

---Measures---

[MeasureTest]
Measure=String
String=[#B8_[#ButtonN]_[#MouseButton]]
UpdateDivider=-1
RegExpSubstitute=1
Substitute="^.*@Resources\\":"#*@*#"

---Meters---

[MeterTest]
Meter=STRING
X=0
Y=0
FontFace=Consolas
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
FontSize=16
AntiAlias=1
MeasureName=MeasureTest
Text="%1"
or, the #@# escaping variant (no measure manipulating the string afterwards needed):

Code: Select all

[Variables]
B8_4_LMD=#*@*#Scripts\FF_Left_Window.exe
ButtonN=4
MouseButton=LMD

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
BackgroundMode=2
SolidColor=47,47,47,255

---Meters---

[MeterTest]
Meter=STRING
X=0
Y=0
FontFace=Consolas
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
FontSize=16
AntiAlias=1
Text="[#B8_[#ButtonN]_[#MouseButton]]"
If your code after integration requires it, you can of course add DynamicVariables=1 where needed. In my sample, it wasn't.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
_3D_
Posts: 16
Joined: July 25th, 2020, 12:46 pm
Location: London, UK.

Re: "#@#" Shown as full path when read as nested variable.

Post by _3D_ »

Yincognito, thanks so much for your help, i'l be sure to include you in the credits. It will take me a couple of hours to get my head around this since I'm still very much new to rainmeter, but this certainly looks like the correct way at first glance, much appreciated. :thumbup:
Yellow on white is seldom a good idea.
My DeviantArt Page
User avatar
Yincognito
Rainmeter Sage
Posts: 7174
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: "#@#" Shown as full path when read as nested variable.

Post by Yincognito »

_3D_ wrote: August 19th, 2020, 5:29 pm Yincognito, thanks so much for your help, i'l be sure to include you in the credits. It will take me a couple of hours to get my head around this since I'm still very much new to rainmeter, but this certainly looks like the correct way at first glance, much appreciated. :thumbup:
No need to, friend - it was just a minor explanation of what's happening, not really a contribution to the code. ;-) I actually became familar with the way these things happen in a somewhat similar case in my attempt to modify my skins, so I've been in this situation as well, albeit for a different purpose.

Just for reference, you can parse the (Variables.inc, I suppose) file yourself, instead of @Include it like you're probably doing now. For example:
- create a Variables.inc file in your @Resources folder of your skin, with the following contents:

Code: Select all

[Variables]

B8_1_LMD=[!ToggleConfig "RainTask\Taskbar\Window_Controls\Firefox" "Win_CTRL_Firefox.ini"]
B8_2_LMD=[!ToggleConfig "RainTask\Taskbar\FF_Remote" "FF_Remote.ini"]
B8_3_LMD=[!ToggleConfig "RainTask\Taskbar\Window_Controls\Firefox" "Win_CTRL_Firefox.ini"]
B8_4_LMD=#@#Scripts\FF_Left_Window.exe
B8_5_LMD=#@#Scripts\Start_Or_Max_FireFox.exe
B8_6_LMD=#@#Scripts\FF_Full_Window.exe
- paste this in your skin:

Code: Select all

[Variables]
ButtonN=4
MouseButton=LMD

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
BackgroundMode=2
SolidColor=47,47,47,255

---Measures---

[MeasureParseFile]
Measure=WebParser
Url="file://#@#Variables.inc"
CodePage=1200
RegExp=(?siU)^(.*)$
StringIndex=1
UpdateRate=600
FinishAction=[!UpdateMeasureGroup "FileGroup"][!UpdateMeter *][!Redraw]
OnConnectErrorAction=[!UpdateMeasureGroup "FileGroup"][!UpdateMeter *][!Redraw]
OnRegExpErrorAction=[!UpdateMeasureGroup "FileGroup"][!UpdateMeter *][!Redraw]

[MeasureFileString]
Group=FileGroup
Measure=String
String="[MeasureParseFile]"
RegExpSubstitute=1
Substitute="(?si)\s*\[Variables\]\s*(?=\R)":"","(?siU)\R(\N*)=(\N*?)":'[!SetVariable \1 """\2"""]',"(?si)^.(.*)$":"\1"
UpdateDivider=-1
OnUpdateAction=[MeasureFileString]
DynamicVariables=1

---Meters---

[MeterTest]
Meter=STRING
X=0
Y=0
FontFace=Consolas
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
FontSize=16
AntiAlias=1
MeasureName=MeasureFileString
Text="Test = [#B8_[#ButtonN]_[#MouseButton]]"
DynamicVariables=1
Result:
ParseVariablesFile.jpg
Of course, you should make a backup of your actual skin first, or test it as a new skin, as it's only for demonstration purposes. The @Include variant is probably recommended for regular Rainmeter users, as Rainmeter does the hard work for you, while the above variant is slightly more advanced stuff. I just wanted to show you that it can be done in various ways, that's all.
You do not have the required permissions to view the files attached to this post.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
_3D_
Posts: 16
Joined: July 25th, 2020, 12:46 pm
Location: London, UK.

Re: "#@#" Shown as full path when read as nested variable.

Post by _3D_ »

Image
Its working much better now. :)

I had to make a slight tweak to the nested variable from your correctly formatted example, but i think this is still ok:

Code: Select all

[MeasureVAR_4]
Measure=String
String=[#B[#ButtonN]_4_[#MouseButton]]
UpdateDivider=-1
RegExpSubstitute=1
Substitute="^.*@Resources\\":"#*@*#"

Code: Select all

[CurrentValue4]
Meter=String
MeterStyle=CurrentValueStyle
StringAlign=Left
X=40
Y=481
W=945
H=32
MouseOverAction=[!SetOption B4 SolidColor "0,50,0,200"][!UpdateMeter B4][!Redraw]
MouseLeaveAction=[!SetOption B4 SolidColor "0,0,0,1"][!UpdateMeter B4][!Redraw]
LeftMouseUpAction=[!CommandMeasure ChangeVariable1 "ExecuteBatch 1"]
MeasureName=MeasureVAR_4
Text="%1"
Yellow on white is seldom a good idea.
My DeviantArt Page
User avatar
Yincognito
Rainmeter Sage
Posts: 7174
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: "#@#" Shown as full path when read as nested variable.

Post by Yincognito »

_3D_ wrote: August 20th, 2020, 12:32 pmIts working much better now. :)
[...]
I had to make a slight tweak to the nested variable from your correctly formatted example, but i think this is still ok.
Nice. ;-) Regarding the tweak, obviously you know better what those numbers from the variable name mean and which one is dynamic and which one isn't, so as long as it does what you want to, all good. :thumbup:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
_3D_
Posts: 16
Joined: July 25th, 2020, 12:46 pm
Location: London, UK.

Re: "#@#" Shown as full path when read as nested variable.

Post by _3D_ »

A followup question if I may, I'm having the same issue but in reverse now. While the correct path is shown on the skin, the literal path is being written to the file after enter is pressed.

While it still works fine, i was wondering if i can reuse the same RegXP measure to alter the $UserInput$ before using it with !WriteKey.

Here i reused [MeasureVAR_4] to set the DefaultValue= for the IntputText plugin in [ChangeVariable4], for the correct path to also show there when the field is selected:

Code: Select all

[MeasureVAR_4]
Measure=String
String=[#B[#ButtonN]_4_[#MouseButton]]
UpdateDivider=-1
RegExpSubstitute=1
Substitute="^.*@Resources\\":"#*@*#"

Code: Select all

[CurrentValue4]
Meter=String
X=40
Y=654
W=945
H=32
MeterStyle=CurrentValueStyle
MouseOverAction=[!SetOption B4 SolidColor "0,50,0,200"][!UpdateMeter B4][!Redraw]
MouseLeaveAction=[!SetOption B4 SolidColor "0,0,0,1"][!UpdateMeter B4][!Redraw]
LeftMouseUpAction=[!CommandMeasure ChangeVariable4 "ExecuteBatch All"]
MeasureName=MeasureVAR_4
Text="%1"

Code: Select all

[ChangeVariable4]
Measure=Plugin
Plugin=InputText
X=40
Y=654
W=945
H=32
FontSize=7
FontFace=Consolas
FontColor=255,255,0,255
SolidColor=0,0,0,255
FocusDismiss=1
DefaultValue=[MeasureVAR_4]
Command1=[!WriteKeyValue Variables "B#ButtonN#_4_#MouseButton#" "$UserInput$" "#@#MouseButtonVariables.inc"][!Refresh]
I was wondering if there is an easy way to reuse [MeasureVAR_4] but this time to set a new variable with the RegXP corrected value, which i could then use with !Writekey somehow.

Im guessing [ChangeVariable4] would end with something like:

Code: Select all

[ChangeVariable4]
...
Command1=[!SetVariable "[#B[#ButtonN]_4_[#MouseButton]]" "$UserInput$"]
Command2=[!UpdateMeasure MeasureVAR_4][!Redraw]
This does seem to change the measure correctly in the log, but I'm stuck on how to set this new text as a variable and then writing that variable to the file.
Yellow on white is seldom a good idea.
My DeviantArt Page
User avatar
Yincognito
Rainmeter Sage
Posts: 7174
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: "#@#" Shown as full path when read as nested variable.

Post by Yincognito »

_3D_ wrote: August 21st, 2020, 12:07 am A followup question if I may, I'm having the same issue but in reverse now. While the correct path is shown on the skin, the literal path is being written to the file after enter is pressed.

While it still works fine, i was wondering if i can reuse the same RegXP measure to alter the $UserInput$ before using it with !WriteKey.

Here i reused [MeasureVAR_4] to set the DefaultValue= for the IntputText plugin in [ChangeVariable4], for the correct path to also show there when the field is selected:

Code: Select all

[MeasureVAR_4]
Measure=String
String=[#B[#ButtonN]_4_[#MouseButton]]
UpdateDivider=-1
RegExpSubstitute=1
Substitute="^.*@Resources\\":"#*@*#"

Code: Select all

[CurrentValue4]
Meter=String
X=40
Y=654
W=945
H=32
MeterStyle=CurrentValueStyle
MouseOverAction=[!SetOption B4 SolidColor "0,50,0,200"][!UpdateMeter B4][!Redraw]
MouseLeaveAction=[!SetOption B4 SolidColor "0,0,0,1"][!UpdateMeter B4][!Redraw]
LeftMouseUpAction=[!CommandMeasure ChangeVariable4 "ExecuteBatch All"]
MeasureName=MeasureVAR_4
Text="%1"

Code: Select all

[ChangeVariable4]
Measure=Plugin
Plugin=InputText
X=40
Y=654
W=945
H=32
FontSize=7
FontFace=Consolas
FontColor=255,255,0,255
SolidColor=0,0,0,255
FocusDismiss=1
DefaultValue=[MeasureVAR_4]
Command1=[!WriteKeyValue Variables "B#ButtonN#_4_#MouseButton#" "$UserInput$" "#@#MouseButtonVariables.inc"][!Refresh]
I was wondering if there is an easy way to reuse [MeasureVAR_4] but this time to set a new variable with the RegXP corrected value, which i could then use with !Writekey somehow.

Im guessing [ChangeVariable4] would end with something like:

Code: Select all

[ChangeVariable4]
...
Command1=[!SetVariable "[#B[#ButtonN]_4_[#MouseButton]]" "$UserInput$"]
Command2=[!UpdateMeasure MeasureVAR_4][!Redraw]
This does seem to change the measure correctly in the log, but I'm stuck on how to set this new text as a variable and then writing that variable to the file.
I won't go into detail for now, but I believe in this case using magic quotes around "$UserInput$" (like """"$UserInput$"""") when !WriteKeyValue the thing should in theory solve this. Some tweaking of quotes in other options might be needed.

Let me know if this works.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
_3D_
Posts: 16
Joined: July 25th, 2020, 12:46 pm
Location: London, UK.

Re: "#@#" Shown as full path when read as nested variable.

Post by _3D_ »

I'm not sure I fully understood you since the change hasn't made any effect. I do understand the magic quotes though since I've used them elsewhere, I'm just not sure on how they apply here, so i would be grateful for a bit more context.

Something else i noticed though:

Code: Select all

[ChangeVariable1]
Measure=Plugin
Plugin=InputText
X=40
Y=481
W=945
H=32
FontSize=7
FontFace=Consolas
FontColor=255,255,0,255
SolidColor=0,0,0,255
FocusDismiss=1
DefaultValue=[MeasureVAR_1]
Command1=[!UpdateMeaseure ChangeVariable1][!Redraw][!WriteKeyValue Variables "B#ButtonN#_1_#MouseButton#" """$UserInput$""" "#@#MouseButtonVariables.inc"]
RegExpSubstitute=1
Substitute="^.*@Resources\\":"#*@*#"
After adding the regxp lines to the [ChangeVariable1] measure, and then toggling them on and off, the value stored after pressing enter is indeed corrected when the regxp is enabled there, as is visible in the log. But it looks like that is only saved in memory, since the text is still treated literally when written.

I'm obviously out of my depth here, but It would be nice to see the correct path in all three places, since it now shows fine both as DefaultText= and after first click on editing.
Yellow on white is seldom a good idea.
My DeviantArt Page
User avatar
_3D_
Posts: 16
Joined: July 25th, 2020, 12:46 pm
Location: London, UK.

Re: "#@#" Shown as full path when read as nested variable.

Post by _3D_ »

Ive attached the skin in its current state for you to preview!

I'm sorry but i normally do all the in code commenting once i have finalized the code, so its not going to be easy to navigate and will likely have lots of obvious errors, but a trained eye should be able to work out whats going on. :confused: :???: :uhuh:
You do not have the required permissions to view the files attached to this post.
Yellow on white is seldom a good idea.
My DeviantArt Page