刚刚得到了一个新的罗技鼠标,我想做一个脚本,在状态之间切换。本质上是让鼠标按键循环它输出的内容。我从来没有做过一个lua脚本,所以一些帮助将不胜感激。基本上,我想要发生的一个例子是
#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;
我希望这是有意义的。如果有一种方法可以做到这一点与罗技G集线器lua脚本,这将是惊人的,如果有人可以告诉我应该是什么样子的脚本。或者甚至是自动热键都可以做到这一点,我想。
编辑:谢谢埃戈尔,好的,我用两个按钮组装了一个可以工作(或者应该可以工作)的版本。我正在尝试完成的是你按下鼠标11,它会根据它最后返回的内容在返回f7或f8之间切换。我添加了另一个按钮,鼠标10,它应该根据最后按下的内容在f7和f9之间切换。但是,由于某些原因,鼠标11的部分不能在两者之间切换,只返回f9
local current_state_m4 = "f7"
local next_state_m4 = {f8 = "f7", f7 = "f8"}
local current_state_m5 = "f9"
local next_state_m5 = {f9 = "f7", f7 = "f9"}
function OnEvent(event, arg)
if event == "MOUSE_BUTTON_PRESSED" and arg == 11 then
PressKey(current_state_m4)
Sleep(30)
ReleaseKey(current_state_m4)
current_state_m4 = next_state_m4[current_state_m4]
elseif event == "MOUSE_BUTTON_PRESSED" and arg == 10 then
PressKey(current_state_m5)
Sleep(30)
ReleaseKey(current_state_m5)
current_state_m4 = next_state_m5[current_state_m5]
end
end
发布于 2020-04-13 18:55:24
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
https://stackoverflow.com/questions/61181469
复制相似问题