【发布时间】:2021-08-13 00:55:39
【问题描述】:
我写了一个简单的 Lua 脚本,在我单击鼠标后左键单击 5。问题是,在第 12 行,如果我包含“不”,它只会重复一次,如果我删除它,它将永远重复。如果可能的话,我想用 mouse5 开始和结束脚本。我知道人们以前也遇到过类似的问题,但我无法找到解决方案。有什么想法吗?
我正在使用罗技 G Hub API: (https://douile.github.io/logitech-toggle-keys/APIDocs.pdf)
这对于我的循环: (https://www.tutorialspoint.com/lua/lua_repeat_until_loop.htm)
我的代码:
function OnEvent(event, arg)
OutputLogMessage("Event: "..event.." Arg: "..arg.."\n")
EnablePrimaryMouseButtonEvents(true)
function OnEvent(event, arg)
if event == "MOUSE_BUTTON_PRESSED" and arg == 5 then
repeat
Sleep(math.random(1046, 1292))
PressMouseButton(1)
Sleep(math.random(27, 78))
ReleaseMouseButton(1)
Sleep(math.random(314, 664))
until not IsMouseButtonPressed(5)
end
end
end
【问题讨论】:
-
您的代码应该可以正常工作。请注意 G5 鼠标键必须绑定到 GHUB 界面中的“前进”动作。这是默认设置,您可能已经手动更改了。
标签: lua logitech logitech-gaming-software