You really can't read Rainmeter.ini from Lua. Lua will only read ANSI / UTF-8 encoded files, and Rainmeter.ini is
always encoded as UTF-16.
https://docs.rainmeter.net/tips/unicode-in-rainmeter/
Use WebParser, with
CodePage=1200 on the parent, to read the entire Rainmeter.ini file into a single StringIndex. Then you can use LUA to parse the value of the WebParser measure as you like, in effect treating that as a file.
Code: Select all
[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
[Variables]
[MeasureReadIni]
Measure=WebParser
URL=file://#SETTINGSPATH#Rainmeter.ini
CodePage=1200
RegExp=(?siU)^(.*)$
StringIndex=1
FinishAction=[!EnableMeasure Lua]
[Lua]
Measure=Script
ScriptFile=Test.lua
Disabled=1
UpdateDivider=-1
[MeterDummy]
Meter=String
Code: Select all
function Initialize()
measureReadingIni = SKIN:GetMeasure('MeasureReadIni')
end
function Update()
entireIni = measureReadingIni:GetStringValue()
print(entireIni)
end
Note that you also should not "write" to Rainmeter.ini with Lua. If you want to write to Rainmeter.ini, you want to send !WriteKeyValue bangs to the skin and have the skin write to the file. If you write to Rainmeter.ini with Lua, you will likely destroy it. The only safe way to write to Rainmeter.ini with Lua is to write the
entire contents as a new file, being careful to preface the file with the BOM characters
ÿþ for UTF-16 LE.
I would also note that none of this is needed to get the current X and Y position of the actual skin the Lua is running in. That can be done by simply using the #CURRENTCONFIGX# and #CURRENTCONFIGY# built-in variables. You would only need this if you wanted to find the position of some other skin. Also, be aware that just because a config is in Rainmeter.ini, and has a WindowX / WindowY setting, doesn't mean it is actually loaded and running. To be sure of that, you need to look for Active=x in the [Section], where "x" is some number other than 0.
Final note: I really hate this for trying in some fashion to have one skin "follow" some other skin based on its real-time position. This is going to end up as a horrid Rube Goldberg, and will at best have all kinds of "lag" and/or use a ton of CPU. I don't know exactly what you are going for here, but I already sorta hate it...
There is no efficient or satisfactory way to have one skin "follow" another skin around on the screen. Period.