Logitech G Hub LUA脚本根据上次状态切换
刚买了一个新的罗技鼠标,我想做一个脚本来在状态之间切换。基本上是通过鼠标键循环输出内容。我以前从未制作过lua脚本,因此希望能得到一些帮助。基本上,我希望发生的一个例子是Logitech G Hub LUA脚本根据上次状态切换,lua,autohotkey,logitech,logitech-gaming-software,Lua,Autohotkey,Logitech,Logitech Gaming Software,刚买了一个新的罗技鼠标,我想做一个脚本来在状态之间切换。基本上是通过鼠标键循环输出内容。我以前从未制作过lua脚本,因此希望能得到一些帮助。基本上,我希望发生的一个例子是 #set default state state = F9; if (state == f9) when mouse4 is pressed send f10 state = f10; if (state == f10) when mouse4 is pressed s
#set default state
state = F9;
if (state == f9)
when mouse4 is pressed send f10
state = f10;
if (state == f10)
when mouse4 is pressed send f9
state = f9;
我希望这是有道理的。如果有一种方法可以用Logitech G Hub lua脚本实现这一点,如果有人能告诉我脚本应该是什么样子,那将是一件令人惊讶的事情。我想,无论是自动热键还是自动热键都可能做到这一点
编辑:
谢谢Egor,好的,所以我准备了一个版本,可以用两个按钮工作,或者应该用两个按钮工作。我想做的是按下鼠标11,它会根据上次返回的内容在返回f7或f8之间切换。我添加了另一个按钮,鼠标10,然后根据上次按下的按钮在f7和f9之间切换。然而,由于某些原因,鼠标11的部分不会在两者之间切换,只返回f9
本地电流状态m4=f7
本地下一个_状态_m4={f8=f7,f7=f8}
本地电流状态m5=f9
本地下一个\u状态\u m5={f9=f7,f7=f9}
函数OnEventevent,arg
如果事件==按下鼠标按钮且参数==11,则
按KeyCurrent\u state\u m4
睡30
释放键当前状态m4
当前状态=下一个状态[当前状态]
elseif event==按下鼠标按钮,arg==10,然后
按KeyCurrent_state_m5
睡30
ReleaseKeycurrent_state_m5
当前_状态_m4=下一个_状态_m5[当前_状态_m5]
终止
终止
你打错了。
local current_state = "f9"
local next_state = {f10 = "f9", f9 = "f10"}
function OnEvent(event, arg)
if event == "MOUSE_BUTTON_PRESSED" and arg == 4 then
current_state = next_state[current_state]
PressKey(current_state)
Sleep(30)
ReleaseKey(current_state)
end
end