1

一位朋友在游戏中使用此 Logitech 鼠标的 LUA 脚本,如果他单击并按住鼠标右键,然后还单击鼠标左键,则会执行“按左键”操作:

function OnEvent(event,arg)
    if IsKeyLockOn("numlock")then
        if IsMouseButtonPressed(3)then
            repeat 
                if IsMouseButtonPressed(1) then
                    PressAndReleaseKey("lalt")
                    repeat
                    until not IsMouseButtonPressed(1)
                end
            until not IsMouseButtonPressed(3)
        end
    end
end

我有不同的设置,我没有单击并按住鼠标右键,而是单击一次,然后我的左键单击可能会在 1-2 秒后或之后立即跟随。因此,仅当我单击鼠标右键然后立即或在 2 秒内单击鼠标左键时,我才需要脚本执行“按左键”操作。

你们能帮帮我吗?

提前致谢!

4

1 回答 1

0
local RMB_time = -math.huge

function OnEvent(event, arg)
   if event == "PROFILE_ACTIVATED" then
      EnablePrimaryMouseButtonEvents(true)
   elseif event == "MOUSE_BUTTON_PRESSED" and arg == 2 then  -- RMB pressed
      RMB_time = GetRunningTime()
   elseif event == "MOUSE_BUTTON_PRESSED" and arg == 1 then  -- LMB pressed
      if IsKeyLockOn"numlock" and GetRunningTime() - RMB_time < 2000 then
         Sleep(20)
         PressKey("lalt")
         Sleep(50)
         ReleaseKey("lalt")
      end
   end
end
于 2020-11-21T09:16:02.340 回答