SCAR Code:
{*******************************************************************************
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,OptionBox: TBox;
TPA, TPA1, TPA2, TextTPA: TPointArray;
aTPA: T2DPointArray;
I, H, HH, ii, L: Integer;
Colors,SearchCols: TIntegerArray;
begin
Result := False;
GetClientDimensions(B.X2, B.Y2);
B.X1 := 0;
B.Y1 := 0;
Dec(B.X2);
Dec(B.Y2);
FindColorsTolerance(TPA1, 4016722, B.X1, B.Y1, B.X2, B.Y2, 0);
FindColorsTolerance(TPA2, 4409686, 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 := [13034990, 4231423, 2070783, 65535, 16776960, 9812166];
TextType := LowerCase(TextType);
case TextType of
'action', 'player': SearchCols := [0,5];
'item' : SearchCols := [1,2];
'npc' : SearchCols := [3];
'object': SearchCols := [4];
else
SearchCols := [0,1,2,3,4,5];
end;
L := High(SearchCols);
SetLength(aTPA,l+1);
for i := 0 to l do
FindColorsTolerance(aTPA[I], Colors[SearchCols[I]], B.X1, B.Y1, B.X2, B.Y2, 3);
TPA := MergeATPA(aTPA);
aTPA := SplitTPAEx(TPA, 7, 1);
L := High(aTPA);
H := High(Texts);
SortATPAFromFirstPoint(ATPA, Point(OptionBox.X1, optionbox.y1));
for I :=0 To H do
begin
TextTPA := LoadTextTPA(Texts[i], UpChars, HH);
for ii := 0 to L do
If FindTextTPAInTPA(HH, TextTPA, aTPA[ii], TPA) Then
begin
Result := True;
case Action of
ClickLeft: MouseBoxEx(B.x1 + 5, TPA[0].Y, B.x2 - 5, TPA[0].Y + 5,5, 1);
Move: MouseBoxEx(B.x1 + 5, TPA[0].Y, B.x2 - 5, TPA[0].Y + 5,5, 3);
Nothing: begin end;
else
srl_warn('ChooseOptionMultiEx', 'ClickRight not a valid click for RS menus!', warn_AllVersions);
end;
Exit;
end;
end;
MMouse(B.X1 - 50, B.Y1 - 50, 40, B.Y2 - B.Y1);
Wait(200 + Random(100));
end;