you can add add this to your script.....
var g_metadb = fb.GetFocusItem();
function on_item_focus_change() {
if (g_metadb) window.UnwatchMetadb();
g_metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();
if (g_metadb) {
on_metadb_changed();
window.WatchMetadb(g_metadb);
}
}
function on_playlist_switch() {
on_item_focus_change();
}
function on_metadb_changed() {
if(!g_metadb) return;
//you need to move your buttons declaration into here
Buttons = {
but1: new Button(0,0,bw,bh, {normal: images + "stop.png", hover: images + "stop_h.png"}, function(){fb.Stop();}, "Stop"),
but2: new Button(bw,0,bw,bh, {normal: images + "pause.png", hover: images + "pause_h.png"}, function(){fb.Pause();}, "Pause"),
but3: new Button(bw*2,0,bw,bh, {normal: images + "play.png", hover: images + "play_h.png"}, function(){fb.Play();}, "Play"),
but4: new Button(bw*3,0,bw,bh, {normal: images + "previous.png", hover: images + "previous_h.png"}, function(){fb.Prev();}, "Previous"),
but5: new Button(bw*4,0,bw,bh, {normal: images + "next.png", hover: images + "next_h.png"}, function(){fb.Next();}, "Next")
};
}
function on_playback_new_track() {
on_item_focus_change();
}
on_item_focus_change();
you need to use this as your function
fb.RunContextCommandWithMetadb("context menu command goes here", g_metadb);
also, be aware that WSH panel mod can only run commands on the selected/playing item only and not a selection.