It is currently April 18th, 2024, 11:25 pm

Merging Skins For Improved Functionality (i hope)[succeeded]

Get help with creating, editing & fixing problems with skins
User avatar
death.crafter
Rainmeter Sage
Posts: 1399
Joined: April 24th, 2021, 8:13 pm

Re: Merging Skins For Improved Functionality (i hope)

Post by death.crafter »

CodeCode wrote: September 15th, 2021, 10:06 am Ok. Forgive my naivety. But how is the ps1 executed initially? Is this correct?
LeftMouseUpAction=[!CommandMeasure Config_psrm "Update"]
It seems it would be ok, but the initial load of the skin, will require a user triggered action, or is there an 'autopilot-startup'?
It's automated 😉
from the Realm of Death
User avatar
CodeCode
Posts: 1365
Joined: September 7th, 2020, 2:24 pm
Location: QLD, Australia

Re: Merging Skins For Improved Functionality (i hope)

Post by CodeCode »

Ok, so I have things going pretty decently.
But the containers aren't coming out. The text scrolls, but the shapes are not there.
I am getting these errors on refresh:

Code: Select all

System.Management.Automation.ParseException: At line:20 char:15
+ [MeterContainer$i]
+               ~
Missing ] at end of attribute or type literal.

At line:20 char:18
+ [MeterContainer$i]
+                  ~
Unexpected token ']' in expression or statement.

At line:25 char:9
+ [MeterStr$i]
+         ~
Missing ] at end of attribute or type literal.

At line:25 char:12
+ [MeterStr$i]
+            ~
Unexpected token ']' in expression or statement.

At line:40 char:34
+    $string | Out-Fi (ExploreConfig\Access.ini - [Config_psrm])

Code: Select all

Invalid container: Container (ExploreConfig\Access.ini - [MeterStr])

Code: Select all

function Update {
    $RmAPI.Bang('[!EnableMeasure GetConfigName][!CommandMeasure GetConfigName Update]')
    MakeConfigs
    $RmAPI.Bang("[!DisableMeasure $($RmAPI.GetMeasureName())]")
}
function MakeConfigs {
    $activeConfigsRaw=$RmAPI.MeasureStr('GetConfigName')
    # split method is used to split a string by a given delimiter. 
    # Here I used '\|' since '|' is a regex reserved character. 
    $activeConfigs=$activeConfigsRaw -split '#clrf#'
    # now that I have an array of active configs, I can use them to make my meters.
    # in this function we would iterate through the values in $activeConfigs to make the meters. 
    # $_ is a automatic variable that is the current object in the iteration. 

   $string=''
   $i=0
"@
   $activeConfigs | ForEach-Object {
       $string+=@"
[MeterContainer$i]
Meter=Shape
MeterStyle=BGStyle
Y=10R
DynamicVariables=1
[MeterStr$i]
Meter=String
X=450
Y=25r
Text=$_
MeterStyle=Contents
Container=MeterContainer$i
DynamicVariables=1

"@
        # we increase the $i variable with each iteration
        $i++
   }
   # now that we have a complete string of measures and meters, we can make a file out of it. 
   # we will use unicode encoding, aka UTF-16
   $string | Out-File -FilePath "$($RmAPI.VariableStr('@'))Builder.inc" -Encoding utf8

}
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.
User avatar
death.crafter
Rainmeter Sage
Posts: 1399
Joined: April 24th, 2021, 8:13 pm

Re: Merging Skins For Improved Functionality (i hope)

Post by death.crafter »

See line 17 of what you posted here.

There is an extra "@
from the Realm of Death
User avatar
CodeCode
Posts: 1365
Joined: September 7th, 2020, 2:24 pm
Location: QLD, Australia

Re: Merging Skins For Improved Functionality (i hope)

Post by CodeCode »

death.crafter wrote: September 15th, 2021, 12:57 pm See line 17 of what you posted here.

There is an extra "@
Ok. Got rid of it.

Weirdly the ps1 is no longer writing to the inc file.

At one point I caused a wild loop, and when I ctrl-z then saved the loop stopped, and the config strings all came out good.
But ya, it isnt building anymore.
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.
User avatar
death.crafter
Rainmeter Sage
Posts: 1399
Joined: April 24th, 2021, 8:13 pm

Re: Merging Skins For Improved Functionality (i hope)

Post by death.crafter »

CodeCode wrote: September 15th, 2021, 3:41 pm Ok. Got rid of it.

