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 script discussion/help (Read 1393556 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

WSH Panel Mod script discussion/help

Reply #175
I completely rewrote my form and keyboard input scripts - and wasted way to much of my time. The result is much more universal and probably useful for others:

FormsAndButtons.zip

It includes a demonstration to show the different elements (harmless to your files):


I implemented the possibility for keyboard-only use, for details see FormsAndButtons.js

There are a few issues:
- I do call window.Repaint() in on_size, although it is recommended not to do (anyone a suggestion how to it otherwise if I need to get the window size?)
- I get a windows sound if I show a pop-up menu after pressing enter (see: this post)
- I wrote this script for an US-international keyboard layout (supporting dead keys and alt-gr) and there is (as far as I know) currently no way in WSH panel mod to find out which layout is used or to decode vkeys depending on keyboard layout. So anyone who wants to use this script with another keyboard layout should manually rewrite KeyboardHandling.js.
- Graphically my elements are plain and simple and that is the way I prefer it, so anyone who wants them otherwise is free to alter the script, but I am not going to do it. Colours could be changed in FormsStyle.js

Comments (or bug reports) are welcome!

WSH Panel Mod script discussion/help

Reply #176
In my current setup, I've created a "now playing" panel showing artist/album/title information.  It works pretty well, but there's a bit of a discrepancy when playing streaming audio. 

Some of my streams provide the artist/title information for the currently playing track, and this displays properly in the playlist viewer.  Unfortunately, my now playing WSH panel only displays the radio station's name.  Additionally, if I right-click on the playing track in the playlist viewer and go to properties, the artist and title fields do not represent the currently playing track, but rather the radio station's name. 

Therefore, it seems like the now playing WSH panel is displaying the metadata information "properly", but I'm not sure how to access the streaming artist/title.  Any ideas?

WSH Panel Mod script discussion/help

Reply #177
You can get it with on_playback_dynamic_info_track() and the Eval() method (not EvalWithMetadb() ).

WSH Panel Mod script discussion/help

Reply #178
Thanks, this replacement worked well.

WSH Panel Mod script discussion/help

Reply #179
Hi.

If this could be the place for a request - there it is, if not - please move it.

The only thing I actually miss in foobar2000 DUI is a panel allowing to tag files easily. Constantly visible, as opposed to Properties, that has some pre-set buttons, configurable preferably, such as "Genre: rock/blues/blah...", same for %date%. Just easier, quicker that quicktagger component, without right-click-menus-in-menus. It would be GREAT to have a field to fill with Artist, Title, Album names manually. Sometimes it's the only option.

I can't write it myself but maybe someone can?

WSH Panel Mod script discussion/help

Reply #180
The only thing I actually miss in foobar2000 DUI is a panel allowing to tag files easily. Constantly visible, as opposed to Properties, that has some pre-set buttons, configurable preferably, such as "Genre: rock/blues/blah...", same for %date%. Just easier, quicker that quicktagger component, without right-click-menus-in-menus. It would be GREAT to have a field to fill with Artist, Title, Album names manually. Sometimes it's the only option.

I can't write it myself but maybe someone can?


It is exactly therefore that I wrote my FormsAndButtons script, which I posted last week. As soon as I find some time I will make an (easy to customise) example of how to use it for tag input.

WSH Panel Mod script discussion/help

Reply #181
How can i select DSP preset within WSH script? I tried fb.RunMainMenuCommand("Playback/DSP Settings/[Preset Name]") but it does not work.

WSH Panel Mod script discussion/help

Reply #182
Hi,

does anyone know how i can compare to strings to eachother in the WSH_Panel_Mod?
I have searched on MSDN and tried to use some of the code from there,
but it gives me errors.

For instance if i put this in my code:


public static function Compare(
    strA : String,
    strB : String
) : int

i get the error Expected ';'

Oh Yeah, i'm a total newbie in using Jscript.
At first I always try to change little code from existing codes.
But in this case i couldn't find one that suites me.

cheers
<3 f00

WSH Panel Mod script discussion/help

Reply #183
keeping it simple.

Code: [Select]
function compare(a,b) {
  (a == b) ? return true : return false;
}

var result = compare("apples", "oranges");

WSH Panel Mod script discussion/help

Reply #184
keeping it simple.

Code: [Select]
function compare(a,b) {
  (a == b) ? return true : return false;
}

var result = compare("apples", "oranges");


Marc,

when is use the first code i get an Syntax error,
when using the second it says Object expected.

As I said i'm a newbie 
<3 f00

WSH Panel Mod script discussion/help

Reply #185
oops, should have tested...

Code: [Select]
function compare(a,b) {
  if(a == b) return true
  else return false;
}

var result = compare("apples", "oranges");


WSH Panel Mod script discussion/help

Reply #187
doh!

WSH Panel Mod script discussion/help

Reply #188
Thanks Tom/Marc for the help and links.
I'm got a little reading to do  now

cheers
<3 f00

WSH Panel Mod script discussion/help

Reply #189
If i may request something then i would ask for an enhancement for some of marc2003s scripts and tedgos lyrics script wich are now limited to show info about now playing track. It would be useful if they would respond to the Dui option in preferences -> display to prefer playing track or selection. Does the WSH Panel at all let you grab this option?

WSH Panel Mod script discussion/help

Reply #190
no, it's not possible to get that preference. you can edit my script to always follow the selection.  open

Code: [Select]
scripts\marc2003\v2\common.js


line 108 should be this....

Code: [Select]
g_metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();


replace it with...

Code: [Select]
g_metadb = fb.GetFocusItem();


restart foobar (or reload script) for changes to take effect.

WSH Panel Mod script discussion/help

Reply #191
The only thing I actually miss in foobar2000 DUI is a panel allowing to tag files easily. Constantly visible, as opposed to Properties, that has some pre-set buttons, configurable preferably, such as "Genre: rock/blues/blah...", same for %date%. Just easier, quicker that quicktagger component, without right-click-menus-in-menus. It would be GREAT to have a field to fill with Artist, Title, Album names manually. Sometimes it's the only option.


I updated my FormsAndButtons script: FormsAndButtons v1.1.zip

Besides some fixed bugs it now includes an example of how to make a tag editor with it.

It still had the issue that it only supports the US or US-international (QWERTY) keyboard layout, unless one edits the KeyboardHandling.js file. @T.P Wang: couldn't you implement windows' MapVirtualKeyEx function?

WSH Panel Mod script discussion/help

Reply #192
hi, guys! I know I`m insane, but how send all Media Library`s fields to array?

WSH Panel Mod script discussion/help

Reply #193
@nosatyj

No offense but... you better use use C++ and the official SDK.
WSH Panel mod can retrieve metadata of only ONE track at any point.
<insert signature here>

WSH Panel Mod script discussion/help

Reply #194
i took pieces from here and there and i made a simple text based playback order drop down
it's based on the marc23's scripts lib (bground options, etc) and his scripting style, vars etc

Here's my result for my controls bar



Code: [Select]
// ==PREPROCESSOR==
// @import "%fb2k_path%scripts\marc2003\v2\common.js"
// ==/PREPROCESSOR==

var panel_id = window.GetProperty("panel_id", window.id);
var custom_background_file = settings_path + panel_id + "buttons_background";
var custom_background = read(custom_background_file);
var top_margin = 0;
var left_margin = 4;
var bw = 16;
var bh = 16;

var mypbo = [];
mypbo[0] = "Default";
mypbo[1] = "Repeat (Playlist)";
mypbo[2] = "Repeat (Track)";
mypbo[3] = "Random";
mypbo[4] = "Shuffle (tracks)";
mypbo[5] = "Shuffle (albums)";
mypbo[6] = "Shuffle (folders)";

function on_size()
{
    ww = window.Width;
    wh = window.Height;
}

function on_mouse_lbtn_down(x, y) {
    var pbo = window.CreatePopupMenu();
    var i;
    var ret;
    for(i = 0; i < mypbo.length; i++)
    {
        pbo.AppendMenuItem(MF_STRING, i+1, mypbo[i]);
    }
    pbo.CheckMenuRadioItem(1, i, fb.PlayBackOrder + 1);
    ret = pbo.TrackPopupMenu(x, y);
    if (ret >= 1 && ret <= i)
    {
        fb.PlayBackOrder = ret - 1;
    }
    pbo.Dispose();
}

function on_paint(gr) {
    buttons_background(gr);
    icon = gdi.Image(images_path + "arrow_down.png");
    gr.DrawImage(icon,left_margin,top_margin,bw,bh,0,0,icon.Width,icon.Height);
    gr.SetTextRenderingHint(5);
    gr.DrawString("Order: " + mypbo[fb.PlayBackOrder], g_font, g_textcolor, left_margin+bw, top_margin, ww, wh, 0);
}

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

function on_mouse_rbtn_up(x, y) {
    buttons_menu(x,y);
    return true;
}


you will need to put a small arrow img in in the folder \scripts\marc2003\v2\images named arrow_down.png
here's one for you



WSH Panel Mod script discussion/help

Reply #195
Is there any way to determine if certain title formatting fields have multiple values, and if so, choose a custom separator?  For instance, this works:

Code: [Select]
artist = fb.TitleFormat("$replace(%artist%,',', &)").Eval();


Now all of my multiple artist tracks have variable "artist" equal to "Artist A & Artist B" (more suitable for compatibility with Last.fm).  The problem with this method is that if the artist field naturally has a comma in it, the script mistakenly sees it as a multiple artist field.  Is there any way around this?  Thanks.


WSH Panel Mod script discussion/help

Reply #197
Thanks, that worked.  Additionally, I've noticed that the foo_softplaylists component doesn't work on tracks with multiple artists.  It only recognizes the first artist.

WSH Panel Mod script discussion/help

Reply #198
Could someone help me get a script working? I've built a little menu that searches shoutcast based off of the genre of the playing track:



Code: [Select]
// ==PREPROCESSOR==
// @import "%fb2k_path%scripts\common.js"
// @import "%fb2k_path%scripts\tooltip_buttons.js"
// ==/PREPROCESSOR==

function on_paint(gr){
    var ww = window.Width;
    var wh = window.Height;    
    gr.FillSolidRect(0,0,ww,wh,RGB(220,220,220));
}

//Split multiline tags into an array
function split_tag(t) {
    var splitstrings = [", ",",","; "," - "," "];
    var tag=fb.TitleFormat("$caps(%"+t+"%)").EvalWithMetadb(g_metadb);
    //if (tag = "?") return;
    var foo = -1;
    do {
        foo++;
        var splitcheck = tag.indexOf(splitstrings[foo]);
    }
    while (splitcheck == -1 && foo < 6)
    return tag.split(splitstrings[foo]);
}

//doesn't work
//Create a dynamic menu for a tag
function scast_menu(t,m,n) {
    var tag = t;
    var menu_index = m;
    var menu_name = n;
    fb.trace(tag.toString());
    var times = tag.length;
    var foo = -1;    
    do {
        foo++;
        _child4.AppendMenuItem(MF_STRING,foobar++,"Search for "+tag[foo]+" stations");
    }
    while (foo < times-1)
}

//Menu Commands
function on_mouse_lbtn_down(x, y) {
    var basemenu = window.CreatePopupMenu();
    var ret;

    basemenu.AppendMenuItem(MF_STRING, 50, "Open a custom station...");
    basemenu.AppendMenuItem(MF_SEPARATOR, 0, 0);
    
    var genres = split_tag("genre");
    var times = genres.length;
    var foo = -1;    
    var foobar=52;
    do {
        foo++;
        basemenu.AppendMenuItem(MF_STRING,foobar++,"Search for "+genres[foo]+" stations");
    }
    while (foo < times-1)

    basemenu.AppendMenuItem(MF_SEPARATOR, 0, 0);
    basemenu.AppendMenuItem(MF_STRING, 51, "Most popular stations");

    var ret = basemenu.TrackPopupMenu(x, y);
    if (ret == 0)
        return;
    
    switch (ret)
    {
    case 50:
        var scast_station = text_input_box("Shoutcast Radio","Search for a Shoutcast station","scast")
        var shout = "http://www.shoutcast.com/radio/"+scast_station;
        WshShell.Run(shout);
        break;  
    case 51:  
        var shout = "http://www.shoutcast.com/most-popular-radio-stations";
        WshShell.Run(shout);
        break;
    default:
        var shout = "http://www.shoutcast.com/radio/"+encodeURIComponent(genres[ret - 52]);
        WshShell.Run(shout);
        break;
    }
    basemenu.Dispose();
}


Seems like the way to do it is would be to have on_metadb_changed() call window.Repaint(), and call the function that draws the menu in on_paint(gr), but hell if I can get it working.

Thanks if someone can help, I'll probably bumble my way to victory eventually but this is driving me up the wall.

WSH Panel Mod script discussion/help

Reply #199
@unclean:

You must use window.WatchMetadb(IFbMetadbHandle)
See interfaces.txt and the example file Watch Metadb Change (Base).txt