Target

Target related methods.


TTargetOptions.ForceFocus

property TTargetOptions.ForceFocus: Boolean;
property TTargetOptions.ForceFocus(Value: Boolean);

Request window focus before mouse/key press.


TTargetOptions.MousePressMin

property TTargetOptions.MousePressMin: Integer;
property TTargetOptions.MousePressMin(Value: Integer);

When clicking the mouse with MouseClick the minimum milliseconds to hold the button down for.


TTargetOptions.MousePressMax

property TTargetOptions.MousePressMax: Integer;
property TTargetOptions.MousePressMax(Value: Integer);

When clicking the mouse with MouseClick the maximum milliseconds to hold the button down for.


TTargetOptions.MouseSpeed

property TTargetOptions.MouseSpeed: Double;
property TTargetOptions.MouseSpeed(Value: Double);

TTargetOptions.MouseGravity

property TTargetOptions.MouseGravity: Double;
property TTargetOptions.MouseGravity(Value: Double);

TTargetOptions.MouseWind

property TTargetOptions.MouseWind: Double;
property TTargetOptions.MouseWind(Value: Double);

TTargetOptions.MouseTimeout

property TTargetOptions.MouseTimeout: Integer;
property TTargetOptions.MouseTimeout(Value: Integer);

TTargetOptions.KeyPressMin

property TTargetOptions.KeyPressMin: Integer;
property TTargetOptions.KeyPressMin(Value: Integer);

When pressing a key with KeyPress/KeySend the minimum milliseconds to hold the button down for.


TTargetOptions.KeyPressMax

property TTargetOptions.KeyPressMax: Integer;
property TTargetOptions.KeyPressMax(Value: Integer);

When pressing a key with KeyPress/KeySend maximum milliseconds to hold the button down for.


TTarget.Construct

function TTarget.Construct: TTarget; static;

TTarget constructor. Use the new keyword to call this method like so:

myTarget := new TTarget();

TTarget.SetDesktop

procedure TTarget.SetDesktop;

Sets the desktop as the target.

Note

This is the default target for any TTarget created


TTarget.SetImage

procedure TTarget.SetImage(TImage: TImage);

Sets the TSimbaImage as a target.

Note

Ownership of the image is taken. It will be freed when the target is changed or target is freed


TTarget.SetWindow

procedure TTarget.SetWindow(Window: TWindowHandle);

Sets a window handle as a target.


TTarget.SetEIOS

procedure TTarget.SetEIOS(Plugin, Args: String);

Sets a plugin (via EIOS API) as the target.


TTarget.SetPlugin

procedure TTarget.SetPlugin(FileName, Args: String);

Sets a plugin (via SimbaPluginTarget API) as the target. For more details about the API see http://villavu.github.io/Simba/tutorials/plugins/plugin-target.html


TTarget.SetPlugin

procedure TTarget.SetPlugin(FileName, Args: String; out Canvas: TExternalCanvas);

Overloaded version that returns a “external canvas” to draw on.


TTarget.FreezeImage

procedure TTarget.FreezeImage(Bounds: TBox = [-1,-1,-1,-1]);

TTarget.UnFreezeImage

procedure TTarget.UnFreezeImage;

TTarget.IsImageFrozen

function TTarget.IsImageFrozen: Boolean;

TTarget.GetImage

function TTarget.GetImage(Bounds: TBox = [-1,-1,-1,-1]): TImage;

Returns the image of the target in the desired bounds. If bounds is not specified the entire target image is returned.


TTarget.IsValid

function TTarget.IsValid: Boolean;

TTarget.IsFocused

function TTarget.IsFocused: Boolean;

TTarget.Focus

function TTarget.Focus: Boolean;

TTarget.ToString

function TTarget.ToString: String;

TTarget.CustomClientArea

property TTarget.CustomClientArea: TBox;
property TTarget.CustomClientArea(Value: TBox);

Set a custom client area within the bounds of the target.

