前言

之前那一篇基本解决了鼠标单击锁定的问题,但还是存在一些瑕疵,就是按下G7后如果单击鼠标就会取消掉单击锁定。

解决思路

思路很简单,直接禁用掉鼠标左键,通过脚本内部的函数来控制左键的触发。

目标效果

第一次按下G7后鼠标左键按下不松开,此时点击物理鼠标左键是不会有任何效果的;第二次按下G7后鼠标左键松开,此时物理鼠标左键重新起作用。

实现过程

设置的过程中最好有另一个鼠标辅助,因为设置的过程分两步,禁用鼠标左键和激活脚本,先禁用的话就无法单击,先激活脚本的话所有单击会变为双击。

禁用鼠标左键前记得切换配置文件为俄罗斯钓鱼4。

然后再修改之前的lua脚本,代码如下:

EnablePrimaryMouseButtonEvents(true)
local buttonFlag = false

function OnEvent(event, arg)
    -- OutputLogMessage("Event: "..event.." Arg: "..arg.."\n")

    if (event == "MOUSE_BUTTON_PRESSED" and arg == 1 and not buttonFlag) then
        PressMouseButton(1)
    end
    if (event == "MOUSE_BUTTON_RELEASED" and arg == 1 and not buttonFlag) then
        ReleaseMouseButton(1)
    end

    -- 路亚
    if (event == "MOUSE_BUTTON_PRESSED" and arg == 8) then
        -- 判断鼠标左键状态,松开鼠标左键
        if IsMouseButtonPressed(1) then
            ReleaseMouseButton(1)
        end
        -- 全力抛竿
        PressKey("lshift")
        RandomSleep(0, 200)
        PressMouseButton(1)
        RandomSleep(800, 500)
        ReleaseMouseButton(1)
        RandomSleep(0, 200)
        ReleaseKey("lshift")
    end

    -- 按住鼠标左键
    if (event == "MOUSE_BUTTON_PRESSED" and arg == 7) then
        if buttonFlag then
            ReleaseMouseButton(1)
            buttonFlag = false
        else
            PressMouseButton(1)
            buttonFlag = true
        end
    end
end

function RandomSleep(base, rand)
    math.randomseed(GetRunningTime())
    Sleep(math.ceil(base + rand * math.random()))
end
0
0