It is currently October 15th, 2019, 9:50 am

Measure Registry Multi-String?

Help with creating, editing & fixing problems with skins
Yincognito
Posts: 657
Joined: February 27th, 2015, 2:38 pm

Re: Measure Registry Multi-String?

Yincognito » March 23rd, 2019, 2:53 pm

jsmorley wrote:
March 23rd, 2019, 2:46 pm
It's just not trivial to do. NULL is used by the C language to indicate the end of a string, and we would have to deal with that. binary values are another issue, as what do we return, the raw binary number, the number converted to HEX / Decimal. All, in all, a fair amount of thought and care would need to be put into this.
Now that explains it better. Since you put it that way, I'd have to at least partially agree.
Yincognito
Posts: 657
Joined: February 27th, 2015, 2:38 pm

Re: Measure Registry Multi-String?

Yincognito » March 23rd, 2019, 3:30 pm

StArL0rd84 wrote:
March 23rd, 2019, 2:26 pm
The measure only returns the first line, as if the substitute was not even there:
D:\Images\Vintage

'D:\Images\Futurism' is still missing...
I've already tested \0 substitutions on REG_MULTI_SZ values, and it does not work. Rainmeter gets the string only up until the NUL character, meaning that whatever substitution you try to do, it will only act on the first line of text from a REG_MULTI_SZ value.

Try using the CMD+reg query combo, like this (adapt it to your needs):

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[MeasureRun]
Measure=Plugin
Plugin=RunCommand
Parameter=reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v "PagingFiles"
State=Hide
OutputType=ANSI
RegExpSubstitute=1
Substitute="\r?\n":"","(?si)^.*REG_MULTI_SZ\s+":""

[MeterRun]
Meter=String
FontSize=11
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Text=Click to Run
LeftMouseUpAction=[!CommandMeasure MeasureRun "Run"]

[MeterResult]
Meter=String
MeasureName=MeasureRun
Y=10R
FontSize=14
FontColor=255,255,255,255
AntiAlias=1
This is getting a REG_MULTI_SZ value and then eliminates the unneeded parts from the string, leaving only its value.
Last edited by Yincognito on March 23rd, 2019, 3:39 pm, edited 1 time in total.
User avatar
jsmorley
Developer
Posts: 19544
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Measure Registry Multi-String?

jsmorley » March 23rd, 2019, 3:41 pm

Your conclusion is right. The Registry measure is going to read up to the first NULL character, which means "end of string", and will be done with it. The answer is going to be RunCommand and either a cmd or Powershell command to get the desired information.
Yincognito
Posts: 657
Joined: February 27th, 2015, 2:38 pm

Re: Measure Registry Multi-String?

Yincognito » March 23rd, 2019, 4:12 pm

And a PowerShell equivalent (as always, adapt it to your needs):

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[MeasureRun]
Measure=Plugin
Plugin=RunCommand
Program=powershell
Parameter=-command Get-ItemProperty -Path \"HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management\" | Select-Object -ExpandProperty \"PagingFiles\"
State=Hide
OutputType=ANSI
RegExpSubstitute=1
Substitute="\r?\n":""

[MeterRun]
Meter=String
FontSize=11
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Text=Click to Run
LeftMouseUpAction=[!CommandMeasure MeasureRun "Run"]

