Text

The text file holds functions and procedures that are used in Runescape text recognition.

The source for this file can be found here.

var ocr

An instance of SimpleOCR.

containsMatch

function containsMatch(needle, haystack: string; match: extended; caseSensitive: boolean = true): extended;

Finds a string within a string and returns the match percentage as an extended (0.00 - 1.00).

  • needle: The text to look for.
  • haystack: The string it searches in.
  • match: Extended match treshold.
  • caseSensitive: Optional boolean, self explanatory.

Note

  • by Thomas
  • Last Updated: 29 June 2016 by Thomas

Example:

var
  option: string;
begin
  option := 'Silly tesseract: Take Abyss4lWh1p from ground';
  if containsMatch('Take Abyssal Whip', option) > 0.75 then
    writeLn('Found a whip');
end.

containsMatch

function containsMatch(needle, haystack: string; match: extended; caseSensitive: boolean = true): boolean; overload;

Overloaded function. Finds a string within a string, with a match threshold. Returns true if the text is found.

  • needle: The text to look for.
  • haystack: The string it searches in.
  • caseSensitive: Optional boolean, self explanatory.

Note

  • by Thomas
  • Last Updated: 29 June 2016 by Thomas

Example:

var
  option: string;
begin
  option := 'Silly tesseract: Take Abyss4lWh1p from ground';
  if containsMatch('Take Abyssal Whip', option, 0.75) then
    writeLn('Found a whip');
end.

findText

function findText(var p: TPoint; txt, fonts: TStringArray; searchBox: TBox): boolean;

Uses a bitmap mask to find text on the screen. Returns true if the text is found.

  • p: The point the text is found.
  • txt: The text to look for.
  • fonts: The font(s) of the text.
  • searchBox: The box to look for the text.

Note

  • by Stupid3ooo, modified by LordJashin & Coh3n
  • Last Updated: 2 July 2015 by The Mayor

Example:

var
  p: TPoint;
begin
  if findText(p, ['Lobby'], [upCharsEx], options.getBounds()) then
    writeln('Found "Exit to Lobby" text');

end;

findText; overload;

function findText(var p: TPoint; col, tol: integer; txt, fonts: TStringArray; lookIn: TBox; waitTime: integer = 0): boolean; overload;

Uses TPointArrays to find text on the screen. Searches for the color (col) with tolerance (tol) on the screen, then looks for the text (txt) in a TPA created from the fonts (fonts). Looks in the box (lookIn) and returns the point found (p). Returns true if the text is found. If the optional parameter (waitTime) is set, will wait specified amount of time for the text to be found before returning false.

Note

  • by Raymond and Coh3n
  • Last Updated: 20 Feb 2013 by Coh3n

Example:

var
  p: TPoint;
begin
  if findText(p, clWhite, 10, ['Lobby'], [upCharsEx], settings.getBounds(), 5000) then
    writeln('Found "Exit to Lobby" text');

end;

extractTextFromTPA

function extractTextFromTPA(tpa: TPointArray; minvspacing, maxvspacing, hspacing: integer; font: string): string;

Returns the text found inside a TPA. The parameters are the following:

  • tpa: the TPA of potential text
  • minvspacing: Minimum vertical letter spacing
  • maxvspacing: Maximum vertical letter spacing
  • hspacing: Horozontal letter spacing
  • font: The font of the text

Note

  • by Coh3n
  • Last Updated: 1 March 2013 by Coh3n

Example:

extractTextFromTPA(tpa, 6, 10, 8, 'upChars');

mouseText

function mouseText(txt, fonts: TStringArray; searchBox: TBox; mouseAction: integer): boolean;

Returns true if the mouse action is performed on the text.

  • txt: The text to look for.
  • fonts: The font(s) of the text.
  • searchBox: The box to look for the text.
  • mouseAction: The action of the mouse.

Note

  • by Coh3n
  • Last Updated: 1 March 2013 by Coh3n

Example:

