罗技脚本内容
EnablePrimaryMouseButtonEvents(true)
-- 配置参数
local w = 900 -- 运行到多少次吃窝窝头
local q = 1500 -- 运行到多少次切换武器次数
local xunhuanyanchi = 500 -- 循环延迟时间
local panduan = 2 -- 选择执行逻辑的条件,可以是 1 或 2 1是NUM小键盘灯 2 是Caps大小写灯,开启灯按鼠标G5键开启宏,关闭直接关掉灯即可
-- 全局变量初始化
local chiwowotoucishu = 0
local qiehuanwuqi = 0
-- 执行宏的函数
local function runMacro(lockCheckFunc)
while true do
PressAndReleaseMouseButton(1) -- 模拟鼠标左键点击
-- 计数器增加并执行相应动作
chiwowotoucishu = chiwowotoucishu + 1
qiehuanwuqi = qiehuanwuqi + 1
-- 输出日志
OutputLogMessage("[提示] 吃窝窝头次数: %d/%d, 切换武器次数: %d/%d\n", chiwowotoucishu, w, qiehuanwuqi, q)
-- 达到次数后执行动作
if chiwowotoucishu == w then
chiwowotoucishu = 0
OutputLogMessage("[提示] 准备吃窝窝头了\n")
-- 模拟按下并释放按键
Sleep(6000)
PressKey("2")
Sleep(50)
ReleaseKey("2")
Sleep(3000)
OutputLogMessage("[提示] 不出意外窝窝头已经吃好了\n")
end
if qiehuanwuqi == q then
qiehuanwuqi = 0
OutputLogMessage("[提示] 准备切换武器了\n")
-- 模拟按下并释放按键
Sleep(6000)
PressKey("1")
Sleep(50)
ReleaseKey("1")
Sleep(3000)
OutputLogMessage("[提示] 不出意外武器已经切换完毕了\n")
end
-- 循环延迟
Sleep(xunhuanyanchi)
-- 强制结束宏
if not lockCheckFunc() then
break
end
end
end
-- 主函数
function OnEvent(event, arg)
-- 键盘锁定状态检查
local numlock_on = IsKeyLockOn("numlock")
local capslock_on = IsKeyLockOn("capslock")
-- 根据 panduan 变量选择执行逻辑
if (panduan == 1 and numlock_on) then
if event == "MOUSE_BUTTON_PRESSED" and arg == 5 then
runMacro(function() return IsKeyLockOn("numlock") end)
end
elseif (panduan == 2 and capslock_on) then
if event == "MOUSE_BUTTON_PRESSED" and arg == 5 then
runMacro(function() return IsKeyLockOn("capslock") end)
end
end
-- 获取鼠标位置
if event == "MOUSE_BUTTON_PRESSED" and arg == 6 then
local x, y = GetMousePosition()
OutputLogMessage("[提示] X坐标: %d Y坐标: %d\n", x, y)
chiwowotoucishu = 0
qiehuanwuqi = 0
OutputLogMessage("[提示] 窝窝头以及切换武器已经初始化为0\n")
end
end