Simba Code:
Type
TOptions = Record
Str: string;
Bounds: TBox;
end;
Function GetChooseOptions(TextType: string): Array of TOptions;
var
B: TBox;
TPA, TPA1, TPA2: TPointArray;
aTPA, tempatpa: T2DPointArray;
I, L: Integer;
Colors: TIntegerArray;
begin
GetClientDimensions(B.X2, B.Y2);
B.X1 := 0;
B.Y1 := 0;
Dec(B.X2);
Dec(B.Y2);
FindColorsTolerance(TPA1, 4343893, B.X1, B.Y1, B.X2, B.Y2, 0);
FindColorsTolerance(TPA2, 3950929, B.X1, B.Y1, B.X2, B.Y2, 0);
TPA := CombineTPA(TPA1, TPA2);
If Length(TPA) < 10 Then
Exit;
B.X2 := 0;
B.Y2 := 0;
aTPA := SplitTPAEx(TPA, 20, 20);
SortATPASize(aTPA, True);
B := GetTPABounds(aTPA[0]);
Colors := [460034];
SetLength(aTPA, Length(Colors));
for i := 0 to High(Colors) do
FindColorsTolerance(aTPA[i], Colors[i], B.X1, B.Y1, B.X2, B.Y2, 5);//yes shadows owns, only 1 color
TPA := MergeATPA(aTPA);
aTPA := SplitTPAEx(TPA, 15, 2);
L := High(aTPA);
SortATPAFromFirstPoint(ATPA, Point(B.X1, B.y1));
SetArrayLength(Result, Length(ATPA));
for i := 0 to high(ATPA) do
begin
TPA := ATPA[i];
tempatpa := SplitTPAEx(TPA, 2, 10); // Split one into characters
SortTPAFrom(TPA, Point(0, 0)); // Sort SplitTPA messes stuff up
SortATPAFromFirstPoint(tempatpa, TPA[0]); // More Sort
Result[i].Str := GetTextATPA(tempatpa, 5, 'SmallCharsNS_s'); // Replace this with 'SmallChars' for non shadow OCR
Result[i].Bounds := GetTPABounds(ATPA[i]);
writeln(Result[i].Str);
setlength(tempatpa,0);
setlength(TPA,0);
end;
end;
{*******************************************************************************
function ChooseOptionMultiEx(Texts: TStringArray; TextType: String; Action: fnct_ActionOptions): Boolean;
By: Wizzup?, Nava2, and N1ke!
Description: Finds Popup menu, then clicks on it.
Will look for the first string first and so on.
It will search for the Text Type you input valid arguments are
'action', 'player': The white text
'npc': The yellow text
'object': The cyan text
'all': Searches for all colors of text.
Will default to 'all'.
*******************************************************************************}
function ChooseOptionMultiEx(Texts: TStringArray; TextType: String; Action: fnct_ActionOptions): Boolean;
var
B: TBox;
I, H, ii, L: Integer;
Options: array of TOptions;
begin
Result := False;
Options := GetChooseOptions(TextType);
H := High(Options);
L := High(Texts);
for I := 0 To H do
begin
for ii := 0 to L do
If Pos(Texts[ii], Options[I].Str) > 0 Then
begin
Result := True;
B := Options[I].Bounds;
case Action of
ClickLeft: MouseBoxEx(B.x1 + 5, B.Y1, B.x2 - 5, B.Y1 + 5,5, 1);
Move: MouseBoxEx(B.x1 + 5, B.Y1, B.x2 - 5, B.Y1 + 5,5, 3);
Nothing: begin end;
else
srl_warn('ChooseOptionMultiEx', 'ClickRight not a valid click for RS menus!', warn_AllVersions);
end;
Exit;
end;
end;
if Action <> Nothing then
begin
MMouse(B.X1 - 50, B.Y1 - 50, 40, B.Y2 - B.Y1);
Wait(200 + Random(100));
end;
if (not result) then
ChooseOptionMultiEx(['Cancel', 'ancel', 'ncel'], 'All', clickLeft);
end;