logitech鼠标宏吧 关注:509贴子:1,963

[求学]PUGB压枪宏自学日记.

只看楼主收藏回复



1楼2018-08-06 13:40回复
    写这篇帖子.
    一是记录自己的学习过程.
    二是记录学习过程中的问题/让大佬帮忙
    三是希望交流


    2楼2018-08-06 13:41
    收起回复
      2025-08-24 21:15:02
      广告
      不感兴趣
      开通SVIP免广告
      在接触Logitech编程、LUA语言之前,就知道罗技/雷蛇等带驱动的鼠标是有压枪宏的。
      期间购买了约三四个的样子,能长期更新的是一个也没有,质量更是参差不齐,最好的属38包更新的
      不过在更新了一次之后也跑路了,一个大版本+一个小版本没有更新了
      到现在自己也不耐烦了,因为压枪效果说真的不算非常好,跟吧主 @camend001 演示视频里比,差一个档次。
      并且各人电脑差异,确实有存在着需要调试的情况
      so,下定决心自己学习,最起码达到可以修改别人压枪宏的水平


      3楼2018-08-06 13:51
      回复
        学习第一步:LUA语言,Logitech编程用的就是LUA语言+自己的G-series Lua API,
        G-series Lua API 参考文档在网上很多,罗技官网也能下载到。
        LUA语言的学习目前是在优酷上看的“医生不坑”的0基础LUA语言入门教程,看完了循环语言,决定暂时不看完了,熟练掌握循环语句后再深一步去学。


        4楼2018-08-06 13:55
        回复
          学习第二步:尝试修改以前的压枪宏,以下面这段压枪宏为例:
          function OnEvent(event, arg)
          OutputLogMessage("event = %s, 键号是 = %s\n", event, arg)
          AkNumber = 4
          ----AK按键号↑
          M4Number = 6
          ----M4按键号↑
          OneClose = 3
          ---关闭压枪号↑
          FireCode = "F8";
          ----开火键按键↑
          FourCode = "capslock";
          ------4倍镜键按键↑
          AllCode = "numlock";
          ------满配件按键↑
          ShieldCode = "alt";
          ------暂停压枪按键↑
          -------------------------------------------------------------------------------------------------
          function BingXiFunc()
          result = false
          result = IsModifierPressed("shift")
          return result
          end
          function PingBiFunc()
          result = false
          result = IsModifierPressed(ShieldCode)
          return result
          end
          -------------------------------------------------------------------------------------------------
          function BoomAK()
          shotTime = 0
          repeat
          if (IsMouseButtonPressed(1)) then
          ifshotTime>1200 then
          MoveMouseRelative(0, 9.8)
          elseif shotTime>800 then
          MoveMouseRelative(0, 8.4)
          elseif shotTime < 800 then
          MoveMouseRelative(0, 8)
          end
          PressAndReleaseKey(FireCode)
          Sleep(30)
          shotTime = shotTime+30
          else
          break
          end
          until( not IsOnClick )
          end
          -------------------------------------------------------------------------------------------------
          function ShiftAK()
          shotTime = 0
          repeat
          if (IsMouseButtonPressed(1)) then
          ifshotTime>1400 then
          MoveMouseRelative(0, 11)
          elseif shotTime>1000 then
          MoveMouseRelative(0, 11)
          elseif shotTime < 1000 then
          MoveMouseRelative(0, 10)
          end
          PressAndReleaseKey(FireCode)
          Sleep(30)
          shotTime = shotTime+30
          else
          break
          end
          until( not IsOnClick )
          end
          -------------------------------------------------------------------------------------------------
          function BoomAllAK()
          shotTime = 0
          repeat
          if (IsMouseButtonPressed(1)) then
          ifshotTime>1840 then
          MoveMouseRelative(0, 7.5)
          elseifshotTime>1000 then
          MoveMouseRelative(0, 7.2)
          elseif shotTime>680 then
          MoveMouseRelative(0, 6.8)
          elseif shotTime < 680 then
          MoveMouseRelative(0, 6.3)
          end
          PressAndReleaseKey(FireCode)
          Sleep(30)
          shotTime = shotTime+30
          else
          break
          end
          until( not IsOnClick )
          end
          -------------------------------------------------------------------------------------------------
          function BoomM4()
          shotTime = 0
          repeat
          if (IsMouseButtonPressed(1)) then
          ifshotTime>1600 then
          MoveMouseRelative(0, 11.3)
          elseifshotTime>1200 then
          MoveMouseRelative(0, 11.5)
          elseif shotTime>700 then
          MoveMouseRelative(0, 11.2)
          elseif shotTime < 700 then
          MoveMouseRelative(0, 8.3)
          end
          PressAndReleaseKey(FireCode)
          Sleep(30)
          shotTime = shotTime+30
          else
          break
          end
          until( not IsOnClick )
          end
          -------------------------------------------------------------------------------------------------
          function ShiftM4()
          shotTime = 0
          repeat
          if (IsMouseButtonPressed(1)) then
          ifshotTime>1600 then
          MoveMouseRelative(1, 9.9)
          elseifshotTime>900 then
          MoveMouseRelative(0.5, 10)
          elseif shotTime>570 then
          MoveMouseRelative(0, 10.8)
          elseif shotTime < 570 then
          MoveMouseRelative(0, 8)
          end
          PressAndReleaseKey(FireCode)
          Sleep(30)
          shotTime = shotTime+30
          else
          break
          end
          until( not IsOnClick )
          end
          -------------------------------------------------------------------------------------------------
          function BoomAllM4()
          shotTime = 0
          repeat
          if (IsMouseButtonPressed(1)) then
          ifshotTime>1840 then
          MoveMouseRelative(0, 7.5)
          elseifshotTime>1000 then
          MoveMouseRelative(0, 7.2)
          elseif shotTime>680 then
          MoveMouseRelative(0, 6.8)
          elseif shotTime < 680 then
          MoveMouseRelative(0, 6.3)
          end
          PressAndReleaseKey(FireCode)
          Sleep(30)
          shotTime = shotTime+30
          else
          break
          end
          until( not IsOnClick )
          end
          -------------------------------------------------------------------------------------------------
          function BoomAKPoint()
          shotTime = 0
          repeat
          if (IsMouseButtonPressed(1)) then
          if shotTime>1840 then
          MoveMouseRelative(0, 60)
          elseif shotTime>1000 then
          MoveMouseRelative(0, 55)
          elseif shotTime>680 then
          MoveMouseRelative(0, 55)
          elseif shotTime < 680 then
          MoveMouseRelative(0, 46)
          end
          PressAndReleaseKey(FireCode)
          Sleep(300)
          shotTime = shotTime+30
          else
          break
          end
          until( not IsOnClick )
          end
          -------------------------------------------------------------------------------------------------
          function BoomM4Point()
          shotTime = 0
          repeat
          if (IsMouseButtonPressed(1)) then
          if shotTime>1840 then
          MoveMouseRelative(0, 60)
          elseif shotTime>1000 then
          MoveMouseRelative(0, 62)
          elseif shotTime>680 then
          MoveMouseRelative(0, 65)
          elseif shotTime < 680 then
          MoveMouseRelative(0, 48)
          end
          PressAndReleaseKey(FireCode)
          Sleep(55)
          shotTime = shotTime+30
          else
          break
          end
          until( not IsOnClick )
          end
          -------------------------------------------------------------------------------------------------
          function AkFunc(arg)
          if not PingBiFunc() then
          ifIsKeyLockOn(FourCode ) then
          BoomAKPoint()
          elseif IsKeyLockOn(AllCode) then
          if not BingXiFunc() then
          BoomAK()
          else
          ShiftAK()
          end
          else
          BoomAllAK()
          end
          end
          end
          -------------------------------------------------------------------------------------------------
          function M4Func(arg)
          if not PingBiFunc() then
          ifIsKeyLockOn(FourCode) then
          BoomM4Point()
          elseif IsKeyLockOn(AllCode) then
          if not BingXiFunc() then
          BoomM4()
          else
          ShiftM4()
          end
          else
          BoomAllM4()
          end
          end
          end
          -------------------------------------------------------------------------------------------------
          function TransAK()
          IsOnClick = false
          IsM4 = false
          IsAK = not IsAK
          if IsAK then
          macro = true
          OutputLogMessage("AK on\n")
          OutputLCDMessage("AK on",500000)
          else
          macro = false
          OutputLogMessage("AK off\n")
          OutputLCDMessage("AK off",500000)
          end
          scr()
          end


          5楼2018-08-06 13:57
          收起回复
            -------------------------------------------------------------------------------------------------
            function TransM4()
            IsOnClick = false
            IsAK = false
            IsM4 = not IsM4
            if IsM4 then
            macro = true
            OutputLogMessage("M4 on\n")
            OutputLCDMessage("M4 on",500000)
            else
            macro = false
            OutputLogMessage("M4 off\n")
            OutputLCDMessage("M4 off",500000)
            end
            scr()
            end
            -------------------------------------------------------------------------------------------------
            function OutTransFunction()
            IsAK = false
            IsM4 = false
            IsOnClick = false
            macro = false
            OutputLogMessage("all gun off\n")
            OutputLCDMessage("all gun off",500000)
            scr()
            end
            -------------------------------------------------------------------------------------------------
            if (event == "MOUSE_BUTTON_RELEASED" and arg == 1) then
            IsOnClick = false
            ReleaseKey(FireCode)
            end
            if (event == "PROFILE_ACTIVATED") then
            EnablePrimaryMouseButtonEvents(true)
            elseif event == "PROFILE_DEACTIVATED" then
            IsOnClick = false
            end
            IsOnClick = false
            if (event == "MOUSE_BUTTON_PRESSED" and arg == 1) then
            IsOnClick = not IsOnClick
            end
            if (event == "MOUSE_BUTTON_PRESSED" and arg == AkNumber) then
            OutputLogMessage("event AKAK\n", event, arg)
            TransAK()
            IsOnClick = false
            end
            if (event == "MOUSE_BUTTON_PRESSED" and arg == M16Number) then
            TransM16()
            IsOnClick = false
            end
            if (event == "MOUSE_BUTTON_PRESSED" and arg == Ump9Number) then
            TransUWP9()
            IsOnClick = false
            end
            if (event == "MOUSE_BUTTON_PRESSED" and arg == M4Number) then
            TransM4()
            IsOnClick = false
            end
            if (event == "MOUSE_BUTTON_PRESSED" and arg == UziNumber) then
            TransUZI()
            IsOnClick = false
            end
            if (event == "MOUSE_BUTTON_PRESSED" and arg == ScarNumber) then
            TransSC()
            IsOnClick = false
            end
            if (event == "MOUSE_BUTTON_PRESSED" and arg == OneClose) then
            OutTransFunction()
            IsOnClick = false
            end
            -----------------------------------------------------------------------------------------------------------
            if (event == "MOUSE_BUTTON_PRESSED" and arg == 1 and IsAK) then
            AkFunc(arg)
            elseif (event == "MOUSE_BUTTON_PRESSED" and arg == 1 and IsSC) then
            ScarFunc(arg)
            elseif (event == "MOUSE_BUTTON_PRESSED" and arg == 1 and IsM4) then
            M4Func(arg)
            elseif (event == "MOUSE_BUTTON_PRESSED" and arg == 1 and IsM16) then
            M16Func(arg)
            elseif (event == "MOUSE_BUTTON_PRESSED" and arg == 1 and IsUWP9) then
            Ump9Func(arg)
            elseif (event == "MOUSE_BUTTON_PRESSED" and arg == 1 and IsUZI) then
            UziFunc(arg)
            elseif (event == "MOUSE_BUTTON_PRESSED" and arg == 1) then
            if not PingBiFunc() then
            PressKey(FireCode)
            end
            end
            end
            function scr()
            if macro and not IsKeyLockOn("scrolllock") then
            PressAndReleaseKey("scrolllock")
            end
            if not macro and IsKeyLockOn("scrolllock") then
            PressAndReleaseKey("scrolllock")
            end
            end


            6楼2018-08-06 13:57
            回复
              五六楼加起来就是一段完整的压枪宏代码,直接复制黏贴即可使用。
              M4的现在的红点/机瞄仍然可以用。
              AKM的后半段子弹不集中。
              枪支快捷键可以自己修改:
              AkNumber = 4
              ----AK按键号↑
              M4Number = 6
              ----M4按键号↑
              OneClose = 3
              ---关闭压枪号↑
              根据自己罗技鼠标的按键自定义修改即可,大写键=4倍镜,NumLock=满配模式,ALT=舔包键。
              目前的目标就是修改调试FunctionAKM的参数,让他更精准。


              7楼2018-08-06 14:01
              收起回复
                但是由于0基础入门,虽然看懂代码没有问题,但是修改起来问题就太大了。
                例如原先AK的函数:

                function BoomAK() 右键机瞄/基础镜开火函数
                shotTime = 0 设定一个叫shotTime/开火时间的值,将0赋予它。
                repeat
                if (IsMouseButtonPressed(1)) then 如果 确定鼠标被按下(IsMouseButtonPressed)左键(1)按下 那么
                进入判断和执行阶段,这里分了三个条件,<800,>800,>1200毫秒。
                问题出在 sleep(30)和自循环的shotTime=shotTime+30
                我之前想不通为什么需要休息(30毫秒)和每次循环shotTime+30,后问了一个老哥,他告诉我要从业务逻辑出发,这两个代码是需要的,如果一直开枪,那么肯定会不准,我问他怎么得出这两个数值呢,他说应该是演/统计得出的。
                现在我就完全懵逼了,这应该怎么统计呢?


                8楼2018-08-06 14:14
                回复(12)
                  2025-08-24 21:09:02
                  广告
                  不感兴趣
                  开通SVIP免广告
                  期间我尝试过自己完全更改这串代码,比如
                  >2500
                  >2000
                  >1500
                  >1000
                  >500
                  <500
                  想每五颗子弹就更改控制一次下拉幅度,但是我始终不清楚sleep(30)和自循环的shotTime=shotTime+30的由来,让我感觉我这边改可能没办法做好
                  @camend001 吧主大哥,求指点。


                  9楼2018-08-06 14:16
                  收起回复
                    sleep(30)和shotTime=shotTime+30的作用是配合起来,作计时用的,给鼠标在时间段内移动多少提供依据。如果去掉sleep(30),你会发现鼠标瞬间移动到脚底。


                    IP属地:重庆10楼2018-08-11 20:28
                    回复
                      厉害了楼主,目前也在学习中,好复杂的说!


                      IP属地:湖南11楼2018-08-14 11:28
                      回复
                        这种算最垃圾的脚本


                        IP属地:浙江12楼2018-08-25 11:28
                        收起回复
                          Sleep30(宏每30毫秒位移一次)shottime(射击时间)
                          这个框架不拉几,只是你们不会用。参数值不会改


                          来自iPhone客户端13楼2018-08-26 14:13
                          收起回复
                            这宏运行鼠标起点在桌面可以完美运行呀,但鼠标的起点在腾讯手游助手窗口上就不能运行了,为什么哟?


                            IP属地:四川14楼2018-10-15 20:39
                            回复
                              2025-08-24 21:03:02
                              广告
                              不感兴趣
                              开通SVIP免广告
                              随机数谁知道


                              IP属地:湖南15楼2018-10-25 03:27
                              回复