Weirdly the ps1 is no longer writing to the inc file.

At one point I caused a wild loop, and when I ctrl-z then saved the loop stopped, and the config strings all came out good.
But ya, it isnt building anymore.
Hmm... How do you know the config strings all came out good if it isn't building anymore?
from the Realm of Death
User avatar
CodeCode
Posts: 1365
Joined: September 7th, 2020, 2:24 pm
Location: QLD, Australia

Re: Merging Skins For Improved Functionality (i hope)

Post by CodeCode »

death.crafter wrote: September 15th, 2021, 3:54 pm Hmm... How do you know the config strings all came out good if it isn't building anymore?
The target inc file did get 'built' one or twice. So the working meters were generated. Behavior has been weird, and not all together consistent.

So the target here:
$string | Out-File -FilePath "$($RmAPI.VariableStr('@'))Builder.inc" -Encoding utf8
was actually working, but for the life of me, now it doesnt.

I do not know what I changed, since when I refreshed the parsed list remained unchanged. but that alone should have rang a bell for me.

Also weird, I got a shape but it did not iterate for the whole list.

I am going t o try to revert and progress through the things I tried until builder.inc is correctly updating again. :handtohead:
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.
User avatar
death.crafter
Rainmeter Sage
Posts: 1399
Joined: April 24th, 2021, 8:13 pm

Re: Merging Skins For Improved Functionality (i hope)

Post by death.crafter »

CodeCode wrote: September 15th, 2021, 4:09 pm The target inc file did get 'built' one or twice. So the working meters were generated. Behavior has been weird, and not all together consistent.

So the target here:
$string | Out-File -FilePath "$($RmAPI.VariableStr('@'))Builder.inc" -Encoding utf8
was actually working, but for the life of me, now it doesnt.

I do not know what I changed, since when I refreshed the parsed list remained unchanged. but that alone should have rang a bell for me.

Also weird, I got a shape but it did not iterate for the whole list.

I am going t o try to revert and progress through the things I tried until builder.inc is correctly updating again. :handtohead:
May I see your current Script ? Along with the skin. Don't post a config, just the code :D
from the Realm of Death
User avatar
CodeCode
Posts: 1365
Joined: September 7th, 2020, 2:24 pm
Location: QLD, Australia

Re: Merging Skins For Improved Functionality (i hope)

Post by CodeCode »

It isnt in working order. I cannot get it to go right lol.

Somehow I did it but changed enough stuff to lose the place where that was.

ps1:

Code: Select all

function Update {
    $RmAPI.Bang('[!EnableMeasure GetConfigName][!CommandMeasure GetConfigName Update]')
    MakeConfigs
    $RmAPI.Bang("[!DisableMeasure $($RmAPI.GetMeasureName())]")
}
function MakeConfigs {
    $activeConfigsRaw=$RmAPI.MeasureStr('GetConfigName')
    # split method is used to split a string by a given delimiter. 
    # Here I used '\|' since '|' is a regex reserved character. 
    $activeConfigs=$activeConfigsRaw -split '#crlf#'
    # now that I have an array of active configs, I can use them to make my meters.
    # in this function we would iterate through the values in $activeConfigs to make the meters. 
    # $_ is a automatic variable that is the current object in the iteration. 

   $string=''
   $i=0

   $activeConfigs | ForEach-Object {
       $string+=@"
[MeterContainer$i]
Meter=Shape
MeterStyle=BGStyle
Y=10R
DynamicVariables=1
[MeterStr$i]
Meter=String
X=450
Y=25r
Text=$_
MeterStyle=Contents
Container=MeterContainer$i
DynamicVariables=1

"@
        # we increase the $i variable with each iteration
        $i++
   }
   # now that we have a complete string of measures and meters, we can make a file out of it. 
   # we will use unicode encoding, aka UTF-16
   $string | Out-File -FilePath "$($RmAPI.VariableStr('@'))Builder.inc" -Encoding utf8

}
main ini:

Code: Select all

[Rainmeter]
Update=-1
AccurateText=1
SkinHeight=350
SkinWidth=900

[Metadata]
Name=Drives
Author=death.crafter
Information=Example skin
Version=1.0.0
License=Creative Commons Attribution - Non - Commercial - Share Alike 3.0

;-------------------------------Variables---------------------------------

[Variables]
Scroll=0

;--------------------------------Script-----------------------------------

