我试图在Logitech GHUB中制作一个使用Lua的自动舔舐脚本。我尝试过很多变体,但总是会出现语法错误。我以前没有编码的经验。
代码的要点是,当我按住p时,鼠标会重复单击,并在这些单击之间等待一个随机间隔。还计划在新闻发布和发布之间留出时间间隔。
EnablePrimaryMouseEvents(true)
function OnEvent(event, arg)
--OutputLogMessage("Event: "..event.." Arg: "..arg.."n")
if IsKeyPressed("P") then
repeat
PressMouseButton(1)
ReleaseMouseButton(1)
Sleep(math.random(29, 36))
PressMouseButton(1)
ReleaseMouseButton(1) ---- Syntax Error(Show up almost everywhere when I change the code)
until not IsKeyPressed("P") then
end
你想要的是不可能的
G-Hub无法确定是按下还是松开了P
键
只监视鼠标按钮(使用IsMouseButtonPressed
(
并且还监视Shift/Alt/Ctrl
密钥(使用IsModifierPressed
(
不监控常用密钥(字母、数字(。
G-Hub有一个错误:在编译时错误消息中,行号偏移了一
因此,由于关键字then
,语法错误实际上指向具有until not IsKeyPressed("P")
的行
顺便说一句,G-Hub中没有定义函数IsKeyPressed()
您可以在菜单Help -> Scripting API
中读取所有G-Hub功能的列表
以下代码是由鼠标按钮#4("返回"(而不是键P
:控制的自动舔舐器的示例
EnablePrimaryMouseButtonEvents(true)
function OnEvent(event, arg)
--OutputLogMessage("Event: "..event.." Arg: "..arg.."n")
if event == "MOUSE_BUTTON_PRESSED" and arg == 4 then
repeat
PressAndReleaseMouseButton(1)
Sleep(math.random(30, 60))
until not IsMouseButtonPressed(4)
end
end