Mouse¶
Methods to interact with the mouse.
To see a click heatmap at the end of your botting session add the following compiler directive before you include WaspLib:
{$DEFINE WL_DEBUG_MOUSE}
EMouseDistribution¶
EMouseDistribution = enum(
DEFAULT, // Use Mouse.Distribution
RANDOM, // Completely random point
GAUSS, // Weighted towards the center
SKEWED, // Weighted torwards current mouse position
ROWP // Weighted torwards current mouse position but more "rounded" compared to SKEWED
);
The available distributions used to generate a point in a box.
TMouse¶
TMouse = record(TSRLBaseRecord)
Speed: Double; // Overall mouse speed (Default: 12)
Gravity, Wind: Double; // Gravity & Wind for generating mouse path (Default: 9 & 5)
Distribution: EMouseDistribution; // Default distribution to use (Default: MOUSE_DISTRIBUTION_ROWP)
MissChance: Double; // Percentage chance to "Miss" the mouse (Default: 10)
IdleInterval: Double; // Distance to travel before calling Mouse.Idle() (Default: 0)
IdleProgress: Double;
IdleGoal: Double;
OnMoving: TMouseMovingEvent; // Callback while mouse is being moved
OnTeleport: TMouseTeleportEvent; // Callback when mouse is teleported
end;
Mouse.Setup¶
procedure TMouse.Setup();
Initializes TMouse
internal values.
Note
This is automatically called on the Mouse variable.
Mouse.Teleport¶
procedure TMouse.Teleport(coordinate: TPoint);
Teleport the mouse to the desired coordinate
.
Example:
Mouse.Teleport(50, 50);
Mouse.Position¶
property TMouse.Position: TPoint;
property TMouse.Position(value: TPoint);
Used to return or set the mouse current position as a TPoint
.
Example:
WriteLn(Mouse.Position);
Mouse.Position := [100, 100];
WriteLn(Mouse.Position);
Mouse.Hold¶
procedure TMouse.Hold(button: EMouseButton);
Holds the desired mouse button down. The button will continue to be held down until Mouse.Release is called.
Example:
Mouse.Hold(EMouseButton.LEFT); // The mouse is now holding down left click.
Mouse.Release¶
procedure TMouse.Release(button: EMouseButton);
Releases the desired mouse button which has been previously held.
Example:
Mouse.Release(EMouseButton.LEFT);
Mouse.Idle¶
procedure TMouse.Idle();
When IdleInterval is reached this is called. Override to change behavior.
An IdleInterval of 1.0 equals to the distance between the top left and bottom right of the client.
Assuming the client dimensions are 500,500 the distance between (0,0) and (500,500) is ~700. With an IdleInterval of 2.0 this would automatically be called every time the mouse has travelled ~1400 pixels.
Mouse.Miss¶
function TMouse.Miss(P: TPoint): TPoint;
“Misses” the destination point P. Will stop somewhere along the path or overshoot. Returns the position the mouse was moved to.
This could automatically be called depending on Mouse.MissChance.
Mouse.Move¶
procedure TMouse.Move(destination: TPoint);
procedure TMouse.Move(circle: TCircle; forcedMove: Boolean = False; distribution: EMouseDistribution = EMouseDistribution.DEFAULT); overload;
procedure TMouse.Move(b: TBox; forcedMove: Boolean = False; distribution: EMouseDistribution = EMouseDistribution.DEFAULT); overload;
procedure TMouse.Move(quad: TQuad; forcedMove: Boolean = False; distribution: EMouseDistribution = EMouseDistribution.DEFAULT); overload;
Moves the mouse to the desired destination. This method has several overloads available that are self explanatory.
Example:
var p: TPoint;
begin
p := TPoint.Create(50, 50);
Mouse.Move(p); // The mouse is now at 50,50
end;
Mouse.Click¶
procedure TMouse.Click(button: EMouseButton);
procedure TMouse.Click(destination: TPoint; button: EMouseButton); overload;
procedure TMouse.Click(circle: TCircle; button: EMouseButton; forcedMove: Boolean = False; distribution: EMouseDistribution = EMouseDistribution.DEFAULT); overload;
procedure TMouse.Click(b: TBox; button: EMouseButton; forcedMove: Boolean = False; distribution: EMouseDistribution = EMouseDistribution.DEFAULT); overload;
procedure TMouse.Click(quad: TQuad; button: EMouseButton; forcedMove: Boolean = False; distribution: EMouseDistribution = EMouseDistribution.DEFAULT); overload;
Moves and clicks the mouse on the desired destination
with the desired button
.
This method has several overloads available that are self explanatory.
Example:
var p: TPoint;
begin
p := TPoint.Create(50, 50);
Mouse.Click(p, EMouseButton.LEFT); // Moves and clicks the mouse left button at 50,50
end;
Mouse.Scroll¶
procedure TMouse.Scroll(amount: Integer; down: Boolean);
procedure TMouse.Scroll(pt: TPoint; amount: Integer; down: Boolean);
procedure TMouse.Scroll(box: TBox; amount: Integer; down: Boolean);
Scrolls the mouse X amount of times.
If a TPoint P
or a TBox b
is passed in, the mouse will be moved there to scroll.
Otherwise, the current mouse position is used.
Example:
var P: TPoint;
begin
P.X := 50;
P.Y := 50;
Mouse.Scroll(P, 5, True); // Scroll 5 times down at 50,50
Mouse.Scroll(P, 5, False); // Scroll 5 times up at 50,50
end;
Mouse variable¶
Global TMouse variable.