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 810793 times) previous topic - next topic
0 Members and 2 Guests are viewing this topic.

WSH Panel Mod

Reply #350
Thanks, already knew about fb.TitleFormat() but couldn't "link" it with metadb. Now I know how

WSH Panel Mod

Reply #351
Any ideas how I can duplicate a playlist with a WSH button? I was trying to do this in PSS but I don't think I can.

WSH Panel Mod

Reply #352
hi guys. i'm in well over my head with this scripting malarkey and i'm really stuck. i've bodged togethe a script from other people's work that works almost perfectly. my only problem is a script error on startup if the playlist is empty (not a huge issue but i'd like to fix it)

i think this is the relvant part of the code....

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

function on_item_focus_change() {
if (g_metadb) window.UnwatchMetadb();
g_metadb = window.GetProperty("Focused", 0) == 1 ? fb.GetFocusItem() : fb.GetNowPlaying();
if (g_metadb) {
on_metadb_changed();
window.WatchMetadb(g_metadb);
}
}

function on_metadb_changed() {
        //console error here when playlist is empty on startup
var wiki = fb.TitleFormat("http://en.wikipedia.org/wiki/$replace(%artist%, ,_)").EvalWithMetadb(g_metadb);
var myspace = fb.TitleFormat("http://www.myspace.com/$replace(%artist%, ,)").EvalWithMetadb(g_metadb);
var lastfm = fb.TitleFormat("http://www.last.fm/music/$replace(%artist%, ,+,/,'%'252F)/_/$replace(%title%, ,+,/,'%'252F)").EvalWithMetadb(g_metadb);
var youtube = fb.TitleFormat("http://www.youtube.com/results?search_query=$replace(%artist%+%title%, ,+,'(',,')',,/,+,&,and)").EvalWithMetadb(g_metadb);
Buttons = {
but1: new Button(0,0,bw,bh, {normal: images + "wiki.png", hover: images + "wiki_h.png"}, function(){WshShell.run(wiki);}, wiki),
but2: new Button(bw,0,bw,bh, {normal: images + "myspace.png", hover: images + "myspace_h.png"}, function(){WshShell.run(myspace);}, myspace),
but3: new Button(bw*2,0,bw,bh, {normal: images + "lastfm.png", hover: images + "lastfm_h.png"}, function(){WshShell.run(lastfm);}, lastfm),
but4: new Button(bw*3,0,bw,bh, {normal: images + "youtube.png", hover: images + "youtube_h.png"}, function(){WshShell.run(youtube);}, youtube)
};
}

obviously it's the first line that breaks it but i really think i need that line of code for when the playlist is populated. how can i work around this?

WSH Panel Mod

Reply #353
@marc2003:
You need to check if the g_metadb is valid:

Code: [Select]
function on_metadb_changed() {
    // Check
    if (!g_metadb) return;
    ....
}

WSH Panel Mod

Reply #354
i also had to add that to a few other functions (thanks to your error reporting telling me which line it was on  ) but now it works perfectly.

many thanks. 

 

WSH Panel Mod

Reply #355
Hey guys!

I sked this some time ago
Quote
...I saw that it's possible get the contexmenu, is it possible to get the individual popups of the menu bar?


Can someone say at least NO?
<insert signature here>

WSH Panel Mod

Reply #356
Hi there,

I am a total noob in Javascript and the whole stuff, can work with the syntax and with the help of the examples and different configs posted here I made this rating button config
Code: [Select]
function RGB(r,g,b){ return (0xff000000|(r<<16)|(g<<8)|(b)); }

var g_drag = 0;
var bool;
var g_metadb;
var imgname;
var rating;
var nrating;
var lrating;
var img;
var hofset = 4;
var vofset = 0;
var iw = 16; var ih = 16;
var g_tfo = fb.TitleFormat("%rating%");

on_item_focus_change();

function on_paint(gr) {    
    if (g_metadb) {
    for (i = 1; i < 6; i++) {
        img = gdi.image(fb.FoobarPath + "skins\\Win7inspirat\\btn\\"+ ((i > (g_drag ? lrating : rating)) ? "star0" : "star1" + (g_drag ? "h" : "")) + ".png");
        gr.DrawImage(img,hofset+iw*(i-1),vofset,iw,ih,0,0,iw,ih);
        }
    }
}

function on_mouse_lbtn_up(x,y){
    if (lrating !=rating) {if (g_metadb) {
            bool = g_metadb.UpdateFileInfoSimple("RATING",lrating);
        }
    }
}
function on_mouse_move(x, y) {
    if (g_metadb) {
    g_drag = 1;
    nrating = Math.ceil((x-hofset)/iw);
    if (nrating > 5) nrating = 5;
        if (nrating != lrating) {
            lrating = nrating;
            window.Repaint();
        }
    }
}
function on_mouse_leave() {
    on_item_focus_change();//on_metadb_changed()
}
function on_item_focus_change() {
    if (g_metadb) {window.UnwatchMetadb();}
    g_metadb = fb.GetNowPlaying();//fb.GetFocusItem();
    if (g_metadb) {
        on_metadb_changed();
        window.WatchMetadb(g_metadb);
    }
}
function on_metadb_changed() {
    // Check
    if (!g_metadb) return;
    g_drag = 0;
    rating = g_tfo.EvalWithMetadb(g_metadb);
    if (rating == "?") {rating = 0;}
    lrating = rating;
    window.Repaint();
}
function on_playback_new_track(metadb) {
    on_item_focus_change();
}
//EOF


What I want, if something is playing the config should update the now playing file, if stopped or possible paused too, just the selected file
Is it possible? Maybe someone should open a thread with example configs/scripts

thanks
-Chris

WSH Panel Mod

Reply #357
try this...

Code: [Select]
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);
    }
}


