You can also address menus by numbers..
Aliases.YourApplication.YourMainForm.MainMenu.Click('[0|0]');
Numbers are 0 based so above clicks first item in first menu.
But honestely, if something changes that is quite pain in the ....
I don't know if this helps anything but i'll tell anyhow..
I have made an published procedure ClikMenuByCaption to our mainform.
Because for reason or other TC doesn't find items from our menu (it's TTmsAdvMenu).
If you have translations available at runtime you could try to translate text and find with that.
to access this you must have *.tds files
function TSKJMainForm.ClickMenuByCaption(const MenuCaption: string): Boolean;
var
i: Integer;
Item: TMenuItem;
begin
Result := False;
Item := nil;
if menucaption <>'' then
begin
for i:=1 to WordCountL(MenuCaption,'|') do
begin
if i=1 then
item:= OurMainMenu.Items.Find(ExtractWordL(1,MenuCaption,'|'))
else
begin
if assigned(item) then
item:=item.Find(ExtractWordL(i,MenuCaption,'|'))
else
break;
if (i=Integer(WordCountL(MenuCaption,'|'))) and assigned(item) then
begin
Result := True;
SendMessage(Self.Handle,WM_COMMAND,Item.Command,0);
Exit;
end;
end;
end;
end;
end;