Skip to main content
Version: 1.0.6

Wrappers

Wrapper classes serve as the interface between Brobot and other libraries that perform real operations. The typical Brobot application will not call Wrappers directly.

All Wrappers handle real and mock operations. If mocking is active, a mock will be performed. When mocking is not active, operations will be carried out using modules that perform a real action. If the class is a Sikuli Wrapper, it will call Sikuli methods. If the class is another type of Wrapper, it will call some other module's methods that perform real actions.

Classes above the Wrapper layer do not know if the application is returning mocked or real results.

Sikuli Wrappers

Findโ€‹

FindFirstPatternโ€‹

Returns the results, contained in a Matches object, for the first Pattern found in a Brobot Image, which itself may contain multiple Patterns.

Matches find(Region region, StateImageObject stateImageObject, Image image, ActionOptions actionOptions)

FindAllPatternsโ€‹

Finds all matches for all Patterns in the Brobot Image. When used by a Find.ALL operation, all matches are returned in the Matches object. When used by a Find.BEST operation, only the match with the highest score is kept.

Matches find(Region region, StateImageObject stateImageObject, Image image, ActionOptions actionOptions)

Mouseโ€‹

ClickLocationOnceโ€‹

Performs a full click once, with pauses, mouse down, and mouse up.

boolean click(Location location, ActionOptions actionOptions)

MouseDownWrapperโ€‹

Presses and holds a mouse button.

boolean press(double pauseBeforeBegin, double totalPause, ClickType.Type type)

MouseUpWrapperโ€‹

Releases a mouse button.

boolean press(double pauseBefore, double pauseAfter, ClickType.Type type)

MouseWheelโ€‹

Scrolls the mouse wheel up or down.

boolean scroll(ActionOptions actionOptions)

MoveMouseWrapperโ€‹

Moves the mouse to a given Location.

boolean move(Location location)

Textโ€‹

GetTextWrapperโ€‹

Finds text on-screen and stores it in the Matches object. Can find text for all Image matches or for a StateRegion.

void allText(Matches matches, Image image) void text(Matches matches, StateRegion stateRegion)

KeyDownWrapperโ€‹

Holds a Key down. Special keys such as CTRL or ENTER are specified by an integer value.

void press(String key) void press(int key)

KeyUpWrapperโ€‹

Methods for releasing all keys or a specific key.

void release() void release(String key) void release(int key)

TypeTextWrapperโ€‹

Types a String to the focused window.

boolean type(StateString stateString, ActionOptions actionOptions)

Other Functionsโ€‹

Appโ€‹

Gets the window of the App in focus. When mocking is active, it will return a mock window.

Optional<Region> focusedWindow()

DragLocationโ€‹

Drags from one Location to another Location.

Typical settings:

  • 0.3 PauseBeforeMouseDown
  • 0.3 PauseAfterMouseDown
  • 0.5 MoveMouseDelay
  • 0.4 PauseBeforeMouseUp
  • 0.0 PauseAfterMouseUp

boolean drag(Location from, Location to, ActionOptions actionOptions)

HighlightMatchโ€‹

Highlights a Match with a given color. It's possible to turn on a highlight, turn off a highlight, or show a highlight for a given number of seconds.

void turnOn(Match match, StateObject stateObject, ActionOptions actionOptions) void turnOff(Match match) boolean highlight(Match match, StateObject stateObject, ActionOptions actionOptions)

Waitโ€‹

Pauses for a given number of seconds.

void wait(double seconds)

Other Wrappers

TimeWrapperโ€‹

Wraps the Time functions to allow for mocking actions. Keeps track of the mocked value of 'now' and performs mocked pauses.

Variables

private LocalDateTime now keeps track of the current mock time.

Methods

LocalDateTime now()
void wait(double seconds)
void wait(ActionOptions.Action action)
void wait(ActionOptions.Find find)
void printNow()
void goBackInTime(double years, Object thingsYouWishYouCouldChange)