[Config_psrm]
Measure=Plugin
Plugin=PowershellRM
ScriptFile=#@#Scripts\Configs.ps1

;--------------------------------Styles-----------------------------------

[BGStyle]
Shape=Rectangle 0,0,900,50,25 | StrokeWidth 0 | Fill Color 090909

[Labels]
Text=[#CURRENTSECTION]
X=200r
Y=r
StringAlign=CenterCenter
FontFace=SF Pro Rounded
FontWeight=600
FontSize=14
AntiAlias=1
FontColor=210,170,90

[Contents]
Text=[#CURRENTSECTION]
X=200r
Y=r
StringAlign=CenterCenter
FontFace=SF Pro Rounded
FontSize=14
AntiAlias=1
FontColor=210,170,90

;------------------------------Added Content-------------------------------

[RainmeterSettings]
Measure=WebParser
URL=file://#SETTINGSPATH#Rainmeter.ini
CodePage=1200
RegExp=(?s)(.*)
UpdateDivider=5
UpdateRate=1
FinishAction=[!UpdateMeasure GetConfigName][!UpdateMeterGroup ShowIt][!Redraw]

[GetConfigName]
Measure=String
String=[RainmeterSettings]
DynamicVariables=1
RegExpSubstitute=1
Substitute="(?s).*?(\[[^\n]*?\])..Active=[^0]" : "\1", "(?s)([^\n]*]).*" : "\1", "\[(.*?)]" : "\1#CRLF#"

[ClickedConfig]
Measure=String
String=[GetConfigName]
MinValue=[GetMouseY]
DynamicVariables=1
RegExpSubstitute=1
Substitute="(?s)([^\n]*?\n){0,[ClickedConfig:MinValue]}([^\n]*?)\n.*" : "\2"

;--------------------------------Content-----------------------------------

[Background]
Meter=Shape
Shape=Rectangle 0,0,900,350 | Fill Color 0,0,0,255 | StrokeWidth 0
DynamicVariables=1
MouseScrollDownAction=[!SetVariable Scroll "(Clamp(#Scroll#-60, 350-[LastItem:Y], 0))"][!Update][!Redraw]
MouseScrollUpAction=[!SetVariable Scroll "(Clamp(#Scroll#+60, 350-[LastItem:Y],0))"][!Update][!Redraw]

[Container-2]
Meter=Shape
Y=#Scroll#
DynamicVariables=1
MeterStyle=BGStyle
[RefreshBG]
Meter=Shape
MeterStyle=BGStyle
Container=Container-2
LeftMouseUpAction=[!CommandMeasure Config_psrm "Get-Configs"]
[Refresh]
Meter=String
X=450r
Y=25r
Container=Container-2
MeterStyle=Labels

[Container-1]
Meter=Shape
MeterStyle=BGStyle
Y=10R
[DriveLabelsBG]
Meter=Shape
MeterStyle=BGStyle
Container=Container-1
[Configs]
Meter=String
X=450
Y=25r
MeterStyle=Labels
Container=Container-1
DynamicVariables=1

;---------------------------------Include------------------------------------
@include=#@#Builder.inc
;---------------------------------LastItem-----------------------------------

[LastItem]
Meter=String
Y=(-[#Scroll])R
DynamicVariables=1
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.
User avatar
death.crafter
Rainmeter Sage
Posts: 1399
Joined: April 24th, 2021, 8:13 pm

Re: Merging Skins For Improved Functionality (i hope)

Post by death.crafter »

Why don't you use substitute in RainmeterSettings itself?

And since you are not disabling it, you don't have to use enablemeasure.

In psrm, change the measure name to rainmetersettings and try again.

Tho I don't see why wouldn't it work as is.

Lemme check again
from the Realm of Death
User avatar
CodeCode
Posts: 1365
Joined: September 7th, 2020, 2:24 pm
Location: QLD, Australia

Re: Merging Skins For Improved Functionality (i hope)

Post by CodeCode »

Wow-wee-kazowie!
I think I have a working config. With tweakss needed but cosmetics mostly.
Configs.ps1:

Code: Select all

function Update {
    $RmAPI.Bang('[!EnableMeasure GetConfigName][!CommandMeasure GetConfigName Update]')
    MakeConfigs
    $RmAPI.Bang("[!DisableMeasure $($RmAPI.GetMeasureName())]")
}
function MakeConfigs {
    $activeConfigsRaw=$RmAPI.MeasureStr('GetConfigName')
    # split method is used to split a string by a given delimiter. 
    # Here I used '\|' since '|' is a regex reserved character. 
    $activeConfigs=$activeConfigsRaw -split '\|'
    # now that I have an array of active configs, I can use them to make my meters.
    # in this function we would iterate through the values in $activeConfigs to make the meters. 
    # $_ is a automatic variable that is the current object in the iteration. 

   $string=''
   $i=0

    $activeConfigs | ForEach-Object {
        $string+=@"

[Container$i]
Meter=Shape
MeterStyle=BGStyle
Y=10R
[ConfigBG$i]
Meter=Shape
MeterStyle=BGStyle
Container=Container$i
[Configs$i]
Meter=String
X=450
Y=25r
Text=$_
MeterStyle=Contents
Container=Container$i
DynamicVariables=1
"@
        $i++
    }

    $string | Out-File -FilePath "$($RmAPI.VariableStr('@'))Builder.inc" -Encoding utf8
    
}
Main INI:

Code: Select all

[Rainmeter]
Update=-1
AccurateText=1
SkinHeight=350
SkinWidth=900

[Metadata]
Name=Drives
Author=death.crafter
Information=Example skin
Version=1.0.0
License=Creative Commons Attribution - Non - Commercial - Share Alike 3.0

;-------------------------------Variables---------------------------------

[Variables]
Scroll=0

;--------------------------------Script-----------------------------------

[Config_psrm]
Measure=Plugin
Plugin=PowershellRM
ScriptFile=#@#Scripts\Configs.ps1

;--------------------------------Styles-----------------------------------

[BGStyle]
Shape=Rectangle 0,0,900,50,25 | StrokeWidth 0 | Fill Color 090909

[Labels]
Text=[#CURRENTSECTION]
X=200r
Y=r
StringAlign=CenterCenter
FontFace=SF Pro Rounded
FontWeight=600
FontSize=14
AntiAlias=1
FontColor=210,170,90

[Contents]
Text=[#CURRENTSECTION]
X=200r
Y=r
StringAlign=CenterCenter
FontFace=SF Pro Rounded
FontSize=14
AntiAlias=1
FontColor=210,170,90

;------------------------------Added Content-------------------------------

[GetRainmeterSettings]
Measure=WebParser
URL=file://#SETTINGSPATH#Rainmeter.ini
CodePage=1200
RegExp=(?s)(.*)
UpdateDivider=5
UpdateRate=1
FinishAction=[!UpdateMeasure GetConfigName][!Redraw]

[GetConfigName]
Measure=String
String=[GetRainmeterSettings]
DynamicVariables=1
RegExpSubstitute=1
Substitute="(?s).*?(\[[^\n]*?\])..Active=[^0]" : "\1", "(?s)([^\n]*]).*" : "\1", "\[(.*?)]" : "\1|"

[ClickedConfig]
Measure=String
String=[GetConfigName]
MinValue=[GetMouseY]
DynamicVariables=1
RegExpSubstitute=1
Substitute="(?s)([^\n]*?\n){0,[ClickedConfig:MinValue]}([^\n]*?)\n.*" : "\2"

;--------------------------------Content-----------------------------------

[Background]
Meter=Shape
Shape=Rectangle 0,0,900,350 | Fill Color 0,0,0,255 | StrokeWidth 0
DynamicVariables=1
MouseScrollDownAction=[!SetVariable Scroll "(Clamp(#Scroll#-60, 350-[LastItem:Y], 0))"][!Update][!Redraw]
MouseScrollUpAction=[!SetVariable Scroll "(Clamp(#Scroll#+60, 350-[LastItem:Y],0))"][!Update][!Redraw]

[Container-2]
Meter=Shape
Y=#Scroll#
DynamicVariables=1
MeterStyle=BGStyle
[RefreshBG]
Meter=Shape
MeterStyle=BGStyle
Container=Container-2
LeftMouseUpAction=[!Refresh]
[Refresh]
Meter=String
X=450r
Y=25r
Container=Container-2
MeterStyle=Labels

[Container-1]
Meter=Shape
MeterStyle=BGStyle
Y=10R

;---------------------------------Include------------------------------------
@include=#@#Builder.inc
;---------------------------------LastItem-----------------------------------

[LastItem]
Meter=String
Y=(-[#Scroll])R
DynamicVariables=1
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.