Rainmeter Lua脚本通过MouseOver事件

问题描述 投票:0回答:1

我有一个Lua脚本,我试图用Rainmeter运行。目前脚本运行,我可以看到我的.txt文件的一行“Notes”获得一个Caesar Cipher应用于它,然后Update()函数将更改ScriptMeter Text字段以匹配输出密码。

我似乎无法找到的是如何使用Rainmeter在MouseOver事件上调用此脚本。我的计划是在鼠标悬停在鼠标悬停事件上的循环中应用密码,并在删除鼠标时将密码撤消到难以辨认的文本。

MyLua.ini

[ScriptMeasure]
Measure=Script
ScriptFile="#@#Scripts\MyLua.lua"

[StringStyle]
 FontFace=Trebuchet MS
 FontColor=255,245,207,255
 SolidColor=0,0,0,1
 StringStyle=Bold
 StringAlign=Center
 AntiAlias=1
 FontSize=20

[ScriptMeter]
Meter=String
MeterStyle=StringStyle
MeasureName=ScriptMeasure
Text=""
x=100
y=40

MyLua.lua

function Initialize()
    FilePath = SKIN:ReplaceVariables("#@#Scripts/MyLua.txt")
    f = io.open(FilePath) --open the file, ovewrites the file each time
    str = f:read('*l') --read line
    f:close()
    --number = string.match(str, 1) --use a pattern search to find the first number in the file
    print(str) --test code


    encrypted = caesar.encrypt(str, 7)
    decrypted = caesar.decrypt(encrypted, 7)
    print("Original text:  ", str)
    print("Encrypted text: ", encrypted)
    print("Decrypted text: ", decrypted)
    output = encrypted


end --funciton Initialize

function Update()

    print(output)
    SKIN:Bang('!SetOption', 'ScriptMeter', 'Text', output)
    --return(output) --return the string

end

function encrypt(text, key)
    return text:gsub("%a", function(t)
            local base = (t:lower() == t and string.byte('a') or string.byte('A'))

            local r = t:byte() - base
            r = r + key
            r = r%26 -- works correctly even if r is negative
            r = r + base
            return string.char(r)
        end)
end

local function decrypt(text, key)
    return encrypt(text, -key)
end

caesar = {
    encrypt = encrypt,
    decrypt = decrypt,
}

MyLua.txt

Notes
lua mouseover rainmeter
1个回答
0
投票

一个名为/ u / GlobTwo的Reddit成员帮我解决了这个问题,所以我想我也会在这里发布他的回复。

MouseOverAction=[!CommandMeasure "ScriptMeasure" "encrypt('sometext', '1')"]
© www.soinside.com 2019 - 2024. All rights reserved.