WMI stands for Windows Management Instrumentation.It provides a common interface to access almost any information of the operation system.Currently I haven't seen a WMI measure for Rainmeter.Version 1.4 introduces the Lua Script Measure,I try to implement a measure using lua with the module LuaCom which allows you to access the com object in the scripts.
My example would be a harddisk temperature measure.
a
package.cpath="d:\\Program Files\\Rainmeter\\clibs\\?.dll;d:\\Program Files\\Rainmeter\\clibs\\loadall.dll"
require("luacom")
PROPERTIES =
{
DiskId = 0;
}
function Initialize()
temp=0
WMI = luacom.GetObject ("winmgmts:{impersonationLevel=Impersonate}!\\\\" ..".".. "\\root\\wmi")
end
function Update()
local items = WMI:ExecQuery("SELECT * FROM MSStorageDriver_ATAPISmartData", "WQL",0x10+0x20)
local vs
for index,item in luacomE.pairs (items) do
if index==tonumber(PROPERTIES.DiskId)+1 then
vs=item:VendorSpecific()
for i,j in pairs (vs) do
if j==194 then
if vs[i+5] == 0 then
else
temp = vs[i+5]
end
end
end
end
end
items=nil
collectgarbage()
end -- function Update
function GetStringValue()
return tonumber(temp)
end -- function GetStringValue
Unfortunately,the memory usage keep increasing after each update.As I am not a real programmer,I have no idea how this happen.I post here to see if anyone interest in.
As of this writing, you cannot call external .dll load libraries with Lua in Rainmeter. I suspect that since you are loading the dll outside of the normal integration with Lua and Rainmeter, it is being loaded again and again on each "update" of the skin when the Lua is executed.
Just out of curiosity, aside from the memory creep, did that even work? Did it return a temperature to the skin?
We are looking at improving this capability, but are struggling a bit with some 32bit vs 64bit issues. Stay tuned.
You might try moving the load of the libray into "Initialize" which is only executed once when the skin is loaded, and see if a) it still works, and b) it helps with the memory creep.
Another option, although ugly, is to use !RainmeterWriteKeyValue to actually change a variable in the skin and a !RainmeterRefresh ConfigName at the end of "Update" to reload the skin. That way the Lua will be fully killed and restarted. Really ugly though.