# 输入设备 (opens new window),鼠标,键盘
点击指定区域,等待按下空格键结束:
-- x,y = getMousePos
setMousePos(1597 ,629 )
while true do
mouse_event(MOUSEEVENTF_LEFTDOWN)
sleep(300)
mouse_event(MOUSEEVENTF_LEFTUP)
if isKeyPressed(VK_SPACE) then
print("end.")
break
end
end
在游戏窗口区域点击:
{$lua}
if syntaxcheck then return end
[ENABLE]
local rect = getTargetWindowRect()
if not rect then return end
-- 添加offset避免点到游戏边框
local offset = 100
-- 每隔200毫秒执行一次
ptimer = setInterval(function()
-- 是否选中游戏
if not targetWindowIsTop() then return end
-- 当前鼠标位置
local x,y = getMousePos()
-- 在游戏区域内
if x > rect.left + offset and x < rect.right - offset and
y > rect.top + offset and y < rect.bottom - offset then
-- 鼠标左键按下
mouse_event(MOUSEEVENTF_LEFTDOWN)
sleep(20)
-- 鼠标左键抬起
mouse_event(MOUSEEVENTF_LEFTUP)
end
end, 200)
[DISABLE]
clearInterval(ptimer)
# 移动鼠标
{$lua}
if syntaxcheck then return end
[ENABLE]
-- 圆中心
local cx = 568
local cy = 821
-- 半径
local r = 100
local a = 0;
ptimer = setInterval(function()
-- - 顺时针
-- + 逆时针
a = a < 360 and a - 0.1 or 0
local x = r * math.sin(a)
local y = r * math.cos(a)
setMousePos(cx+x,cy+y)
end, 1000 / 60)
[DISABLE]
clearInterval(ptimer)