Page 1 of 1

Filtering output from wmic RunCommand

Posted: July 22nd, 2018, 1:23 pm
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

Re: Filtering output from wmic RunCommand

Posted: July 22nd, 2018, 1:32 pm
by FreeRaider
Post the original files.txt

Re: Filtering output from wmic RunCommand

Posted: July 22nd, 2018, 2:59 pm
by sunnys
The output files?

Re: Filtering output from wmic RunCommand

Posted: July 22nd, 2018, 3:09 pm
by FreeRaider
Yes.

Re: Filtering output from wmic RunCommand

Posted: July 22nd, 2018, 3:13 pm
by sunnys
Here

Re: Filtering output from wmic RunCommand

Posted: July 22nd, 2018, 11:18 pm
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.

Re: Filtering output from wmic RunCommand

Posted: July 24th, 2018, 6:22 pm
by sunnys
Thanks!!

I'll try to understand the regex pattern :)

Re: Filtering output from wmic RunCommand

Posted: July 24th, 2018, 6:56 pm
by FreeRaider
You are welcome.