Target.CustomClientArea := [100,100,600,600];
Input.MouseMove([1,1]); // Will move the mouse to [101,101] on the "real" bounds

TTarget.Bounds

property TTarget.Bounds: TBox;

TTarget.Width

property TTarget.Width: Integer;

TTarget.Height

property TTarget.Height: Integer;

TTarget.Size

property TTarget.Size: TSize;

Returns the targets dimensions as in a TSize.


TTarget.Options

property TTarget.Options: TTargetOptions;

Returns options for the target. Mostly contains input options controlling speed of mouse/keyboard.

Example for changing the mouse speed:

Target.Options.MouseSpeed := 15;

TTarget.AddEvent

function TTarget.AddEvent(EventType: ETargetEvent; Event: TTargetEvent): Integer;

Add an event. Valid events are:

  • ETargetEvent.TARGET_CHANGE

  • ETargetEvent.TARGET_INVALID

  • ETargetEvent.TARGET_RESIZE

  • ETargetEvent.MOUSE_TELEPORT

  • ETargetEvent.MOUSE_BUTTON

Returns the index of the added event, use for RemoveEvent.


TTarget.RemoveEvent

procedure TTarget.RemoveEvent(EventType: ETargetEventType; Index: Integer);

TTarget.MouseTeleport

procedure TTarget.MouseTeleport(P: TPoint);

Instantly moves the mouse to P


TTarget.MouseClick

procedure TTarget.MouseClick(Button: EMouseButton);

TTarget.MouseDown

procedure TTarget.MouseDown(Button: EMouseButton);

TTarget.MouseUp

procedure TTarget.MouseUp(Button: EMouseButton);

TTarget.MouseScroll

procedure TTarget.MouseScroll(Scrolls: Integer);

TTarget.MousePressed

function TTarget.MousePressed(Button: EMouseButton): Boolean;

TTarget.MouseMove

procedure TTarget.MouseMove(Dest: TPoint);

Move the mouse in a “human-like” way. Speed, Gravity and Wind variables of Options variable affects this.

Note

The algorithm used is WindMouse. For more details see https://ben.land/post/2021/04/25/windmouse-human-mouse-movement


TTarget.MouseMove

procedure MouseMove(Box: TBox; ForcedMove: Boolean = False); overload;
procedure MouseMove(Quad: TQuad; ForcedMove: Boolean = False); overload;

MouseMove overloads. Use ForcedMove to determine if the mouse will still move if it’s already inside the box/quad.


TTarget.MouseXY

property TTarget.MouseXY: TPoint;
property TTarget.MouseXY(Value: TPoint);

TTarget.MouseX

property TTarget.MouseX: Integer;
property TTarget.MouseX(Value: Integer);

TTarget.MouseY

property TTarget.MouseY: Integer;
property TTarget.MouseY(Value: Integer);

TTarget.KeySend

procedure TTarget.KeySend(Text: String);

TTarget.KeyDown

procedure TTarget.KeyDown(Key: EKeyCode);

TTarget.KeyUp

procedure TTarget.KeyUp(Key: EKeyCode);

TTarget.KeyPress

procedure TTarget.KeyPress(Key: EKeyCode);

TTarget.KeyPressed

function TTarget.KeyPressed(Key: EKeyCode): Boolean;

TTarget.KeyCodeFromChar

function TTarget.KeyCodeFromChar(C: Char): EKeyCode;

TTarget.MatchColor

function TTarget.MatchColor(Color: TColor; ColorSpace: EColorSpace; Multipliers: TChannelMultipliers; Bounds: TBox): TSingleMatrix;

TTarget.FindColor

function TTarget.FindColor(Color: TColor; Tolerance: Single; Bounds: TBox = [-1,-1,-1,-1]): TPointArray;

TTarget.FindColor

function TTarget.FindColor(Color: TColorTolerance; Bounds: TBox = [-1,-1,-1,-1]): TPointArray;

TTarget.CountColor

function TTarget.CountColor(Color: TColor; Tolerance: Single; Bounds: TBox = [-1,-1,-1,-1]): Integer;

