Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: WSH Panel Mod (Read 815517 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

WSH Panel Mod

Reply #975
T.P Wang
Thank you very much! Great update. Will try.

WSH Panel Mod

Reply #976
WSH Panel Mod 1.4.0 Beta released.
Changelog:
Quote
v1.4.0 Beta 1
- ADD: New IFbMetadbHandleList interface for a list of metadb handles.
- ADD: fb.GetSelections() method.
- CHG: fb.RunContextCommandWithMetadb() now accept IFbMetadbHandleList.
- ADD: Autoplaylist functions: fb.IsAutoPlaylist(), fb.CreateAutoPlaylist() and fb.ShowAutoPlaylistUI().
- FIX: Script crashes with themes API while changing Windows themes.
- ADD: UI improvements.



going to play NOW! thanx for this unexpected (i mean so fast btw!) answer

feedback a.S.a.P ~

WSH Panel Mod

Reply #977
Autoplaylist functions: fb.IsAutoPlaylist(), fb.CreateAutoPlaylist() and fb.ShowAutoPlaylistUI() works perfectly !!! thanx a lot

WSH Panel Mod

Reply #978
some remarks on Scintilla embedded:

^F - Find dialog - enter query - press Return - nothing

it seems dialog has focus, and default Find button is highlighted, but I just have to use mouse to make it work. Same for ^H, thou works fine on ^G (there is OK button)

Also Esc doesn't close any of Scintilla dialogs

WSH Panel Mod

Reply #979
@romor:
1.4.0 Beta 1 have fixed those issues, hopefully.

WSH Panel Mod

Reply #980
could it be possible to add too an interface to retreive the query of an AutoPlaylist ? and (in priority) a way to re-order playlists idx (maybe a SwapPlaylist() function ?

WSH Panel Mod

Reply #981
Found a bug:
fb.RunContextCommandWithMetadb("Open containing folder", metadb); now crashes if metadb is not a list.
Very strange.

And can we get one metadb handle from the list?

P.S. Foobar2000 1.1 version.

WSH Panel Mod

Reply #982
WSH Panel Mod 1.4.0 Beta 2 is released.
Code: [Select]
v1.4.0 Beta 2
- ADD: New preprocessor directive "feature" (Preprocessors.txt).
- ADD: More methods added to IFbMetadbHandleList interface.
- CHG: IContextMenuManager.InitContext() now accept IFbMetadbHandleList.
- FIX: Possible memory leaks and script crashes in fb.RunContextCommandWithMetadb(), introduced in 1.4.0 Beta 1.
- FIX: minor fixes.

WSH Panel Mod

Reply #983
could it be possible to add too an interface to retreive the query of an AutoPlaylist ? and (in priority) a way to re-order playlists idx (maybe a SwapPlaylist() function ?

   // [1.3.2] New:
   boolean MovePlaylist(from, to);

feel stupid, sorry!

WSH Panel Mod

Reply #984
After using Sort() method for metadb list it seems to be empty (or Count doesn't work).
Count and Item(idx) functions work very well with not sorted list. RunContextCommandWithMetadb(...) works good too.
Thanks!

WSH Panel Mod

Reply #985
Quote
After using Sort() method for metadb list it seems to be empty (or Count doesn't work).


I can't reproduce that, can you please provide your script which cause that problem?

WSH Panel Mod

Reply #986
T.P Wang, here is code:

Code: [Select]
//WSH Button panel by Zin-Uru, 2010
//24.10.2010 version

var img_path;
var settings_path;
var meta_mode;
var show_tip;

//Button type
var btn_type;

var image_null;
var image_hover;

//For play-pause, stop-after, mood, skip and option buttons
var image_null_add;
var image_hover_add;

//For playback order button
var image_null_rp;
var image_null_rt;
var image_null_r;
var image_null_st;
var image_null_sa;
var image_null_sf;

var image_hover_rp;
var image_hover_rt;
var image_hover_r;
var image_hover_st;
var image_hover_sa;
var image_hover_sf;

//Option
var option_name,option_value;
var tip_name;
var switch_to_0;

//Globals
var smooth = window.GetProperty("Smooth hover effect",true);
var on_hover = false;
var on_hover_chk = false;
var clicked = false;
var leave = false;
var btn_alpha_max = window.GetProperty("Button alpha","180")*1;
var btn_alpha;

var timer;
var timer_interval = 20;
var counter = 0;

var meta,meta_focus,mood,skip,va;
var tooltip = window.CreateTooltip();

var artist,album,title;
var WshShell = new ActiveXObject("WScript.Shell");
var FSO = new ActiveXObject("Scripting.FileSystemObject");
var special = false;

function set_tooltip_text() {
switch (btn_type) {
case 1:
tooltip.Text = "Play/Pause";
break;
case 2:
tooltip.Text = "Stop";
break;
case 3:
tooltip.Text = "Next track";
break;
case 4:
tooltip.Text = "Previous track";
break;
case 5:
tooltip.Text = "Focus now playing item";
break;
case 6:
tooltip.Text = "Open file(s)";
break;
case 7:
tooltip.Text = "Choose playback order";
break;
case 8:
tooltip.Text = "Set stop after current on/off";
break;
case 9:
tooltip.Text = "Change mood status";
break;
case 10:
tooltip.Text = "Set/remove skip on/from track";
break;
case 11:
tooltip.Text = "Popup main menu";
break;
case 12:
tooltip.Text = "Last.fm artist page";
break;
case 13:
tooltip.Text = "Google search for artist art";
break;
case 14:
tooltip.Text = "Wikipedia artist info";
break;
case 15:
tooltip.Text = "Google search for album art";
break;
case 16:
tooltip.Text = "Search for YouTube videos";
break;
case 17:
tooltip.Text = "Visit Hydrogenaudio official Foobar2000 forum";
break;
case 18:
tooltip.Text = "Open file containing folder";
break;
case 19:
tooltip.Text = "Open Preferences page";
break;
case 20:
tooltip.Text = "Google search for artist";
break;
case 21:
tooltip.Text = "Increase window height";
break;
case 22:
tooltip.Text = "Decrease window height";
break;
case 23:
tooltip.Text = "Increase window width";
break;
case 24:
tooltip.Text = "Decrease window width";
break;
case 25:
tooltip.Text = "Open Audio CD";
break;
case 26:
tooltip.Text = "Random track";
break;
case 27:
tooltip.Text = "Send to device";
break;
case 28:
tooltip.Text = "Switch " + replace_symbol(option_name,"_"," ") + " to " + tip_name[option_value-1];
break;
case 29:
tooltip.Text = "Load playlist";
break;
case 30:
tooltip.Text = "Remove playlist";
break;
case 31:
tooltip.Text = "Create new playlist";
break;
case 32:
tooltip.Text = "Rename playlist";
break;
case 33:
tooltip.Text = "Save playlist";
break;
case 34:
tooltip.Text = "Save all playlists";
break;
case 35:
tooltip.Text = "Open Playlist Manager";
break;
case 36:
tooltip.Text = "Copy file (name(s)) to clipboard";
break;
case 37:
tooltip.Text = "Send file(s) to playlist";
break;
case 38:
tooltip.Text = "Remove dead items";
break;
case 39:
tooltip.Text = "Remove duplicates";
break;
case 40:
tooltip.Text = "Set or remove Various Artists tag to file";
break;
}
}

function file_exists(path) {
  var file = new ActiveXObject("Scripting.FileSystemObject");
 
  return file.FileExists(path);
}

function folder_exists(path) {
  var folder = new ActiveXObject("Scripting.FileSystemObject");
 
  return folder.FolderExists(path);
}

function drive_exists(path) {
  var drive = new ActiveXObject("Scripting.FileSystemObject");
 
  return drive.DriveExists(path);
}

function create_folder(path) {
var folder = new ActiveXObject("Scripting.FileSystemObject");
var drive = path.substring(0,path.indexOf("\\")+1);
var fold = drive;
var work_path = path.replace(drive,"") + "\\";

while (work_path.lastIndexOf("\\")!=-1) {
fold = fold + work_path.substring(0,work_path.indexOf("\\")+1);
if(!folder.FolderExists(fold)) folder.CreateFolder(fold);
work_path = work_path.substring(work_path.indexOf("\\")+1,work_path.length);
}

}

function fix_russian_text(str) {
var work_str = "";
var rus;
var alphabet = "абвгдеёжзийклмнопрстуфхцчшщъыьэюяАБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ";
var codes = "%D0%B0%D0%B1%D0%B2%D0%B3%D0%B4%D0%B5%D1%91%D0%B6%D0%B7%D0%B8%D0%B9%D0%BA%D0%BB%D0%BC%D0%BD%D0%BE%D0%BF%D1%80%D1%81%D1%82%D1%83%D1%84%D1%85%D1%86%D1%87%D1%88%D1%89%D1%8A%D1%8B%D1%8C%D1%8D%D1%8E%D1%8F%D0%90%D0%91%D0%92%D0%93%D0%94%D0%95%D0%81%D0%96%D0%97%D0%98%D0%99%D0%9A%D0%9B%D0%9C%D0%9D%D0%9E%D0%9F%D0%A0%D0%A1%D0%A2%D0%A3%D0%A4%D0%A5%D0%A6%D0%A7%D0%A8%D0%A9%D0%AA%D0%AB%D0%AC%D0%AD%D0%AE%D0%AF";

for(var i = 0; i < str.length; i++) {
for(var j = 0; j < alphabet.length; j++) {
if(str.charAt(i)==alphabet.charAt(j)) {
work_str = work_str + codes.substring(j*6,(j+1)*6);
rus = true;
break;
}  else {
rus = false;
}
}
if(!rus) work_str = work_str + str.charAt(i);
}
return work_str;
}

function fix_russian_text2(str) {
var work_str = str;
var alphabet1 = "абвгдеёжзийклмнопрстуфхцчшщъыьэюяАБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ";
var alphabet2 = " ЎўЈ¤Ґс¦§Ё©Є«¬­®ЇабвгдежзийклмнопЂЃ‚ѓ„…р†‡€‰Љ‹ЊЌЋЏђ‘’“”•–—˜™љ›њќћџ";

for(var i = 0; i < work_str.length; i++) {
for(var j = 0; j < alphabet1.length; j++) {
if(work_str.charAt(i)==alphabet1.charAt(j)) {
work_str = work_str.substring(0,i)+alphabet2.charAt(j)+work_str.substring(i+1,work_str.length);
break;
}
}
}
return work_str;
}

function replace_symbol(str, symbol, new_symbol) {
while (str.lastIndexOf(symbol)!=-1) {
str = str.replace(symbol, new_symbol);
}
return str;
}

function get_playback_data() {
meta = meta_mode ? fb.GetSelections().Sort() : fb.GetNowPlaying();
meta_focus = meta_mode ? fb.GetFocusItem() : fb.GetNowPlaying();
if(meta_focus) {
if(btn_type==9 || btn_type==10 || btn_type==40) {
mood = fb.TitleFormat("%mood%").EvalWithMetadb(meta_focus);
skip = fb.TitleFormat("%skip%").EvalWithMetadb(meta_focus);
va = fb.TitleFormat("%album artist%").EvalWithMetadb(meta_focus);
if(mood=="?" || mood=="") mood = 0;
if(skip=="?" || skip=="") skip = 0;
if(va=="") va = "";
mood = mood*1;
skip = skip*1;
va = va;
}
if(btn_type>11 && btn_type<17 || btn_type==20) {
artist = replace_symbol(fb.TitleFormat("%artist%").EvalWithMetadb(meta_focus)," ","+");
album = replace_symbol(fb.TitleFormat("%album%").EvalWithMetadb(meta_focus)," ","+");
title = replace_symbol(fb.TitleFormat("%title%").EvalWithMetadb(meta_focus)," ","+");
} else {
artist = "";
album = "";
title = "";
}
} else {
mood = 0;
skip = 0;
va = "";

artist = "";
album = "";
title = "";
}
}

function on_paint(gr) {
var ww,wh;
var img_null,img_hover,img;

get_playback_data();
switch (btn_type) {
case 1:
img_null = (fb.IsPlaying && !fb.IsPaused) ? image_null_add : image_null;
img_hover = (fb.IsPlaying && !fb.IsPaused) ? image_hover_add : image_hover;
break;
case 7:
switch (fb.PlaybackOrder+1) {
case 1:
img_null = image_null;
img_hover = image_hover;
break;
case 2:
img_null = image_null_rp;
img_hover = image_hover_rp;
break;
case 3:
img_null = image_null_rt;
img_hover = image_hover_rt;
break;
case 4:
img_null = image_null_r;
img_hover = image_hover_r;
break;
case 5:
img_null = image_null_st;
img_hover = image_hover_st;
break;
case 6:
img_null = image_null_sa;
img_hover = image_hover_sa;
break;
case 7:
img_null = image_null_sf;
img_hover = image_hover_sf;
break;
}
break;
case 8:
img_null = fb.StopAfterCurrent ? image_null_add : image_null;
img_hover = fb.StopAfterCurrent ? image_hover_add : image_hover;
break;
case 9:
img_null = mood==0 ? image_null : image_null_add;
img_hover = mood==0 ? image_hover : image_hover_add;
break;
case 10:
img_null = skip==0 ? image_null : image_null_add;
img_hover = skip==0 ? image_hover : image_hover_add;
break;
case 28:
img_null = get_option(option_name)==option_value ? image_null_add : image_null;
img_hover = get_option(option_name)==option_value ? image_hover_add : image_hover;
break;
case 40:
img_null = va=="Various Artists" ? image_null_add : image_null;
img_hover = va=="Various Artists" ? image_hover_add : image_hover;
break;
default:
img_null = image_null;
img_hover = image_hover;
break;
}
img = on_hover ? img_hover : img_null;

ww = window.Width;
wh = window.Height;

if(smooth) {
gr.DrawImage(img_null, 0, 0, ww, wh, 0, 0, img_null.Width, img_null.Height, angle = 0, alpha = btn_alpha_max - btn_alpha);
gr.DrawImage(img_hover, 0, 0, ww, wh, 0, 0, img_hover.Width, img_hover.Height, angle = 0, alpha = clicked ? 255 : btn_alpha);
} else {
gr.DrawImage(img, 0, 0, ww, wh, 0, 0, img.Width, img.Height, angle = 0, alpha = clicked ? 255 : btn_alpha);
}
}

function on_mouse_move(x, y) {
window.SetCursor(32649);
if(leave) {
leave = false;
on_mouse_leave();
} else {
on_hover = true;
if(on_hover!=on_hover_chk) {
if(show_tip) {
set_tooltip_text();
tooltip.Activate();
}
if(smooth) {
timer && window.KillTimer(timer);
timer=null;
CollectGarbage();
if (!timer) timer = window.CreateTimerInterval(timer_interval);
}
on_hover_chk = on_hover;
window.Repaint();
}
}
}

function on_mouse_leave() {
if(show_tip) tooltip.Deactivate();
window.SetCursor(32512);
on_hover = false;
on_hover_chk = false;
if(smooth) {
counter = 0;
clicked = false;
timer && window.KillTimer(timer);
timer=null;
CollectGarbage();
if (!timer) timer = window.CreateTimerInterval(timer_interval); 
}
window.Repaint();
}

function on_playback_new_track(metadb) {
window.Repaint();
}

function on_playback_stop(reason) {
window.Repaint();
}

function on_playback_pause(state) {
window.Repaint();
}

function on_playback_starting(cmd, is_paused) {
window.Repaint();
}

function on_playback_order_changed(new_order_index) {
window.Repaint();
}

function on_item_focus_change() {
if(meta_mode) window.Repaint();
}

function on_selection_changed(metadb) {
if(meta_mode) window.Repaint();
}

function on_playlist_stop_after_current_changed(state) {
window.Repaint();
}

function on_notify_data(name, info) {
if(name=="switched "+option_name && info!=option_value && btn_type==28) window.Repaint();
}

on_timer = function(id){
var step = 8;

if (!timer || timer.ID != id) return;
if(counter!=0) counter = counter==1 ? counter + timer_interval - 1 : counter + timer_interval;
if(counter>259) {
counter = 0;
clicked = false;
timer && window.KillTimer(timer);
timer=null;
CollectGarbage();
}
if(smooth) {
if(on_hover) {
btn_alpha = btn_alpha + step;
if(btn_alpha>btn_alpha_max-1) {
btn_alpha = btn_alpha_max;
if(counter==0) {
timer && window.KillTimer(timer);
timer=null;
CollectGarbage();
}
}
} else {
btn_alpha = btn_alpha - step;
if(btn_alpha<step) {
btn_alpha = 0;
clicked = false;
timer && window.KillTimer(timer);
timer=null;
CollectGarbage();
}
}
}
window.Repaint();
}

function popup_main_menu(x, y) {
//Function code by Br3tt
var MF_SEPARATOR = 0x00000800;
var MF_ENABLED = 0x00000000;
var MF_GRAYED = 0x00000001;
var MF_DISABLED = 0x00000002;
var MF_UNCHECKED = 0x00000000;
var MF_CHECKED = 0x00000008;
var MF_STRING = 0x00000000;
var MF_POPUP = 0x00000010;
var MF_RIGHTJUSTIFY = 0x00004000;

var menu = window.CreatePopupMenu();
var context_menu_manager = fb.CreateContextMenuManager();

var idx;

context_menu_manager.InitNowPlaying();

var menu_file = window.CreatePopupMenu(); //File
var menu_edit = window.CreatePopupMenu(); //Edit
var menu_view = window.CreatePopupMenu(); //View
var menu_playback = window.CreatePopupMenu(); //Playback
var menu_library = window.CreatePopupMenu(); //Library
var menu_help = window.CreatePopupMenu(); //Help
var menu_nowp = window.CreatePopupMenu(); //Now playing

var menu_file_manager = fb.CreateMainMenuManager();
var menu_edit_manager = fb.CreateMainMenuManager();
var menu_view_manager = fb.CreateMainMenuManager();
var menu_playback_manager = fb.CreateMainMenuManager();
var menu_library_manager = fb.CreateMainMenuManager();
var menu_help_manager = fb.CreateMainMenuManager();

menu.AppendMenuItem(MF_STRING | MF_POPUP, menu_file.ID, "File");
menu.AppendMenuItem(MF_STRING | MF_POPUP, menu_edit.ID, "Edit");
menu.AppendMenuItem(MF_STRING | MF_POPUP, menu_view.ID, "View");
menu.AppendMenuItem(MF_STRING | MF_POPUP, menu_playback.ID, "Playback");
menu.AppendMenuItem(MF_STRING | MF_POPUP, menu_library.ID, "Library");
menu.AppendMenuItem(MF_STRING | MF_POPUP, menu_help.ID, "Help");
fb.IsPlaying && menu.AppendMenuItem(MF_STRING | MF_POPUP, menu_nowp.ID, "Now Playing");

menu_file_manager.Init("file");
menu_edit_manager.Init("edit");
menu_view_manager.Init("View");
menu_playback_manager.Init("playback");
menu_library_manager.Init("library");
menu_help_manager.Init("help");

menu_file_manager.BuildMenu(menu_file, 1, 100);
menu_edit_manager.BuildMenu(menu_edit, 100, 150);
menu_view_manager.BuildMenu(menu_view, 200, 200);
menu_playback_manager.BuildMenu(menu_playback, 300, 250);
menu_library_manager.BuildMenu(menu_library, 400, 300);
menu_help_manager.BuildMenu(menu_help, 500, 350);

context_menu_manager.InitNowPlaying();

fb.IsPlaying && context_menu_manager.BuildMenu(menu_nowp, 700, -1);

idx = 0;
idx = menu.TrackPopupMenu(x, y);

switch (true) {
case (idx>=1 && idx<100):
menu_file_manager.ExecuteByID(idx-1);
break;
case (idx>=100 && idx<200):
menu_edit_manager.ExecuteByID(idx-100);
break;
case (idx>=200 && idx<300):
menu_view_manager.ExecuteByID(idx-200);
break;
case (idx>=300 && idx<400):
menu_playback_manager.ExecuteByID(idx-300);
break;
case (idx>=400 && idx<500):
menu_library_manager.ExecuteByID(idx-400);
break;
case (idx>=500 && idx<600):
menu_help_manager.ExecuteByID(idx-500);
break;
case (idx>=700):
context_menu_manager.ExecuteByID(idx-700);
break;
}

menu.Dispose();
context_menu_manager.Dispose();
menu_file_manager.Dispose();
menu_edit_manager.Dispose();
menu_view_manager.Dispose();
menu_playback_manager.Dispose();
menu_library_manager.Dispose();
menu_help_manager.Dispose();
}

function send_2_device(meta_send) {
var ext,file,drive,file_folder,file_path,file_path_convert,folder,mask,file_copy;
var mp3 = true;

if(meta) {
ext = fb.TitleFormat("$ext($if2(%__referenced_file%,%path%))").EvalWithMetadb(meta_send);
file_folder = fb.TitleFormat("$directory_path(%path%)").EvalWithMetadb(meta_send);
file_path = file_folder + "\\" + fb.TitleFormat("$if2(%__referenced_file%,%filename_ext%)").EvalWithMetadb(meta_send);
if(file_path.substring(1,2)!==":") return;
mask = fb.TitleFormat("%folder_mask%").EvalWithMetadb(meta_send);
mask = fb.TitleFormat(mask).EvalWithMetadb(meta_send);
file_copy = file_path;
if(ext!="mp3") {
file_path_convert = file_folder + "\\" + fb.TitleFormat("$replace($if2(%track%,00) - $if($strcmp(%album artist%,%artist%),,%artist% - )$if2(%title%,%filename%).mp3,/,-)").EvalWithMetadb(meta_send);
file_copy = file_path_convert;
file = FSO.CreateTextFile(fb.FoobarPath + "\\utilities\\send2device.cmd",2);
file.WriteLine('copy NUL "' + fix_russian_text2(file_folder) + '\\tmp_send"');
file.WriteLine('BladeEnc.exe %~1 "%~2" "%~3" %~4');
file.WriteLine('del "' + fix_russian_text2(file_folder) + '\\tmp_send"');
file.WriteLine("del %0");
file.Close();
mp3 = false;
}
drive = fb.TitleFormat("%device%").EvalWithMetadb(meta_send);
for(var i = 0; i < drive.length; i++) {
folder = drive.charAt(i) + ":\\" + mask;
if(drive_exists(drive.charAt(i)+":")) {
if(!mp3) fb.RunContextCommandWithMetadb("Convert/Send2Device_Preset_(not_for_manual_usage)",meta_send);
if(!folder_exists(folder)) create_folder(folder);
file = FSO.CreateTextFile(file_folder + "\\tmp_send.cmd",2);
if(!mp3) {
file.WriteLine(":start");
file.WriteLine('if exist "' + fix_russian_text2(file_path_convert) + '" goto test');
file.WriteLine("goto start");
file.WriteLine(":test");
file.WriteLine('if not exist "' + fix_russian_text2(file_folder) + '\\tmp_send" goto do_copy');
file.WriteLine("goto test");
file.WriteLine(":do_copy");
file.WriteLine('"' + fb.FoobarPath + '\\utilities\\sleep.exe" 3');
}
file.WriteLine('copy "' + fix_russian_text2(file_copy + '" "' + folder) + '"');
if(!mp3) file.WriteLine('del "' + fix_russian_text2(file_copy) + '"');
file.WriteLine("del %0");
file.Close();
break;
}
}
if(file_exists(file_folder + "\\tmp_send.cmd")) {
WshShell.run('"' + file_folder + '\\tmp_send.cmd"',0);
} else if(file_exists(fb.FoobarPath + "\\utilities\\send2device.cmd")) {
FSO.DeleteFile(fb.FoobarPath + "\\utilities\\send2device.cmd", true);
}
}
}

function on_mouse_rbtn_down(x, y, mask) {
var MF_SEPARATOR = 0x00000800;
var MF_STRING = 0x00000000;
var menu = window.CreatePopupMenu();
var idx;

menu.AppendMenuItem(MF_STRING, 1, "Properties");
// menu.AppendMenuItem(MF_STRING, 2, "Configure...");
idx = menu.TrackPopupMenu(x, y);
switch(idx) {
case 1:
window.ShowProperties();
break;
case 2:
window.ShowConfigure();
break;
}
menu.Dispose();
}

//Button effects
function on_mouse_lbtn_down(x, y, mask) {
var MF_SEPARATOR = 0x00000800;
var MF_STRING = 0x00000000;
var menu,idx;
var pbo = fb.PlaybackOrder;
var tag;
var art,alb,tit;
var dimensions;
var window_x,window_y,window_width,window_height;
var h = 16;
var opt_value;
var meta_cur;

if(btn_type>11 && btn_type<17 || btn_type==20) {
art = fix_russian_text(artist);
alb = fix_russian_text(album);
tit = fix_russian_text(title);
} else {
art = artist;
alb = album;
tit = title;
}
if(btn_type>20 && btn_type<25) {
if(!special) {
init_special_libraries(true);
special = true;
}
dimensions = get_window_dimensions("CUI");
window_x = dimensions[0];
window_y = dimensions[1];
window_width = dimensions[2];
window_height = dimensions[3];
}
switch (btn_type) {
case 1:
fb.PlayOrPause();
break;
case 2:
fb.Stop();
break;
case 3:
fb.Next();
break;
case 4:
fb.Prev();
case 5:
fb.RunMainMenuCommand("View/Columns playlist/Activate now playing");
fb.RunMainMenuCommand("View/ELPlaylist/Show now playing");
break;
case 6:
fb.RunMainMenuCommand("File/Open...");
leave = true;
break;
case 7:
menu = window.CreatePopupMenu();
menu.AppendMenuItem(MF_STRING, 1, "Default");
menu.AppendMenuItem(MF_STRING, 2, "Repeat Playlist");
menu.AppendMenuItem(MF_STRING, 3, "Repeat Track");
menu.AppendMenuItem(MF_STRING, 4, "Random");
menu.AppendMenuItem(MF_STRING, 5, "Shuffle Tracks");
menu.AppendMenuItem(MF_STRING, 6, "Shuffle Albums");
menu.AppendMenuItem(MF_STRING, 7, "Shuffle Folders");
menu.CheckMenuRadioItem(1, 7, pbo+1);
idx = menu.TrackPopupMenu(0, window.Height);
fb.PlaybackOrder = idx - 1;
menu.Dispose();
break;
case 8:
fb.RunMainMenuCommand("Playback/Stop After Current");
break;
case 9:
if(meta) {
for(var i=0; i<(meta_mode ? meta.Count : 1); i++) {
tag = mood==0 ? 1 : "";
meta_cur = meta_mode ? meta.Item(i) : meta;
meta_cur.UpdateFileInfoSimple("MOOD",tag);
}
fb.trace("WSH: tag <MOOD> updated to value "+tag+".");
fb.RunMainMenuCommand("ELPlaylist/Refresh");
}
break;
case 10:
if(meta) {
for(var i=0; i<(meta_mode ? meta.Count : 1); i++) {
tag = skip==0 ? 1 : "";
meta_cur = meta_mode ? meta.Item(i) : meta;
meta_cur.UpdateFileInfoSimple("SKIP",tag);
}
fb.trace("WSH: tag <SKIP> updated to value "+tag+".");
fb.RunMainMenuCommand("ELPlaylist/Refresh");
}
break;
case 11:
popup_main_menu(0, window.Height);
break;
case 12:
if(artist!="") WshShell.run("http://www.last.fm/music/" + art);
break;
case 13:
if(artist!="") WshShell.run("http://images.google.com/images?hl=en&q=" + art + "&btnG=Recherche+d%27images&gbv=2");
break;
case 14:
if(artist!="") WshShell.run("http://en.wikipedia.org/wiki/" + replace_symbol(art,"+","_"));
break;
case 15:
if(artist!="" && album!="") WshShell.run("http://images.google.com/images?hl=en&q=" + art + "%20" + alb + "&btnG=Recherche+d%27images&gbv=2");
break;
case 16:
if(artist!="" && title!="") WshShell.run("http://www.youtube.com/results?search_type=&search_query=" + art + "%20" + tit + "&aq=2&oq");
break;
case 17:
WshShell.run("http://www.hydrogenaudio.org/forums/index.php?showforum=28");
break;
case 18:
if(meta_focus) fb.RunContextCommandWithMetadb("Open containing folder", meta_focus);
break;
case 19:
fb.RunMainMenuCommand("File/Preferences");
break;
case 20:
if(artist!="") WshShell.run("http://www.google.com/search?q=" + art + "&ie=utf-8");
break;
case 21:
move_window("CUI",window_x,window_y,window_width,window_height+h);
break;
case 22:
move_window("CUI",window_x,window_y,window_width,window_height-h);
break;
case 23:
move_window("CUI",window_x,window_y,window_width+h,window_height);
break;
case 24:
move_window("CUI",window_x,window_y,window_width-h,window_height);
break;
case 25:
fb.RunMainMenuCommand("File/Open audio CD...");
break;
case 26:
fb.Random();
break;
case 27:
send_2_device(meta_focus);
break;
case 28:
opt_value = get_option(option_name);
set_option(option_name,(opt_value==option_value && switch_to_0) ? 0 : option_value);
window.NotifyOthers("switched "+option_name,option_value);
foo_refresh();
break;
case 29:
fb.RunMainMenuCommand("File/Load playlist...");
break;
case 30:
fb.RunMainMenuCommand("File/Remove playlist");
break;
case 31:
fb.RunMainMenuCommand("File/New playlist");
break;
case 32:
fb.RunMainMenuCommand("File/Rename playlist");
break;
case 33:
fb.RunMainMenuCommand("File/Save playlist...");
break;
case 34:
fb.RunMainMenuCommand("File/Save all playlists...");
break;
case 35:
fb.RunMainMenuCommand("View/Playlist Manager");
break;
case 36:
if(meta) fb.RunContextCommandWithMetadb("Copy",meta);
break;
case 37:
if(meta) fb.RunContextCommandWithMetadb("Send to playlist...",meta);
break;
case 38:
fb.RunMainMenuCommand("Edit/Remove dead items");
break;
case 39:
fb.RunMainMenuCommand("Edit/Remove duplicates");
break;  
case 40:
if(meta) {
for(var i=0; i<(meta_mode ? meta.Count : 1); i++) {
tag = va=="Various Artists" ? "" : "Various Artists";
meta_cur = meta_mode ? meta.Item(i) : meta;
meta_cur.UpdateFileInfoSimple("ALBUM ARTIST",tag);
}
fb.trace("WSH: tag <ALBUM ARTIST> updated to value "+tag+".");
fb.RunMainMenuCommand("ELPlaylist/Refresh");
}
break;
}
clicked = true;
counter = 1;
if (!timer) timer = window.CreateTimerInterval(timer_interval);
window.Repaint();
}

The first one is for store in file and import with another code:
Code: [Select]
// ==PREPROCESSOR==
// @import "%fb2k_path%skins\Black_Glass_Remake\scripts\WSH_Button.js"
// ==/PREPROCESSOR==

//WSH Button panel by Zin-Uru, 2010

settings_path = fb.FoobarPath + "\\skins\\Black_Glass_Remake\\settings\\";
img_path = fb.FoobarPath + "\\skins\\Black_Glass_Remake\\images\\playlist\\";
meta_mode = window.GetProperty("Follow cursor mode",false);
show_tip = window.GetProperty("Show tooltip",true);

//Button type
//1 = Play or Pause
//2 = Stop
//3 = Next
//4 = Previous
//5 = Focus now playing
//6 = Open
//7 = Choose playback order
//8 = Set stop after current on/off
//9 = Change mood status
//10 = Change skip status
//11 = Popup main menu
//12 = Last.fm button
//13 = Google search for artist art
//14 = Wikipedia artist info
//15 = Google search for album art
//16 = Search for YouTube videos
//17 = Visit Hydrogenaudio official Foobar2000 forum
//18 = Open file containing folder
//19 = Open Preferences page
//20 = Google search for artist
//21 = Increase window height (Additional_WSH_Libs.js required)
//22 = Decrease window height (Additional_WSH_Libs.js required)
//23 = Increase window width (Additional_WSH_Libs.js required)
//24 = Decrease window width (Additional_WSH_Libs.js required)
//25 = Open audio CD
//26 = Random track
//27 = Send to device (foo_ui_hacks, foo_exvar with special variables and special converter preset required)
//28 = Switch option (Settings.js required)
//29 = Load playlist
//30 = Remove playlist
//31 = Create new playlist
//32 = Rename playlist
//33 = Save playlist
//34 = Save all playlists
//35 = Open Playlist Manager
//36 = Copy file (name(s)) to clipboard
//37 = Send file(s) to playlist
//38 = Remove dead items
//39 = Remove duplicates
//40 = Set or remove Various Artists tag to file(s)
btn_type = 40;

image_null = gdi.Image(img_path+"btn_group_album_0.png");
image_hover = gdi.Image(img_path+"btn_group_album_1.png");

//For play-pause, stop-after, mood, skip and option buttons
if(btn_type==1 || btn_type==8 || btn_type==9 || btn_type==10 || btn_type==28 || btn_type==40) {
    image_null_add = gdi.Image(img_path+"btn_group_album_2.png");
    image_hover_add = gdi.Image(img_path+"btn_group_album_3.png");
}

//For playback order button
if(btn_type==7) {
    image_null_rp = gdi.Image(img_path+"4.png");
    image_null_rt = gdi.Image(img_path+"5.png");
    image_null_r = gdi.Image(img_path+"6.png");
    image_null_st = gdi.Image(img_path+"7.png");
    image_null_sa = gdi.Image(img_path+"8.png");
    image_null_sf = gdi.Image(img_path+"9.png");
   
    image_hover_rp = gdi.Image(img_path+"10.png");
    image_hover_rt = gdi.Image(img_path+"11.png");
    image_hover_r = gdi.Image(img_path+"12.png");
    image_hover_st = gdi.Image(img_path+"13.png");
    image_hover_sa = gdi.Image(img_path+"14.png");
    image_hover_sf = gdi.Image(img_path+"15.png");
}

//For option button
if(btn_type==28) {
    option_name = "sort_preset";
    option_value = 1;
    tip_name = Array("Albums","Artist","Singles","Path");
    switch_to_0 = false;
}

//if(!file_exists(settings_path + "smooth_1")) smooth = false;
btn_alpha = smooth ? 0 : btn_alpha_max;

See get_playback_data() and on_mouse_lbtn_down(...) functions in the first code (I use fb.GetSelections() there). With btn_type=40 for example commands don't work if I use Sort().

WSH Panel Mod

Reply #987
@Zin-Uru:
Sort() won't return a metadb handle list.
You should use like this:

var metas = fb.GetSelections();
metas.Sort();


However, I've found a stupid mistake in IFbMetadbHandleList::Sort(), without your report, I think I'll take much more time to realize that... thanks.

WSH Panel Mod

Reply #988
T.P Wang, thank you too! Now waiting for the final version.

WSH Panel Mod

Reply #989
@TP:
I wonder if there could be a function to select all the contents of a specified playlist, and then generate a Metadb list for users to operate
mad messy misanthropist morbid mused

 

WSH Panel Mod

Reply #990
I've just got a crash with WSH 1.4.0 beta 2 (it's at the top of the stack), I sent the crash report over the official channel. My panels are here.

Also, I use notifier to pass an array from my bio panel to artist art panel, and the artist art panel tends to crash randomly albeit rarely (artist art does not load, even though it has been fetched and it crashes when accessing array arr that holds artist art paths). I don't know why, it happens with both 1.4.0 beta 2 and 1.3.7, but I feel the former does it more frequently. If you can check why it does that, it would help a lot.

WSH Panel Mod

Reply #991
I've just got a crash with WSH 1.4.0 beta 2 (it's at the top of the stack), I sent the crash report over the official channel. My panels are here.

Also, I use notifier to pass an array from my bio panel to artist art panel, and the artist art panel tends to crash randomly albeit rarely (artist art does not load, even though it has been fetched and it crashes when accessing array arr that holds artist art paths). I don't know why, it happens with both 1.4.0 beta 2 and 1.3.7, but I feel the former does it more frequently. If you can check why it does that, it would help a lot.


window.NotifyOthers() method is unable to pass an Array object, because the script engine can not tell the Array in JS from the Array in VBS.
but the document on MSDN provided an alternative solution, if you still want to use an Array, the Typed Array.
The typed array looks like this:
var T_Array = [elements1,ele2, ele3,...,eleN];
and the methods as well as the properties of this object are the same as those of an normal Array in JS.
But be aware that this kind of array must NOT be sparse, that is to say, the elements of a typed array should be assigned one by one.

here will be very helpful:
http://msdn.microsoft.com/en-us/library/dt...x(v=VS.80).aspx
mad messy misanthropist morbid mused

WSH Panel Mod

Reply #992
I passed that array elements one by one before (all are strings) using an notifier each (the last notifier is also used to start my artist art code), but got problem so I tried array and got another problem, will try typed array to see if I have better stability. I thought that if all my panels are JS, it should be ok. Basically I just want to pass four string to another panel and after the other panel's received all these strings, it fires up my start() function.

WSH Panel Mod

Reply #993
@ T.P Wang:

bug found in 1.4.0 beta 2:

fb.IsAutoPlaylist(idx) don't work on init ! it return false even if a playlist is an autoplaylist. Works fine after panel started, displayed and a window.Repaint()

any idea for a fix please ?

Thanx


WSH Panel Mod

Reply #995
Is it possible to change panel compile order at startup, I have a panel that needs to be compiled before another, is there a way to do that other than changing their order in the GUI, which is not what I wanna do?

WSH Panel Mod

Reply #996
@ T.P Wang

could you consider please to add a function to get the query of an autoplaylist (i hope it's possible and not too hard to code for you) ? i really need this ...

Thanx by advance

WSH Panel Mod

Reply #997
@ T.P Wang

could you consider please to add a function to get the query of an autoplaylist (i hope it's possible and not too hard to code for you) ? i really need this ...

Thanx by advance


can't you use C++ or VB or Java , why can't you make a component like foo_uie_wsh_br3tt.dll?

cause your ability of write code is very strong!

I trust you , beg others is not a good way for my hero like you

WSH Panel Mod

Reply #998
I'm unaware of Falstaff's skillset, but there is a rather significant difference between JS and C++.
In any way, if I wrote the WSH component, which I didn't, I'd expose a third party interface for external extension of the component, instead of all the _mod forks.
Stay sane, exile.

WSH Panel Mod

Reply #999
Hello,

after updating to version 1.4.0.beta3, i'm receiving Invalid procedure call or argument
on gr.drawimage(...

Has something changed in this version which causes something what worked, not to work anymore?
<3 f00