mouseText(['Lobby'], [upCharsEx], tabLogout.bounds, MOUSE_LEFT);

typeByte

procedure typeByte(k: byte);

Types one character k.

Note

  • by Mutant Squirrle

Example:

typeByte(VK_ENTER);

typeByteWait

procedure typeByteWait(key: Byte; waitTime: integer);

Holds down the desired key for the set waitTime.

Note

  • by Ollybest

Example:

typeByteWait(vk_up, 800 + random(200));

typeSend

procedure typeSend(text: string; pressEnter: boolean = true);

Types text in a human-like way. Optional parameter ‘pressEnter’. Will press enter by default.

Note

  • by SKy Scripter
  • Last Updated: 29 January 2013 by Coh3n

Example:

// to type and press enter
typeSend('Hello');

// to type and not press enter
typeSend('Hello', false);

multiType

function multiType(text: string; chance, maxSends: integer; pressEnter: boolean = true): boolean;

Will simulate “spam” typing of the string ‘text’. It will repeat a random amount between 1 and ‘maxSends’. It will always type once, and then has a percent ‘chance’ of typing again. Will not exceed ‘maxSends’.

Note

  • Author: Ashaman88
  • Last Updated: 7 May 2014 by Ashaman88

Example:

if isMouseOverText('Party hat') then
  multiType('woot', 35, 5);

multiType

function multiType(k: byte; chance, maxSends: integer; pressEnter: boolean = true): boolean; overload;

Overload for the other multiType, but uses bytes for the key sending

Note

  • Author: Ashaman88
  • Last Updated: 7 May 2014 by Ashaman88

Example:

if (mainscreen.isUptext('Tree')) then
  multiType(VK_SPACE, 35, 5);

getMouseOverText

function getMouseOverText(): string;

Returns the current mouse-over text.

Note

  • by euphemism & Coh3n
  • Last Modified: 12 August 2013 by Coh3n

Example:

writeln(getMouseOverText());

isMouseOverText

function isMouseOverText(txt: TStringArray; waitTime: integer = 200): boolean;

Returns true if one of the indexes in ‘txt’ is found in the current mouse-over text. Will wait up to ‘waitTime’ to find the text before exiting the function.

Note

  • by Coh3n
  • Last Modified: 12 August 2013 by Coh3n

Example:

if isMouseOverText(['Tree']) then
begin
  getMousePos(x, y);
  mouse(point(x, y), MOUSE_LEFT);
end;

isMouseOverMenuOpen

function isMouseOverMenuOpen(var res: TBox; waitTime: integer = 100): boolean;

Returns true if the mouse-over menu is open. Will wait a maximum of ‘waitTime’ for the menu to appear.

Note

  • by Coh3n
  • Last Modified: 12 August 2013 by Coh3n

Example:

if isMouseOverMenuOpen(box) then
  writeln('Mouse-over menu is open');

getUpText

function getUpText(): string;

Returns the current UpText (the text in the top-left corner of the screen).

Note

  • by slacky & KeepBotting
  • Last Modified: 27 February 2016 by KeepBotting

Example:

writeLn(getUpText());

isUpText

function isUpText(txt: string; waitTime: integer = 100): boolean;

Returns true if the string ‘txt’ is found in the current UpText. Will wait up to ‘waitTime’ to find the text before exiting the function.

Note

  • by KeepBotting
  • Last Modified: 27 February 2016 by KeepBotting

Example:

if isUpText('Banker') then writeLn('Found the bank!');

isUpText

function isUpText(txt: TStringArray; waitTime: integer = 100): boolean; overload;

Overloaded function. Takes a TStringArray instead of a string.

Returns true if any one of the indicies in ‘txt’ is found in the current UpText. Will wait up to ‘waitTime’ to find the text before exiting the function.

Note

  • by KeepBotting
  • Last Modified: 27 February 2016 by KeepBotting

Example:

if isUpText(['Bank', 'Banker', 'Booth']) then writeLn('Found the bank!');