TTarget.CountColor

function TTarget.CountColor(Color: TColorTolerance; Bounds: TBox = [-1,-1,-1,-1]): Integer;

TTarget.HasColor

function TTarget.HasColor(Color: TColor; Tolerance: Single; MinCount: Integer = 1; Bounds: TBox = [-1,-1,-1,-1]): Boolean;

TTarget.HasColor

function TTarget.HasColor(Color: TColorTolerance; MinCount: Integer = 1; Bounds: TBox = [-1,-1,-1,-1]): Boolean; overload;

TTarget.GetColor

function TTarget.GetColor(P: TPoint): TColor;

TTarget.GetColors

function TTarget.GetColors(Points: TPointArray): TColorArray;

TTarget.GetColorsMatrix

function TTarget.GetColorsMatrix(Bounds: TBox = [-1,-1,-1,-1]): TIntegerMatrix;

TTarget.FindImage

function TTarget.FindImage(Image: TImage; Tolerance: Single; Bounds: TBox = [-1,-1,-1,-1]): TPoint;

TTarget.FindImage

function TTarget.FindImage(Image: TImage; Tolerance: Single; ColorSpace: EColorSpace; Multipliers: TChannelMultipliers; Bounds: TBox = [-1,-1,-1,-1]): TPoint;

TTarget.FindImageEx

function TTarget.FindImageEx(Image: TImage; Tolerance: Single; MaxToFind: Integer = -1; Bounds: TBox = [-1,-1,-1,-1]): TPointArray;

TTarget.FindImageEx

function TTarget.FindImageEx(Image: TImage; Tolerance: Single; ColorSpace: EColorSpace; Multipliers: TChannelMultipliers; MaxToFind: Integer = -1; Bounds: TBox = [-1,-1,-1,-1]): TPointArray;

TTarget.FindTemplate

function TTarget.FindTemplate(Image: TImage; out Match: Single; Bounds: TBox = [-1,-1,-1,-1]): TPoint;

TTarget.FindDTM

function TTarget.FindDTM(DTM: TDTM; Bounds: TBox = [-1,-1,-1,-1]): TPoint;

TTarget.FindDTMEx

function TTarget.FindDTMEx(DTM: TDTM; MaxToFind: Integer = 1; Bounds: TBox = [-1,-1,-1,-1]): TPointArray;

TTarget.FindDTMRotated

function TTarget.FindDTMRotated(DTM: TDTM; StartDegrees, EndDegrees: Double; Step: Double; out FoundDegrees: TDoubleArray; Bounds: TBox = [-1,-1,-1,-1]): TPoint;

TTarget.FindDTMRotatedEx

function TTarget.FindDTMRotatedEx(DTM: TDTM; StartDegrees, EndDegrees: Double; Step: Double; out FoundDegrees: TDoubleArray; MaxToFind: Integer = 1; Bounds: TBox = [-1,-1,-1,-1]): TPointArray;

TTarget.FindEdges

function TTarget.FindEdges(MinDiff: Single; ColorSpace: EColorSpace; Multipliers: TChannelMultipliers; Bounds: TBox = [-1,-1,-1,-1]): TPointArray;

TTarget.FindEdges

function TTarget.FindEdges(MinDiff: Single; Bounds: TBox = [-1,-1,-1,-1]): TPointArray;

TTarget.GetPixelDifference

function TTarget.GetPixelDifference(WaitTime: Integer; Bounds: TBox = [-1,-1,-1,-1]): TPointArray;

TTarget.GetPixelDifference

function TTarget.GetPixelDifference(WaitTime, Tolerance: Single; Bounds: TBox = [-1,-1,-1,-1]): TPointArray;

TTarget.AverageBrightness

function TTarget.AverageBrightness(Bounds: TBox = [-1,-1,-1,-1]): Integer;

TTarget.PeakBrightness

function TTarget.PeakBrightness(Bounds: TBox = [-1,-1,-1,-1]): Integer;