我不知道如何使鼠标每秒以不同的速度下拉。
我尝试添加不同的睡眠值,这将改变鼠标在整个脚本中下拉的难度,但是它不起作用,只会以设定的速率下拉。
function OnEvent(event, arg)
if IsKeyLockOn("scrolllock" )then
if IsMouseButtonPressed(1) then
repeat
MoveMouseRelative(0,1)
Sleep(8)
MoveMouseRelative(0,1)
Sleep(7)
until not IsMouseButtonPressed(1)
end
end
end
我期望鼠标以一个速率向下滑动,然后在第二秒内更困难地向下滑动,但是结果只是一个固定速率。
答案 0 :(得分:0)
Windows计时器的刻度是15-16毫秒。
这意味着Sleep(1)
,Sleep(2)
,...,Sleep(15)
几乎相同。
您应该改变移动鼠标的像素数量。
local time0 = GetRunningTime()
repeat
local dtime = GetRunningTime() - time0
local dy
if dtime < 1000 then
-- during the first second we move mouse slowly: 1 pixel per tick
dy = 1
else
-- after the first second we move mouse faster: 2 pixels per tick
dy = 2
end
MoveMouseRelative(0,dy)
Sleep(1)
until not IsMouseButtonPressed(1)