Logitech G Hub脚本-即使释放了鼠标左键,代码有时仍会运行 [英] Logitech G Hub script - The code keeps running sometimes even after I release left mouse

查看:586
本文介绍了Logitech G Hub脚本-即使释放了鼠标左键,代码有时仍会运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

即使我松开鼠标左键,有时脚本也会不断点击自身,如何停止此操作.

Even after I release left mouse the script would sometimes keep clicking by itself how do I stop this.

EnablePrimaryMouseButtonEvents(true);

function OnEvent(event, arg)
            if IsMouseButtonPressed(1) then
                repeat
                    Sleep(math.random(50, 75))
                    PressMouseButton(1)
                    Sleep(math.random(50, 75))
                    ReleaseMouseButton(1)
                until not IsMouseButtonPressed(1)
            end             
end

推荐答案

既不能模拟LMB的按下/释放,也不能确定它是按下还是释放.

It's impossible to both simulate LMB press/release and determine if it's pressed or released.

但是有一种解决方法:您可以添加替代按钮来执行与LMB相同的操作.
例如,如果LMB表示开火",则添加键"P"作为在游戏中开火的替代方法.

But there is a workaround: you can add alternative button for the same action as LMB.
For example, if LMB means "Fire" then add key "P" as alternative way to fire in the game.

local key_fire = "P"
EnablePrimaryMouseButtonEvents(true)

function OnEvent(event, arg)
   if event == "MOUSE_BUTTON_PRESSED" and arg == 1 then
      Sleep(math.random(100, 150))
      while IsMouseButtonPressed(1) do
         Sleep(math.random(50, 75))
         PressKey(key_fire)
         Sleep(math.random(50, 75))
         ReleaseKey(key_fire)
      end
   end
end

您可以通过按LMB来拍摄第一张照片,而脚本将通过在循环中以编程方式按 P 来拍摄第二张,第三张....

You make the first shot by pressing LMB, and the script will make 2nd, 3rd,... shots by programmatically pressing P in the loop.

这篇关于Logitech G Hub脚本-即使释放了鼠标左键,代码有时仍会运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