WSH Panel Mod

Reply #358
@marc2003
As another newbee, would you be so kind as to post your completed script so that I can understand your added functions mentioned above. Thanks

WSH Panel Mod

Reply #359
I think you just change the function on_item_focus_change in my config with his part, simple
but I didn't test it, atm I am at wrok

take care
-Chris

WSH Panel Mod

Reply #360
i only changed one line of code. i thought i'd post the whole function so it was easier to find.

i replaced this....

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


with this

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


if you have no idea what that is, it's basically shorthand for writing

Code: [Select]
if(fb.IsPlaying) {
  g_metadb = fb.GetNowPlaying();
} else {
  g_metadb = fb.GetFocusItem();
}

WSH Panel Mod

Reply #361
Hey guys!

I sked this some time ago
Quote
...I saw that it's possible get the contexmenu, is it possible to get the individual popups of the menu bar?


Can someone say at least NO?

You can get each main menu command with fb.RunMainMenuCommand('Open Audio CD...'); Etc, so you can replicate the main menu with window.CreatePopupMenu(); There are examples of creating menus in the samples folder. I don't think you can just get them all automatically like the context menu.

WSH Panel Mod

Reply #362
@marc: thank you very much, works great

WSH Panel Mod

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

just to expand that idea a little, this code snippet should work on anything that uses on_item_focus_change().

when playback is stopped, it defaults to fb.GetFocusItem() - but when playing, you can switch between "modes" on the fly using the right click context menu.

Code: [Select]
function on_item_focus_change() {
if (g_metadb) window.UnwatchMetadb();
g_metadb = window.GetProperty("Focused", 0) == 1 || !fb.IsPlaying ? fb.GetFocusItem() : fb.GetNowPlaying();
if (g_metadb) {
on_metadb_changed();
window.WatchMetadb(g_metadb);
}
}

function on_mouse_rbtn_down(x, y) {
var MF_SEPARATOR = 0x00000800;
var MF_STRING = 0x00000000;

var _menu = window.CreatePopupMenu();
var idx;
_menu.AppendMenuItem(MF_STRING, 1, "Playing item");
_menu.AppendMenuItem(MF_STRING, 2, "Focused item");
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_STRING, 3, "Properties");
_menu.AppendMenuItem(MF_STRING, 4, "Configure...");
_menu.CheckMenuRadioItem(1, 2, window.GetProperty("Focused", 0) + 1);

idx = _menu.TrackPopupMenu(x, y);

if (idx == 0) return;

switch (idx) {
case 1:
window.SetProperty("Focused", 0);
break;

case 2:
window.SetProperty("Focused", 1);
break;

case 3:
window.ShowProperties();
break;

case 4:
window.ShowConfigure();
}
on_item_focus_change();
}

WSH Panel Mod

Reply #364
Hello i istaled foobar config by Br3tt  ( xchange v3.5.1)
And i have a next error:

WSH Panel Mod
Scripting Engine Initialization Failed (GUID: 38BDCC36-06FF-441F-83A1-65CAD59D3006, CODE: 0x8000ffff)
Check the console for more detailed information.

I searched for solution but nothing useful. Help.  Tnx

WSH Panel Mod

Reply #365
@Djomlamrak:
This is known for scripts which don't contain exception handlers (and yes errors happen in the script), for Br3tt's config, it's usually caused by accessing ActiveX is denied, especially using FSO and Moving/Creating files in Program Files folder

WSH Panel Mod

