相关文章推荐
活泼的椰子  ·  python ...·  1 年前    · 
英姿勃勃的闹钟  ·  django.core.exceptions ...·  2 年前    · 
暗恋学妹的柑橘  ·  python 使用 ...·  2 年前    · 

没学过编程,随便乱搞的,2000点多行,但是功能还是实现了,难为我了,有没有大佬帮忙优化?

function OnEvent(event, arg)
if (event == "MOUSE_BUTTON_PRESSED" and arg ==6) then--当按下鼠标6键然后
      PressAndReleaseKey("b")--按下并弹起按键b
      Sleep(10)--延迟20毫秒
        PressAndReleaseKey("spacebar")--按下空格键
        Sleep(200)
               local  i=math.random(1,37)--随机变量1到37
               if i==1  then
               PressAndReleaseKey("num0")
               Sleep(10)
               elseif i==2 then
               PressAndReleaseKey(1)
               Sleep(10)
               elseif i==3 then
              PressAndReleaseKey(2)
               Sleep(10)
              elseif i==4 then
               PressAndReleaseKey(3)
               Sleep(10)
               elseif i==5 then
               PressAndReleaseKey(4)
               Sleep(10) 
               elseif i==6 then
               PressAndReleaseKey(5)
               Sleep(10)
               elseif i==7 then
               PressAndReleaseKey(6)
				
lua需要生成随机数的需求也是很常见的,为了生成看起来更随机的数字,我们需要注意以下几点 我们也需要给随机数设置随机数种子:math.randomseed(xx) lua随机数种子也是有一定要求的:不能太相近 lua中的os.time()是基于秒的,不太满足lua随机数种子的要求(如果设置随机数种子的频率太高的话) 那怎么做? 把 os.time()返回的数值字串倒过来再取高...
CSDN-Ada助手: 恭喜您开始博客创作!标题中的“罗技鼠标lua脚本随机按键输出”听起来非常有趣。通过分享您编写的脚本,您不仅能够帮助其他用户解决类似问题,还能展示您的技术能力。接下来,我建议您可以进一步深入探讨该脚本的实现原理,并分享一些实际应用场景,或者提供一些额外的技巧和技术建议。期待看到更多有关罗技鼠标lua脚本的内容,祝您博客创作顺利! 推荐【每天值得看】:https://bbs.csdn.net/forums/csdnnews?typeId=21804&utm_source=csdn_ai_ada_blog_reply1