【04-14 技术交流】简易Lua实现:监控皮肤中求最大值的问题解决
rainmeter吧
全部回复
仅看楼主
level 3
换机后重写雨滴。
以前用的8核cpu可以简单的把所有核心的情况罗列到桌面,但换机后面对20个核心,盯都盯不过来。
那就把最高温的核心温度放监控上吧,于是产生了新需求:核心温度的最大值,核心电压的最大值等等。
然后一读手册,rainmeter居然没有直接求最大值的函数~!~!
2025年04月14日 15点04分 1
level 3
幸好我们有万能的lua。于是就写了个脚本。
懒得写教程了,直接贴代码。请读注释[滑稽]
2025年04月14日 15点04分 2
level 3
文件名:test1.ini
[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
[Metadata]
Name=TemperatureMonitor
Author=fantaskiss
;---------- Styles ----------
[TextStyle]
FontFace=Segoe UI
FontSize=10
FontColor=0,0,0,255
AntiAlias=1
SolidColor=0,0,0,1
[BarStyle]
W=100
H=4
Y=2r
;---------- Background ----------
[Background]
Meter=Shape
Shape=Rectangle 0,0,220,120,10 | Fill Color 240,240,240,180 | StrokeWidth 0
X=0
Y=0
;----------CPUpkg CPU封装温度参数 Measures ----------
[MeasureCPUPKG]
Measure=Plugin
Plugin=SIV
SivKey=H-T1
SivSensor=T
MinValue=20
MaxValue=100
;---------- CPUpkg Section ----------
[CPUpkgLabel]
Meter=String
MeterStyle=TextStyle
Text=CPUPKG
X=10
Y=10
[CPUpkgValue]
Meter=String
MeterStyle=TextStyle
MeasureName=MeasureCPUPKG
Text=%1 ℃
X=75
Y=10
NumOfDecimals=0
;---------- CPUpkg bar ----------
[CPUpkgBarBack]
Meter=Shape
Shape=Rectangle 0,0,100,4,2 | Fill Color 200,200,200,255 | StrokeWidth 0
X=112
Y=17
[CPUpkgbar]
Meter=Shape
MeasureName=MeasureCPUPKG
Shape=Rectangle 0,0,([MeasureCPUPKG:%]),4,2 | Fill Color
#CPUpkgColor#
| StrokeWidth 0
X=112
Y=17
DynamicVariables=1
;---------- CPUpkgColor Calculations ----------
[CPUpkgColorCalc]
Measure=Calc
Formula=MeasureCPUPKG
IfCondition=(MeasureCPUPKG < 60)
IfTrueAction=[!SetVariable CPUpkgColor "255,255,255,255"]
IfCondition2=(MeasureCPUPKG >= 60) && (MeasureCPUPKG < 80)
IfTrueAction2=[!SetVariable CPUpkgColor "255,200,100,255"]
IfCondition3=(MeasureCPUPKG >= 80)
IfTrueAction3=[!SetVariable CPUpkgColor "255,100,100,255"]
DynamicVariables=1
;----------MBPCH 主板PCH温度 Measures ----------
[MeasureMBPCH]
Measure=Plugin
Plugin=SIV
SivKey=P-T0
SivSensor=T
MinValue=20
MaxValue=100
;---------- MBPCH Section ----------
[CPULabel]
Meter=String
MeterStyle=TextStyle
Text=MBPCH
X=10
Y=31
[CPUValue]
Meter=String
MeterStyle=TextStyle
MeasureName=MeasureMBPCH
Text=%1 ℃
X=75
Y=31
NumOfDecimals=0
;---------- MBPCH bar ----------
[CPUBarBack]
Meter=Shape
Shape=Rectangle 0,0,100,4,2 | Fill Color 200,200,200,255 | StrokeWidth 0
X=112
Y=38
[CPUBar]
Meter=Shape
MeasureName=MeasureMBPCH
Shape=Rectangle 0,0,([MeasureMBPCH:%]),4,2 | Fill Color
#MBPCHColor#
| StrokeWidth 0
X=112
Y=38
DynamicVariables=1
;---------- MBPCHColor Calculations ----------
[CPUColorCalc]
Measure=Calc
Formula=MeasureMBPCH
IfCondition=(MeasureMBPCH < 60)
IfTrueAction=[!SetVariable MBPCHColor "255,255,255,255"]
IfCondition2=(MeasureMBPCH >= 60) && (MeasureMBPCH < 80)
IfTrueAction2=[!SetVariable MBPCHColor "255,200,100,255"]
IfCondition3=(MeasureMBPCH >= 80)
IfTrueAction3=[!SetVariable MBPCHColor "255,100,100,255"]
DynamicVariables=1
;----------COREmax 核心最高温度 注意调用lua内容以及lua脚本的内容 ------------------
; ---------作者机器为20核心。注意变量数字以及命名的规则 ---------------------
;------------具体核心数值调用部分 ------------------------------
[MeasureCORE0]
Measure=Plugin
Plugin=SIV
SivKey=CPU-0-T
SivSensor=T
[MeasureCORE1]
Measure=Plugin
Plugin=SIV
SivKey=CPU-1-T
SivSensor=T
[MeasureCORE2]
Measure=Plugin
Plugin=SIV
SivKey=CPU-2-T
SivSensor=T
[MeasureCORE3]
Measure=Plugin
Plugin=SIV
SivKey=CPU-3-T
SivSensor=T
[MeasureCORE4]
Measure=Plugin
Plugin=SIV
SivKey=CPU-4-T
SivSensor=T
[MeasureCORE5]
Measure=Plugin
Plugin=SIV
SivKey=CPU-5-T
SivSensor=T
[MeasureCORE6]
Measure=Plugin
Plugin=SIV
SivKey=CPU-6-T
SivSensor=T
[MeasureCORE7]
Measure=Plugin
Plugin=SIV
SivKey=CPU-7-T
SivSensor=T
[MeasureCORE8]
Measure=Plugin
Plugin=SIV
SivKey=CPU-8-T
SivSensor=T
[MeasureCORE9]
Measure=Plugin
Plugin=SIV
SivKey=CPU-9-T
SivSensor=T
[MeasureCORE10]
Measure=Plugin
Plugin=SIV
SivKey=CPU-10-T
SivSensor=T
[MeasureCORE11]
Measure=Plugin
Plugin=SIV
SivKey=CPU-11-T
SivSensor=T
[MeasureCORE12]
Measure=Plugin
Plugin=SIV
SivKey=CPU-12-T
SivSensor=T
[MeasureCORE13]
Measure=Plugin
Plugin=SIV
SivKey=CPU-13-T
SivSensor=T
[MeasureCORE14]
Measure=Plugin
Plugin=SIV
SivKey=CPU-14-T
SivSensor=T
[MeasureCORE15]
Measure=Plugin
Plugin=SIV
SivKey=CPU-15-T
SivSensor=T
[MeasureCORE16]
Measure=Plugin
Plugin=SIV
SivKey=CPU-16-T
SivSensor=T
[MeasureCORE17]
Measure=Plugin
Plugin=SIV
SivKey=CPU-17-T
SivSensor=T
[MeasureCORE18]
Measure=Plugin
Plugin=SIV
SivKey=CPU-18-T
SivSensor=T
[MeasureCORE19]
Measure=Plugin
Plugin=SIV
SivKey=CPU-19-T
SivSensor=T
;------------具体核心数值调用部分结束 ------------------------------
;-------------- 使用lua计算以及生成Measure部分 maxtemp.lua要与ini放在同一目录下--------------------
[MeasureCOREMax]
Measure=Script
ScriptFile=MaxTemp.lua
UpdateDivider=1
MinValue=20
MaxValue=100
;-------------- 使用lua计算以及生成Measure部分结束 --------------------
;---------- COREmax Section ----------
[COREmaxLabel]
Meter=String
MeterStyle=TextStyle
Text=CORmax
X=10
Y=51
[COREmaxValue]
Meter=String
MeterStyle=TextStyle
MeasureName=MeasureCOREmax
Text=%1 ℃
X=75
Y=51
NumOfDecimals=0
;---------- COREmax bar ----------
[COREmaxBarBack]
Meter=Shape
Shape=Rectangle 0,0,100,4,2 | Fill Color 200,200,200,255 | StrokeWidth 0
X=112
Y=59
[COREmaxBar]
Meter=Shape
MeasureName=MeasureCOREmax
Shape=Rectangle 0,0,([MeasureCOREmax:%]),4,2 | Fill Color
#COREmaxColor#
| StrokeWidth 0
X=112
Y=59
DynamicVariables=1
;---------- COREmaxColor Calculations ----------
[COREmaxColorCalc]
Measure=Calc
Formula=MeasureCOREmax
IfCondition=(MeasureCOREmax < 60)
IfTrueAction=[!SetVariable COREmaxColor "255,255,255,255"]
IfCondition2=(MeasureCOREmax >= 60) && (MeasureCOREmax < 80)
IfTrueAction2=[!SetVariable COREmaxColor "255,200,100,255"]
IfCondition3=(MeasureCOREmax >= 80)
IfTrueAction3=[!SetVariable COREmaxColor "255,100,100,255"]
DynamicVariables=1
;----------IGT 集显核心温度参数 Measures ----------
[MeasureIGT]
Measure=Plugin
Plugin=SIV
SivKey=GPU-1-T
SivSensor=T
MinValue=20
MaxValue=100
;---------- IGTcore Section ----------
[IGTLabel]
Meter=String
MeterStyle=TextStyle
Text=IGTCORE
X=10
Y=73
[IGTValue]
Meter=String
MeterStyle=TextStyle
MeasureName=MeasureIGT
Text=%1 ℃
X=75
Y=73
NumOfDecimals=0
;---------- IGTcore bar ----------
[IGTBarBack]
Meter=Shape
Shape=Rectangle 0,0,100,4,2 | Fill Color 200,200,200,255 | StrokeWidth 0
X=112
Y=80
[IGTBar]
Meter=Shape
MeasureName=MeasureIGT
Shape=Rectangle 0,0,([MeasureIGT:%]),4,2 | Fill Color
#IGTColor#
| StrokeWidth 0
X=112
Y=80
DynamicVariables=1
;---------- GPU Color Calculations ----------
[IGTColorCalc]
Measure=Calc
Formula=MeasureIGT
IfCondition=(MeasureIGT < 50)
IfTrueAction=[!SetVariable IGTColor "255,255,255,255"]
IfCondition2=(MeasureIGT >= 60) && (MeasureIGT < 80)
IfTrueAction2=[!SetVariable IGTColor "255,200,100,255"]
IfCondition3=(MeasureIGT >= 80)
IfTrueAction3=[!SetVariable IGTColor "255,100,100,255"]
DynamicVariables=1
;----------GPUcore 独显核心温度参数 Measures ----------
[MeasureGPU]
Measure=Plugin
Plugin=SIV
SivKey=GPU-0-T-0
SivSensor=T
MinValue=20
MaxValue=100
;---------- GPUcore Section ----------
[GPULabel]
Meter=String
MeterStyle=TextStyle
Text=GPUCOR
X=10
Y=94
[GPUValue]
Meter=String
MeterStyle=TextStyle
MeasureName=MeasureGPU
Text=%1 ℃
X=75
Y=94
NumOfDecimals=0
[GPUBarBack]
Meter=Shape
Shape=Rectangle 0,0,100,4,2 | Fill Color 200,200,200,255 | StrokeWidth 0
X=112
Y=101
[GPUBar]
Meter=Shape
MeasureName=MeasureGPU
Shape=Rectangle 0,0,([MeasureGPU:%]),4,2 | Fill Color
#GPUColor#
| StrokeWidth 0
X=112
Y=101
DynamicVariables=1
;---------- GPU Color Calculations ----------
[GPUColorCalc]
Measure=Calc
Formula=MeasureGPU
IfCondition=(MeasureGPU < 50)
IfTrueAction=[!SetVariable GPUColor "255,255,255,255"]
IfCondition2=(MeasureGPU >= 60) && (MeasureGPU < 80)
IfTrueAction2=[!SetVariable GPUColor "255,200,100,255"]
IfCondition3=(MeasureGPU >= 80)
IfTrueAction3=[!SetVariable GPUColor "255,100,100,255"]
DynamicVariables=1
2025年04月14日 15点04分 3
level 3
文件名:MaxTemp.lua
function Update()
local max = 0
for i = 0, 19 do
local temp = SKIN:GetMeasure('MeasureCore'..i):GetValue()
max = math.max(max, temp)
end
return max
end
2025年04月14日 15点04分 4
level 3
调用lua以及lua的内容都在核心最高温度那一块,其他的都是附带的。
获取温度值用的插件是SIV。
其实本来想把获取温度的内容用循环写在lua里的,但写着发现总是有参数传递的错误。对雨滴的规则了解的不透彻导致的。足以说明我是个半桶水。
所以如果有大佬看到了,然后无聊,指点两句或者帮忙修改,本人先谢过了。
最后,感谢伟大的人工智能~![滑稽][滑稽]
2025年04月14日 15点04分 5
吧务
level 14
Rainmeter有Max(x,y)函数可以用,不妨试试这个(虽然不够优雅):
Max(Max(Max(Max(Max(x0,x1),Max(x2,x3)),Max(Max(x4,x5),Max(x6,x7))),Max(Max(Max(x8,x9),Max(x10,x11)),Max(Max(x12,x13),Max(x14,x15)))),Max(Max(x16,x17),Max(x18,x19)))
2025年04月15日 03点04分 7
[汗][汗][不高兴]我翻手册竟然没看到~!
2025年04月15日 04点04分
多谢~!
2025年04月15日 04点04分
1