It is currently March 28th, 2024, 6:26 pm

Filtering output from wmic RunCommand

Get help with creating, editing & fixing problems with skins
Post Reply
sunnys
Posts: 17
Joined: February 22nd, 2018, 6:31 pm

Filtering output from wmic RunCommand

Post by sunnys »

I am using RunCommand to call wmic to get back details of RAM installed on my machine.
Problem is that the output comes in a few lines and I want to create a single text line that will go into a meter that will display Manufacturer - Capacity - Bank label - Speed.
Should I build the string in lua or could it all be done through substitute on regex?
Should I have a separate measure for each field or could I do it all in one?

Code: Select all

[Rainmeter]
Update=1000
BackgroundMode=2
SolidColor=0,0,0,100
OnRefreshAction=[!CommandMeasure GetRamManufacturer "Run"][!CommandMeasure GetRamBankLabel "Run"]

[GetRamManufacturer]
Measure=Plugin
Plugin=RunCommand
Parameter=wmic MemoryChip get BankLabel, Capacity, Manufacturer, Speed
OutputFile=#CURRENTPATH#RamManufacturer.txt
OutputType=ANSI
FinishAction=[!UpdateMeter RamManufacturer][!Redraw]
DynamicVariables=1
RegExpSubstitute=1
Substitute="BankLabel.*#CRLF#":"", "#CRLF#":"", "Manufacturer (\s)":""
;"(\s)":""

[GetRamBankLabel]
Measure=Plugin
Plugin=RunCommand
Parameter=wmic MemoryChip get BankLabel
OutputFile=#CURRENTPATH#RamBankLabel.txt
OutputType=ANSI
FinishAction=[!UpdateMeter RamBankLabel][!Redraw]
DynamicVariables=1
RegExpSubstitute=1
Substitute="BankLabel.*#CRLF#":"","#CRLF#":""

[RamManufacturer]
Meter=String
MeasureName=GetRamManufacturer
FontSize=11
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
X=10
Y=0

[RamBankLabel]
Meter=String
MeasureName=GetRamBankLabel
FontSize=11
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
X=10
Y=20
User avatar
FreeRaider
Posts: 826
Joined: November 20th, 2012, 11:58 pm

Re: Filtering output from wmic RunCommand

Post by FreeRaider »

Post the original files.txt
sunnys
Posts: 17
Joined: February 22nd, 2018, 6:31 pm

Re: Filtering output from wmic RunCommand

Post by sunnys »

The output files?
User avatar
FreeRaider
Posts: 826
Joined: November 20th, 2012, 11:58 pm

Re: Filtering output from wmic RunCommand

Post by FreeRaider »

Yes.
sunnys
Posts: 17
Joined: February 22nd, 2018, 6:31 pm

Re: Filtering output from wmic RunCommand

Post by sunnys »

Here
Attachments
RamManufacturer.txt
(140 Bytes) Downloaded 129 times
RamDetails.txt
(41 Bytes) Downloaded 126 times
RamBankLabel.txt
(41 Bytes) Downloaded 124 times
User avatar
FreeRaider
Posts: 826
Joined: November 20th, 2012, 11:58 pm

Re: Filtering output from wmic RunCommand

Post by FreeRaider »

Try this code.

Code: Select all

[Rainmeter]
Update=-1
BackgroundMode=2
SolidColor=0,0,0,100
OnRefreshAction=[!CommandMeasure GetRamInfo "Run"]

[GetRamInfo]
Measure=Plugin
Plugin=RunCommand
Parameter=wmic MemoryChip get BankLabel, Capacity, Manufacturer, Speed
OutputFile=#CURRENTPATH#RamManufacturer.txt
OutputType=ANSI
FinishAction=[!UpdateMeter RamInfo][!Redraw]
DynamicVariables=1
RegExpSubstitute=1
; Manufacturer - Capacity - Bank label - Speed
Substitute="(?siU)^.*\n(.*)\s{2,}+(.*)\s{2,}+(.*)\s{2,}+(.*)\s+\n(.*)\s{2,}+(.*)\s{2,}+(.*)\s{2,}+(.*)\s{2,}+":"\3 \2 \1 \4 - \7 \6 \5 \8"

[RamInfo]
Meter=String
MeasureName=GetRamInfo
FontSize=11
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
X=10
Y=0

Post Scriptum: I have changed the name of the measure and the name of the meter.
sunnys
Posts: 17
Joined: February 22nd, 2018, 6:31 pm

Re: Filtering output from wmic RunCommand

Post by sunnys »

Thanks!!

I'll try to understand the regex pattern :)
User avatar
FreeRaider
Posts: 826
Joined: November 20th, 2012, 11:58 pm

Re: Filtering output from wmic RunCommand

Post by FreeRaider »

You are welcome.
Post Reply