Skip to content

ScriptBase Class

Komefai edited this page Oct 5, 2017 · 6 revisions

ScriptBase class provides functionalities for scripting and an entry-point for PS4 Macro

Syntax

public abstract class ScriptBase

Basic Methods

These are the frequently used basic methods that will help you get started with scripting quickly. They can be chained together for convenience.


Press

public ScriptBase Press(DualShockState state, int delay = DEFAULT_PRESS_BUTTONS_DELAY)

Press/hold button combinations for the specified amount of time.


SetButtons

public ScriptBase SetButtons(DualShockState state)

Set buttons manually.


ClearButtons

public ScriptBase ClearButtons()

Reset buttons manually.


Sleep

public ScriptBase Sleep(int timeout, int checkInterval = DEFAULT_SLEEP_CHECK_INTERVAL)

Wait and block execution for an amount of time.


Suspend

public ScriptBase Suspend(int delay)

Disable Update() for an amount of time.


PlayMacro

public ScriptBase PlayMacro(List<DualShockState> sequence, int suspendDelay = 0)
public ScriptBase PlayMacro(string path, int suspendDelay = 0)

Play a macro.


StopMacro

public ScriptBase StopMacro()

Stop the playing macro.



Advanced Methods

These are methods for advanced scripting.


CaptureFrame

public Bitmap CaptureFrame()

Take a screenshot of PS4 Remote Play as Bitmap.

CropFrame

public Bitmap CropFrame(Bitmap frame, Rectangle rect)
public Bitmap CropFrame(Rectangle rect)

Crop a Bitmap image.


GetPixel

public int GetPixel(Bitmap frame, int x, int y)
public int GetPixel(int x, int y)

Get a pixel color from an image. Returns color as int (eg. WHITE = 0xFFFFFF = 16777215).


MatchTemplate [Pixel]

public bool MatchTemplate(Bitmap frame, int x, int y, int color, int tolerance = DEFAULT_PIXEL_TOLERANCE)
public bool MatchTemplate(int x, int y, int color, int tolerance = DEFAULT_PIXEL_TOLERANCE)
public bool MatchTemplate(Bitmap frame, PixelMap pixel, int tolerance = DEFAULT_PIXEL_TOLERANCE)
public bool MatchTemplate(PixelMap pixel, int tolerance = DEFAULT_PIXEL_TOLERANCE)

Match a pixel template within an image. Tolerance is how much difference in the RGB space are allowed between the source and the template. For example, 0xFFFFFF (R: 255, G: 255, B: 255) vs 0xFEFFFE (R: 254, G: 255, B: 254) has a difference of 2, so a tolerance of 2 or more will pass the match test.


MatchTemplate [Rectangle]

public bool MatchTemplate(Bitmap frame, Rectangle rect, ulong targetHash, double similarity = DEFAULT_RECT_TOLERANCE)
public bool MatchTemplate(Rectangle rect, ulong targetHash, double similarity = DEFAULT_RECT_TOLERANCE)
public bool MatchTemplate(Bitmap frame, RectMap rect, double similarity = DEFAULT_RECT_TOLERANCE)
public bool MatchTemplate(RectMap rect, double similarity = DEFAULT_RECT_TOLERANCE)

Match a rectangle template within an image using Perceptual Hash. Similarity is a scale from 0.00% to 100.00%.