GetMenuItems
Retrieve all items for menu with Caption - as strings.
Returns nothing if no active menu or menu with selected caption not found or char disconnected.
Similar methods: GetLastMenuItems and GetMenuItemsEx.
Warning: param (with type TStringList) should be created before calling GetFindedList and be disposed after!
NB: DWS have overloaded method version, which returns array of string and dont need any init before.
procedure GetMenuItems(Caption : String; var TL : TStringList);
procedure GetMenuItems(Caption : String; var TL : TStringList);
function GetMenuItems(Caption : String) : TArray<String>;
Pascal Example:
var
menu : TStringList;
i : Integer;
const animals = 'Llama|Shelby|Ostard|Mustang|Steed|Desolator|Nightmare|Unicorn';
function Contains(text, pattern : string) : boolean;
var
stringList : TStringList;
i : integer;
begin
stringList := TStringList.Create;
result := false;
StrBreakApart(pattern, '|', stringList);
for i := 0 to stringList.Count - 1 do
begin
if (BMSearch(1, UpperCase(text), UpperCase(stringList.Strings[i])) > 0) then
begin
result := true;
break;
end;
end;
stringList.Free;
end;
Begin
if (MenuPresent()) then
begin
menu := TStringList.Create();
GetMenuItems('Tracking', menu);
for i := 0 to menu.Count - 1 do
begin
if Contains(menu[i], animals) then
begin
DiscordMessenger.SendMessage('FOUND ' + menu[i] + ' , my position: ' + IntToStr(GetX(Self())) + ', ' + IntToStr(GetY(Self())), chatGame);
break;
end;
end;
menu.Free();
end;
End.
Python Syntax:
def GetMenuItems(): --> list of string