ghub吧 关注:361贴子:1,509
  • 1回复贴,共1

有没有大佬帮我看一下ghub这个代码哪里不对

取消只看楼主收藏回复

本意是做一个能连续点击多个坐标点并且可以随时停止的脚本,但是现在写的这个无法做到停止
local point1 = {x = 7820, y = 18707}
local point2 = {x = 6864, y = 23262}
local clickInterval = 25
local maxCycles = 5
local currentCycle = 0
local isRunning = false
local shouldStop = false
function clickAtPoint(point)
MoveMouseTo(point.x, point.y)
Sleep(25)
PressMouseButton(1)
Sleep(25)
ReleaseMouseButton(1)
end
function cycleClick()
if not isRunning then
isRunning = true
shouldStop = false
currentCycle = 0
OutputLogMessage("脚本开始运行\n")
while currentCycle < maxCycles and not shouldStop do
OutputLogMessage("点击点1 (%d, %d)\n", point1.x, point1.y)
clickAtPoint(point1)
OutputLogMessage("点击点2 (%d, %d)\n", point2.x, point2.y)
clickAtPoint(point2)
currentCycle = currentCycle + 1
OutputLogMessage("已完成 %d/%d 次循环\n", currentCycle, maxCycles)
end
isRunning = false
if shouldStop then
OutputLogMessage("脚本已手动停止\n")
else
OutputLogMessage("脚本已完成\n")
end
end
end
function stopScript()
shouldStop = true
end
function OnEvent(event, arg)
if event == "MOUSE_BUTTON_PRESSED" and arg == 5 then
cycleClick()
elseif event == "MOUSE_BUTTON_PRESSED" and arg == 4 then
stopScript()
end
end


IP属地:浙江1楼2025-06-20 14:45回复
    1


    IP属地:浙江来自iPhone客户端2楼2025-06-20 18:50
    回复