0

我不知道如何让鼠标每秒以不同的速度下拉。

我尝试添加不同的睡眠值,这会改变我的鼠标在整个脚本中下拉的力度,但它不起作用,它只会以一个设定的速率下拉。

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

我期待鼠标以一个速率下拉,然后在一秒钟后更用力地下拉,但结果只是一个固定速率。

4

1 回答 1

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)
于 2019-07-11T08:36:19.277 回答