NetAutoGUI/Internals/AbstractMouseController.cs
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using MonoGame.Extended.Tweening;
using System.Diagnostics;
using System.Numerics;
using System.Threading;
namespace NetAutoGUI.Internals
{
public abstract class AbstractMouseController : IMouseController
{
private readonly double MINIMUM_DURATION = 0.1;//If the duration is less than MINIMUM_DURATION the movement will be instant.
public abstract void Click(int? x = null, int? y = null, MouseButtonType button = MouseButtonType.Left, int clicks = 1, double interval = 0);
public void DoubleClick(int? x = null, int? y = null, MouseButtonType button = MouseButtonType.Left, double interval = 0)
{
Click(x, y, button, 2, interval);
}
public abstract void MouseDown(int? x = null, int? y = null, MouseButtonType button = MouseButtonType.Left);
public abstract void MouseUp(int? x = null, int? y = null, MouseButtonType button = MouseButtonType.Left);
public void Move(int offsetX, int offsetY)
{
(int x, int y) = Position();
MoveTo(x + offsetX, y + offsetY);
}
public abstract void MoveTo(int x, int y);
public void MoveTo(int x, int y, double durationInSeconds, TweeningType tweeningType = TweeningType.Linear)
{
durationInSeconds.NotNegative(nameof(durationInSeconds));
if (durationInSeconds <= MINIMUM_DURATION)
{
MoveTo(x, y);
return;
}
Vector2TweeningObject tweenObject = new Vector2TweeningObject();
tweenObject.CurrentValue = Position();
tweenObject.ToValue = new Vector2(x, y);
using Tweener tweener = new Tweener();
tweener.TweenTo(target: tweenObject, expression: _ => tweenObject.CurrentValue,
toValue: tweenObject.ToValue,
duration: (float)durationInSeconds * 1000, delay: 0)
.Easing(TweeningTypeHelpers.ToEasingFunction(tweeningType));
Stopwatch sw = Stopwatch.StartNew();
sw.Start();
long lastMS = sw.ElapsedMilliseconds;
while (sw.ElapsedMilliseconds <= durationInSeconds * 1000)
{
tweener.Update(sw.ElapsedMilliseconds - lastMS);
lastMS = sw.ElapsedMilliseconds;
MoveTo((int)tweenObject.CurrentValue.X, (int)tweenObject.CurrentValue.Y);
Thread.Sleep(10);
}
}
后面还有 19 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。