[MeterResult]
Meter=String
MeasureName=MeasureRun
Y=10R
FontSize=14
FontColor=255,255,255,255
AntiAlias=1
The difference (and the reason it didn't work before) is that -command is needed before the actual command, and, of course, the command interpreter (which is still CMD) needs the quotes (") to be escaped by using \ before them.
User avatar
balala
Rainmeter Sage
Posts: 8809
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Measure Registry Multi-String?

balala » March 23rd, 2019, 4:36 pm

StArL0rd84 wrote:
March 23rd, 2019, 2:26 pm
The measure only returns the first line, as if the substitute was not even there:
D:\Images\Vintage

'D:\Images\Futurism' is still missing...
And what if you don't add a Substitute option?
User avatar
SilverAzide
Posts: 590
Joined: March 23rd, 2015, 5:26 pm

Re: Measure Registry Multi-String?

SilverAzide » March 23rd, 2019, 4:54 pm

StArL0rd84 wrote:
March 23rd, 2019, 7:41 am
Tested Substitute="\0":"|" today and i'm afraid it does not work either.
Still only returns the first string.

I have never used Powershell together with Rainmeter before.
How do i format the measure?
The following measure only returns the number 103...
Yincognito's code is what you want. I only gave you the Powershell command line. Try this:

Code: Select all

[mMultiString]
Measure=Plugin
Plugin=RunCommand
Program=Powershell
Parameter=-Command "Get-ItemProperty -Path 'HKCU:\Software\Binary Fortress Software\DisplayFusion\Wallpaper\c01c88eb-b1af-446a-ba4c-d714a2c45fdd' | Select-Object -ExpandProperty Wallpaper_0_RotatePaths"
State=Hide
OutputType=ANSI
You will get the list of strings separated by CRLF, so you can replace these with something else using a Substitute if you want.
Last edited by SilverAzide on March 24th, 2019, 2:37 pm, edited 1 time in total.
DeviantArt Gadgets More...
User avatar
StArL0rd84
Posts: 336
Joined: February 8th, 2015, 10:07 pm
Location: EU, Denmark.

Re: Measure Registry Multi-String?

StArL0rd84 » March 23rd, 2019, 7:07 pm

balala wrote:
March 23rd, 2019, 4:36 pm
And what if you don't add a Substitute option?
Same deal
(#WorkTime# = 1 ? #Work# : ([mEnergyLoss:%] > 100 ? #SleepMode# : #Rainmeter#))
Yincognito
Posts: 657
Joined: February 27th, 2015, 2:38 pm

Re: Measure Registry Multi-String?

Yincognito » March 23rd, 2019, 10:38 pm

jsmorley wrote:
March 23rd, 2019, 3:41 pm
Your conclusion is right. The Registry measure is going to read up to the first NULL character, which means "end of string", and will be done with it. The answer is going to be RunCommand and either a cmd or Powershell command to get the desired information.
A little off-topic, but I discovered that the \0 badly needed to be escaped in my feeds skin as well, since when browsing these posts from Rainmeter's feed, it totally messed up the strings I was working with and the way things were displayed. I'm not yet sure if \0 was interpreted as the whole string or the end of the string, but once I escaped it, it all came back to normal.
User avatar
balala
Rainmeter Sage
Posts: 8809
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Measure Registry Multi-String?

balala » March 24th, 2019, 12:38 pm

StArL0rd84 wrote:
March 23rd, 2019, 7:07 pm
Same deal
I'm not too sure, but check Yincognito's above reply.
Yincognito
Posts: 657
Joined: February 27th, 2015, 2:38 pm

Re: Measure Registry Multi-String?

Yincognito » March 24th, 2019, 2:33 pm

SilverAzide wrote:
March 23rd, 2019, 4:54 pm
Note the UpdateDivider line, you probably don't need this running once a second, so it is best to do this one time and be done with it.
Just as a clarification, as far as I know, I don't think setting UpdateDivider=-1 in that measure you posted will make any difference, since according to the manual, the plugin will take no action unless triggered with a [!CommandMeasure TheRunCommandMeasureName "Run"] bang. Instead, what you'd want is to set UpdateDivider=-1 on the measure where the bang that triggers the RunCommand measure is, not on the actual RunCommand measure.

Of course, if the bang is executed within a mouse action, there will be no need for UpdateDivider=-1, since only that mouse action will trigger the running of the actual RunCommand measure.

A little convoluted system, I know - but from a logical point of view, it makes sense if you think about it.