Logitech 鼠标循环开关

我已经尝试了很多次,最终总是陷入无限循环。

我的代码:

toggle_button = 5
button_toggled = false
function OnEvent(event, arg)
    if event == "MOUSE_BUTTON_PRESSED" and arg == toggle_button then
        button_toggled = not button_toggled
        if button_toggled then
            while button_toggled do
            OutputLogMessage(tostring(button_toggled))
            Sleep(50)
            end
        else
            button_toggled = not button_toggled
        end
    end
end
点赞