I can't make it, foobar constantly crashes or doesn't show the menu:
var MF_SEPARATOR = 0x00000800;
var MF_STRING = 0x00000000;
var MF_POPUP = 0x00000010;
var c_man = fb.CreateContextMenuManager();
var m_man = fb.CreateMainMenuManager();
var g_handle = fb.GetFocusItem();
function on_mouse_lbtn_down(x, y) {
var _base = window.CreatePopupMenu();
var _file = window.CreatePopupMenu();
var _edit = window.CreatePopupMenu();
var _view = window.CreatePopupMenu();
var _play = window.CreatePopupMenu();
var _lib = window.CreatePopupMenu();
var _help = window.CreatePopupMenu();
var _playing = window.CreatePopupMenu();
var _select = window.CreatePopupMenu();
var ret;
_base.AppendMenuItem(MF_STRING | MF_POPUP, _file.ID, "File");
_base.AppendMenuItem(MF_STRING | MF_POPUP, _edit.ID, "Edit");
_base.AppendMenuItem(MF_STRING | MF_POPUP, _view.ID, "View");
_base.AppendMenuItem(MF_STRING | MF_POPUP, _play.ID, "Playback");
_base.AppendMenuItem(MF_STRING | MF_POPUP, _lib.ID, "Library");
_base.AppendMenuItem(MF_STRING | MF_POPUP, _help.ID, "Help");
_base.AppendMenuSeparator();
_base.AppendMenuItem(MF_STRING | MF_POPUP, _select.ID, "Selection");
_base.AppendMenuItem(MF_STRING | MF_POPUP, _playing.ID, "Now Playing");
m_man.Init("File");
m_man.BuildMenu(_file, 1, 32);
m_man.Init("File");
m_man.BuildMenu(_file, 33, 64);
m_man.Init("Edit");
m_man.BuildMenu(_edit, 65, 96);
m_man.Init("View");
m_man.BuildMenu(_view, 97, 128);
m_man.Init("Playback");
m_man.BuildMenu(_play, 129, 160);
m_man.Init("Library");
m_man.BuildMenu(_lib, 161, 192);
m_man.Init("Help");
m_man.BuildMenu(_lib, 193, 224);
c_man.InitContext(g_handle);
c_man.BuildMenu(_select, 225, -1);
c_man.InitNowPlaying();
c_man.BuildMenu(_playing, 226, -1);
ret = _base.TrackPopupMenu(x, y);
if (ret == 0)
return;
if (ret >= 1 && ret <= 32) {
m_man.ExecuteById(ret - 1);
}
if (ret >= 33 && ret <= 64) {
m_man.ExecuteById(ret - 33);
}
if (ret >= 65 && ret <= 96) {
m_man.ExecuteById(ret - 65);
}
if (ret >= 97 && ret <= 128) {
m_man.ExecuteById(ret - 97);
}
if (ret >= 129 && ret <= 160) {
m_man.ExecuteById(ret - 129);
}
if (ret >= 161 && ret <= 192) {
m_man.ExecuteById(ret - 161);
}
if (ret >= 193 && ret <= 224) {
m_man.ExecuteById(ret - 193);
}
if (ret == 225) {
c_man.ExecuteById(ret - 225);
}
if (ret == 226) {
c_man.ExecuteById(ret - 226);
}
m_man.Dispose();
c_man.Dispose();
}