Reply #366
Yes, Xchange write informations to your Xchange folder, so, be sure your profil has rights to write in xchange/settings/ folder (or just your foobar2000 folder) (windows UAC restrictions)


WSH Panel Mod

Reply #367
tNX MATES

tnx Br3tt ( Falstaff = br3tt? ) i did what you told and everything works just perfect!

WSH Panel Mod

Reply #368
Does anyone know if it's possible to add icons to each menu item? I mean the window.CreatePopupMenu() menus. Like MP3Tag has.

WSH Panel Mod

Reply #369
Really quick question; I'm using the following command to get the properties of the selected item in the playlist:

Code: [Select]
fb.RunContextCommandWithMetadb('Properties', fb.GetFocusItem() )

But how do I get the properties of all items selected rather than just the one item that has focus?

WSH Panel Mod

Reply #370
@TomBarlow:
I'm sorry to tell you it's not possbile. I believe it will be messed up (resource managements and restrictions of certain types of bitmaps), so I don't add this feature.

@Renton:
WSH Panel Mod doesn't support any features like metadb handle "Array", since VBScript and JScript using different array class, and I really don't like VBArray (which JScript support), hard to maintain...

WSH Panel Mod

Reply #371
OK, thanks for the answer

WSH Panel Mod

Reply #372
Thanks TP, I'm really liking WSH by the way, you can expect many more questions to come (but I'll do my best to work things out first).

Keep up the good work!

WSH Panel Mod

Reply #373
Hi guys,

I've managed to make myself a volume bar. But I wanted to add a pop up thing that displays the dB(decibels?) when the volume is adjusted like in default volume toolbar. Anyone know if this is possible or how I would do this.

And if it helps here's my volume bar.
Code: [Select]
function RGB(r, g, b) {
    return (0xff000000 | (r << 16) | (g << 8) | (b));
}
var g_font = gdi.Font("Segoe UI", 12, 0);
var g_drag = 0;
var ww;
var hofset = 10;
var wh = 5;
var ih = 16;
var iw = 9;
var vofset;
var grad;




function on_paint(gr) {

    grad = Math.pow((100 + fb.Volume) / 100, 2);
    vofset = (window.Height - wh) / 2;
    ww = window.Width - 2 * hofset;
    var i = 0;
    while (i < ww) {
        var col = (grad <= 0) ? RGB(168, 168, 168) : (i <= grad * ww) ? RGB(32 + 128 * i / ww, 164 * (1 - i / ww), 32 * (1 - i / ww)) : RGB(168, 168, 168);
        gr.FillSolidRect(hofset + 1 + i, vofset, 4, wh, col);
        i = i + 5;
    }
    gr.DrawRect(hofset, vofset, ww, wh + 1, 1, RGB(192, 192, 192));
    img = gdi.image(fb.FoobarPath + "Images\\Volume.png");
    gr.DrawImage(img, hofset + ww * grad - iw / 2, (window.Height - ih) / 2, iw, ih, 0, 0, iw, ih);

}



function on_mouse_lbtn_down(x, y) {
    g_drag = 1;
}



function on_mouse_lbtn_up(x, y) {
    on_mouse_move(x, y);
    g_drag = 0;
}


function on_mouse_rbtn_up(x, y) {
    var MF_SEPARATOR = 0x00000800;
    var MF_UNCHECKED = 0x00000000;
    var MF_CHECKED = 0x00000008;
    var MF_STRING = 0x00000000;

    var menu = window.CreatePopupMenu();
    var idx;

    var V_MF = fb.Volume == -100 ? MF_CHECKED : MF_UNCHECKED;

    menu.AppendMenuItem(V_MF, 1, "Volume Mute");
    menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
    menu.AppendMenuItem(MF_STRING, 2, "Configure");
    idx = menu.TrackPopupMenu(x, y);

    if (idx == 1) fb.VolumeMute();
    else if (idx == 2) window.ShowConfigure();

    menu.Dispose();
    return true;
}



function on_mouse_move(x, y) {
    if (g_drag) {
        var v = (x - hofset) / ww;
        v = (v < 0) ? 0 : (v < 1) ? v : 1;
        v = 100 * (Math.pow(v, 1 / 2) - 1);
        fb.Volume = v;
    }
}



function on_mouse_wheel(delta) {
    if (delta > 0) fb.VolumeUp();
    else fb.VolumeDown();
}



function on_volume_change(val) {
    window.Repaint();
}



function on_playback_time(time) {
    window.Repaint();
}
//EOF
Thanks in advance

WSH Panel Mod

Reply #374
Look at your WSH_MOD_HELP\SAMPLES folder. There is one explaining pretty well how to do a tooltip.
<insert signature here>