按键精灵2014
代码1 x1 = 800 : y1 = 600 //目标点 x2 = 100 : y2 = 100//起始点MoveTo x2,y2k = (y2 - y1) / (x2 - x1)b = y2 - k * x2For x = x2 To x1 Step sgn(x1 - x2) //sgn函数为返回表示数字符号的整数。当(x1 - x2)>0时,返回值为1.当(x1 - x2)<0时,返回值为-1.当=0时,返回值为0 LeftDown 1 MoveTo x, (k * x + b) LeftUp 1 Delay 1Next
代码2 Call 鼠标慢慢跑(100,100,800,600,5)Sub 鼠标慢慢跑(x1, y1, x2, y2,time1) Dim a, x, y, i x = x1 : y = y1 a = x2 / y2 MoveTo x1, y1 For i = y To y2-1 y = y + 1 x = y * a LeftDown 1 MoveTo x, y Delay time1 NextEnd Sub
代码3//点到点直线移动,鼠标移动速度开始快后来越来越慢Call 老鼠慢慢跑(100,100,800,600,100)Sub 老鼠慢慢跑(x1,y1,x2,y2,times) MoveTo x1,y1 While abs(x1-x2)>5 or abs(y1-y2)>5 GetCursorPos x1, y1 LeftDown 1 MoveR (x2 - x1) / 4, (y2 - y1) / 4 LeftUp 1 Delay times Wend LeftDown 1 MoveTo x2, y2 LeftUp 1End Sub
代码4//点到点直线移动,并且可以设置移动几次到达目标地点Dim a, b, c, d ,n,t //起点(100,100),终点(800,600)a = 100 : b = 100 : c = 800 : d = 600 //匀速直线移动UserVar n=100 '多少次移动到位'UserVar t=50 '每一次移动相隔多少时间'Call 老鼠慢慢跑()Sub 老鼠慢慢跑 MoveTo a, b Delay t For n x = (c - a) / n : y = (d - b) / n LeftDown 1 MoveR x, y LeftUp 1 Delay t Next End Sub
代码5MoveTo 100,100Call 老鼠慢慢跑(800, 600, 5, 50)Sub 老鼠慢慢跑(x, y, mousestep, mouseDelay) 'x,y : 移动终点坐标 ' mousestep: 移动间距 'mouseDelay : 移动时间间隔(ms) Dim Xstep, Ystep Dim curx, cury, PianYiX, PianYiY GetCursorPos curx, cury If abs(curx - x) < mousestep And abs(cury - y) < mousestep Then LeftDown 1 MoveTo x, y LeftUp 1 Exit Sub End If Xstep = (x - curx) / mousestep Ystep = (y - cury) / mousestep If abs(Xstep) > abs(Ystep) Then PianYiX = mousestep * sgn(Xstep) PianYiY = (y - cury) / abs(Xstep) Else PianYiX = (x - curx) / abs(Ystep) PianYiY = mousestep * sgn(Ystep) End If LeftDown 1 MoveR PianYiX, PianYiY LeftUp 1 Delay mouseDelay Call 老鼠慢慢跑(x, y, mousestep, mouseDelay)End Sub