我试图每秒调用一个方法 20 次以将 A 点推离 B 点。该方法应使用以下变量:
- A点(X)
- A点(Y)
- B点(X)
- B点(Y)
- 力量
A 点和 B 点越靠近,它们彼此远离的速度就越快。强度变量控制每个刻度的距离以及不再推动点 A 的点之间的距离......
基本上我试图慢慢地将光标推离指定点。
有什么想法可以实现吗?
这是我的尝试,不幸的是,如果距离增加,光标移动得更快......
'PosX and PosY are the percentage of the screen width/height
'Calculate the real position
Dim ScreenPosX As Integer = Screen.PrimaryScreen.WorkingArea.Width * (PosX / 100)
Dim ScreenPosY As Integer = Screen.PrimaryScreen.WorkingArea.Height * (PosY / 100)
Dim PointOffsetX As Integer = Cursor.Position.X - ScreenPosX
Dim PointOffsetY As Integer = Cursor.Position.Y - ScreenPosY
If PointOffsetX > -Strength And PointOffsetX < Strength Then
Dim StrengthFactorX As Integer = Strength - ScreenOffsetX
Dim StrengthFactorY As Integer = Strength - ScreenOffsetY
Cursor.Position = New Point(Cursor.Position.X + StrengthFactorX, Cursor.Position.Y + StrengthFactorY)
'Would be the same for Y. Obviously doesn't work though.
End If