This is kinda proof of the concept.
It can invoke other app's MenuBar directly from AHK.
And, can be used as another way to invoke AHK's TrayMenu too.
Code:
#NoTrayIcon
#NoEnv
TPM_RECURSE = 0x0001
TPM_NONOTIFY = 0x0080
TPM_RETURNCMD = 0x0100
DetectHiddenWindows, On
WinGet, hWnd, ID, ahk_class Notepad
WinGet, hAHK, ID, ahk_class AutoHotkey
CoordMode, Mouse, Screen
MouseGetPos, xpos, ypos
nIndex := 1 ; 1-based index of the SubMenu. If 0 or omitted, thin bar will appear.
;hWnd := hAHK ; will get AHK's TrayMenu
hMenu := DllCall("GetMenu", "Uint", hWnd)
If nIndex
hMenu := DllCall("GetSubMenu", "Uint", hMenu, "int", nIndex - 1)
WinActivate, ahk_id %hAHK%
nID := DllCall("TrackPopupMenu", "Uint", hMenu
, "Uint", TPM_RECURSE | TPM_NONOTIFY | TPM_RETURNCMD
, "int", xpos, "int", ypos, "int", 0, "Uint", hAHK, "Uint", 0)
PostMessage, 0x111, nID, 0, , ahk_id %hWnd% ; WM_COMMAND
MsgBox, Done