【问题标题】:How to cancel a script after it has started LUA如何在启动 LUA 后取消脚本
【发布时间】:2023-01-01 16:47:05
【问题描述】:

如果我启动我的脚本然后意识到我按下了错误的按钮或者不希望它一直运行到最后我可以在代码中添加一些东西如果我再次按下按钮或者另一个按钮如果它必须是它会立即停止脚本?

我正在使用 LUA 脚本

这是我当前的脚本

    if (event == "G_PRESSED" and arg == 4 and GetMKeyState("kb") == 3) then 
    MoveMouseTo( 36165, 57821)
    Sleep(math.random(10, 25))
    PressMouseButton(3)      
    ReleaseMouseButton(3)
    Sleep(math.random(40, 135))
    MoveMouseTo( 36131, 59461)
    Sleep(math.random(30, 65))
    PressKey ("lalt")
    Sleep(math.random(30, 65))
    PressKey ("X")
    Sleep(math.random(30, 65))
    ReleaseKey ("lalt")
    ReleaseKey ("X")
    PressMouseButton(1)
    ReleaseMouseButton(1)
    Sleep(math.random(2220, 2270))
    MoveMouseTo( 38932, 56060)
    Sleep(math.random(10, 25))
    PressMouseButton(1)
    ReleaseMouseButton(1)
    Sleep(math.random(40, 135))
    MoveMouseTo( 2595, 3037)
    Sleep(math.random(40, 135))
    PressMouseButton(1)
    ReleaseMouseButton(1)
    MoveMouseTo( 4166, 1518)
    Sleep(math.random(250, 350))
    PressMouseButton(1)
    ReleaseMouseButton(1)
    MoveMouseTo( 38932, 56060)
    Sleep(math.random(40, 135))
    PressMouseButton(3)
    ReleaseMouseButton(3)
    Sleep(math.random(40, 135))
    MoveMouseTo( 38590, 57882)
    Sleep(math.random(40, 135))
    PressKey ("lalt")
    Sleep(math.random(40, 135))
    PressKey ("X")
    Sleep(math.random(40, 135))
    ReleaseKey ("lalt")
    ReleaseKey ("X")
    Sleep(math.random(40, 135))
    PressKey ("O")
    Sleep(math.random(40, 135))
    ReleaseKey ("O")
    Sleep(200)
    MoveMouseTo( 54436, 55453)
    Sleep(math.random(40, 135))
    PressMouseButton(1)
    ReleaseMouseButton(1)
    Sleep(400)
    MoveMouseTo( 54299, 48650)
       Sleep(150)
       PressMouseButton(1)      
       ReleaseMouseButton(1)
    end

【问题讨论】:

    标签: lua


    【解决方案1】:

    您可以使用 while 循环来检查条件是否会在满足条件时中断,例如:

    while true do
        if (GetMKeyState("kb") == 3) then
            break
        end
    end
    

    您还可以在末尾添加一个类似的循环来检查某个按键或鼠标单击,然后在满足该条件时跳出循环。

    【讨论】:

      猜你喜欢
      • 2021-08-26
      • 2021-03-02
      • 2012-04-12
      • 1970-01-01
      • 2018-11-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-29
      相关资源
      最近更新 更多