早上好,
我目前在Logitech中录制了一个宏("Loop"),它执行以下操作:
120延迟,键1,90延迟,左击,150延迟,键2,90延迟,左击,140延迟
它被设置为切换。然后,我使用以下脚本:
local flag
function OnEvent(event, arg)
if event == "MOUSE_BUTTON_PRESSED" and arg == 20 then
PlayMacro("Loop")
end
if event == "MOUSE_BUTTON_RELEASED" and arg == 20 then
AbortMacro()
end
end
然而,这工作得很好。:D很明显,每次重复单击左键后的所有延迟都是相同的。我希望它们在120到160之间是随机的。遗憾的是,我是一个无可救药的LUA新手,所以我做了一些谷歌搜索,试图离开宏,并将其全部放入lua脚本中,但我做错了什么,因为它所做的一切就是不停的按下1:
local flag
function OnEvent(event, arg)
if event == "MOUSE_BUTTON_PRESSED" and arg == 20 then
Sleep(math.random(120, 160))
PressKey("1")
Releasekey("1")
Sleep(90)
PressMouseButton(1)
ReleaseMouseButton(1)
Sleep(math.random(120, 160))
PressKey("2")
Releasekey("2")
Sleep(90)
PressMouseButton(1)
ReleaseMouseButton(1)
end
if event == "MOUSE_BUTTON_RELEASED" and arg == 20 then
return
end
end
我遗漏了什么?
感谢您的帮助!
发布于 2021-09-18 21:29:18
步骤1.
你在游戏中使用鼠标按键4 ("Back")吗?
步骤2.
您必须将游戏操作从MB#4重新映射到其他键。
执行以下操作:
(假设当前未使用F12
键)
F12
分配给您的物理MB#4
F12
,而不是MB#4因此,当您按下physical MB#4时,游戏将接收F12
并激活游戏操作。
现在跳过“步骤3”,继续执行“步骤4”。
步骤3.
转到LGS中的大鼠标图片。
从physical MB#4取消分配标准命令"Back“(从下拉菜单中选择" Unassign”)。
步骤4.
转到LGS中的大鼠标图片。
将命令"Back“分配给您的物理按钮G20。
步骤5.
设置脚本
local function InterruptableSleep(ms)
local tm = GetRunningTime() + ms
while GetRunningTime() < tm do
Sleep(5)
if not IsMouseButtonPressed(4) then return true end
end
end
function OnEvent(event, arg)
if event == "MOUSE_BUTTON_PRESSED" and arg == 20 then
repeat
if InterruptableSleep(math.random(120, 160)) then break end
PressKey("1")
Releasekey("1")
if InterruptableSleep(90) then break end
PressMouseButton(1)
ReleaseMouseButton(1)
if InterruptableSleep(math.random(120, 160)) then break end
PressKey("2")
Releasekey("2")
if InterruptableSleep(90) then break end
PressMouseButton(1)
ReleaseMouseButton(1)
until not IsMouseButtonPressed(4) -- 4 = "Back"
end
end
https://stackoverflow.com/questions/69234657
复制相似问题