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

WSH Panel Mod script discussion/help

Reply #501
samples updated. 

i decided to split "similar artists" into it's own script and have reverted "simple biography" to how it was before.

each "similar artist" now has a "search spotify" button as i think this is more useful than using foo_lastfm_radio.




WSH Panel Mod script discussion/help

Reply #502
I'm looking at your previous screenshot and I just have to ask something:



Is the rounded edge (see arrow) part of the button design or is it part of a script?

WSH Panel Mod script discussion/help

Reply #503
it's just rounded rectangles offset with negative numbers so you don't see the top...

Code: [Select]
function on_paint(gr) {
    gr.FillGradRect(0, 0, ww, wh, 270, utils.GetSysColor(15), RGB(255,255,255));
    gr.SetSmoothingMode(2);
    gr.FillRoundRect(5, -8, ww-10, 48, 8, 8, RGB(210, 210, 210));
    gr.FillRoundRect(7, -6, ww-14, 44, 8, 8, RGB(245, 245, 245));
    gr.FillRoundRect(11, -2, ww-22, 40, 8, 8, RGB(245, 247, 246));
    drawAllButtons(gr);
}

WSH Panel Mod script discussion/help

Reply #504
samples updated. 

i decided to split "similar artists" into it's own script and have reverted "simple biography" to how it was before.

each "similar artist" now has a "search spotify" button as i think this is more useful than using foo_lastfm_radio.



Nice script!
But multiple tag value is not supported, it is sad.

WSH Panel Mod script discussion/help

Reply #505
Marc, I've tried your Similar Artists panel, but I can't get the spotify buttons to work.  I guess I have to install the spotify protocol on my machine, but I don't know how.  Do I need to install the despotify frontend?
Can you help a newbie like me?

WSH Panel Mod script discussion/help

Reply #506
i have spotify free installed. i have no idea what despotify is? when you install the spotify app, the "spotify:" protocol automatically links in so it opens the app with the search results listed.

WSH Panel Mod script discussion/help

Reply #507
i have spotify free installed. i have no idea what despotify is? when you install the spotify app, the "spotify:" protocol automatically links in so it opens the app with the search results listed.

Thanks.  Unfortunately, spotify is not available here (Belgium), and I can't download it.

Despotify is an open source implementation of the spotify app.  I don't know it, and I will not try to install it, as I prefer to stay in foobar for all audio and radio related stuff.

Maybe you should consider to make the spotify buttons optional, as spotify is available only in a few lands, and anyway, some users may prefer to not have to download the official app just to use that buttons.  (I have already replaced them with "play last.fm artist radio' buttons, so I don't need an update, but I think other users may need it.)

WSH Panel Mod script discussion/help

Reply #508
ok, i can add an option to make them optional. i'll do it over the weekend sometime.

edit: i didn't realise it was so restricted. i just checked and you can only get it in

Quote
Sweden, Norway, Finland, the UK, France, Spain and the Netherlands


i knew it wasn't available in the US but i thought more european users could use it. oh well.


WSH Panel Mod script discussion/help

Reply #510
ok, i can add an option to make them optional. i'll do it over the weekend sometime.

edit: i didn't realise it was so restricted. i just checked and you can only get it in

Quote
Sweden, Norway, Finland, the UK, France, Spain and the Netherlands


i knew it wasn't available in the US but i thought more european users could use it. oh well.

Yes, except in Belgium!  :-(

IMO, instead of the option to make the spotify buttons optional, the user should be able to chose the old behaviour (play last.fm radio).  It's also less work for you.  You have just to change the icon, the tooltip and the command, and you don't have to do different calculations for the layout of the window.

BTW, I have had to modify several of your panels, as they don't work well when a radio is playing, because the dynamic track info is not monitored.
I realized too that I don't want to permanently save the xml and images files downloaded from last.fm for the radio artists, as I don't necessarily like all artists I hear on the radios.  So, I have modified the scripts so that, when a radio is playing, it saves its files in my temp folder (with the artist name in the file names), and it removes them when the script is unloaded (when foobar is closed).  Unfortunately, I had to hardcode the temp folder, because I don't know how to retrieve the %temp% environment variable of Windows.  Do you know how to do it?  Is it possible?

WSH Panel Mod script discussion/help

Reply #511
IMO, instead of the option to make the spotify buttons optional, the user should be able to chose the old behaviour (play last.fm radio).  It's also less work for you.  You have just to change the icon, the tooltip and the command, and you don't have to do different calculations for the layout of the window.


done.

Quote
Unfortunately, I had to hardcode the temp folder, because I don't know how to retrieve the %temp% environment variable of Windows.  Do you know how to do it?  Is it possible?


google?

Code: [Select]
var WshShell = new ActiveXObject("WScript.Shell"); //this line is already in my common.js
var envVars = WshShell.Environment("USER");
var temp_path = envVars.Item("TEMP");


WSH Panel Mod script discussion/help

Reply #513
Thanks to you both!  I've googled, of course, and found the Environment object, but I'm new to the Windows programming environment, and I find the doc pages confusing.  I did not know that it was possible to link WScript.Shell.Environment together.  (Finding the right objects is the major difficulty in object oriented programming imo.  I will have to study that stuff...)

WSH Panel Mod script discussion/help

Reply #514
I know this is off current discussion but it says : "discussion/help" and I need some help with the following:

1. Panels switching inside Foobar only shows after resizing the main window. Should be immidiate. "Tech" was able to do it right but I dunno how.
2. Fade back transition from hover to normal is not smooth how to fix ?
3. How to tell the button to remain in changeState(2) which is the active state until hitting another button ?
Thanks for helping me out

WSH Panel Code:

Code: [Select]
// ==PREPROCESSOR==
// @import "%fb2k_path%\skins\foooffice\scripts\Flags.txt"
// @import "%fb2k_path%\skins\foooffice\scripts\Helpers.txt"
// @import "%fb2k_path%\skins\foooffice\scripts\Buttons.txt"
// ==/PREPROCESSOR==
var DT_LEFT = 0x00000000;
var DT_RIGHT = 0x00000002;
var DT_TOP = 0x00000000;
var DT_CENTER = 0x00000001;
var DT_VCENTER = 0x00000004;
var DT_WORDBREAK = 0x00000010;
var DT_CALCRECT = 0x00000400;
var DT_NOPREFIX = 0x00000800;
var DT_END_ELLIPSIS = 0x00008000;

var g_timer_started = false;
var g_timer;
var WshShell = new ActiveXObject("WScript.Shell");
var button_font = gdi.font("Calibri", 12, 0);
var gen_font = gdi.font("Calibri", 12, 0);
var codec_font = gdi.font("segoe ui", 14, 0);
var settings_dir = fb.FoobarPath + "skins\\foooffice\\settings\\";
var img_dir = fb.FoobarPath + "skins\\foooffice\\images\\";
var script_dir = fb.FoobarPath + "skins\\foooffice\\scripts\\";

function on_paint(gr) {
Foobar_hWnd = utils.GetHWND("{E7076D1C-A7BF-4f39-B771-BCBE88F2A2A8}");
utils.CreateGlass(Foobar_hWnd, 0, 0, 30, 0)
gr.FillSolidRect(0, 0, ww, 30, 0xFF000000);
  for (var i in $buttons) {
    $buttons[i].draw(gr);
  }
}

function on_size() {

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

  if (ww <= 0 || wh <= 0) return;

$buttons = {
    button_1: new Button(5, 5, FILETAB.width / 3, FILETAB.height, FILETAB, function () {
      update_option("panel_id",1);
      }),
    button_2: new Button(60, 5, PLAYINGTAB.width / 3, PLAYINGTAB.height, PLAYINGTAB, function () {
      update_option("panel_id",2);
      })
  }
window.Repaint();
    
}

function on_mouse_move(x, y) {
buttons_on_mouse_move(x, y);
}

function on_mouse_lbtn_down(x, y) {
buttons_on_lbtn_down(x, y);
}

function on_mouse_lbtn_up(x, y) {
buttons_on_mouse_lbtn_up(x, y);
}

function on_mouse_leave() {
buttons_on_mouse_leave();
}

function on_timer(id) {
button_on_timer(id);
}

function update_option(optname, optvalue) {
    var fso, f1, ts, s;
    var ForReading = 1;
    var ForWriting = 2;
    fso = new ActiveXObject("Scripting.FileSystemObject");

    ts = fso.OpenTextFile(settings_dir + optname + ".txt", ForReading);
    s = ts.ReadLine();
    ts.Close();

    f1 = fso.MoveFile(settings_dir + optname + "_" + s, settings_dir + optname + "_" + optvalue);

    ts = fso.OpenTextFile(settings_dir + optname + ".txt", ForWriting);
    ts.WriteLine(optvalue);
    ts.Close();
    return optvalue;
}

function read_option(optname, initvalue) {
    var fso, ts, ts2, s;
    var ForReading = 1;
    var ForWriting = 2;
    fso = new ActiveXObject("Scripting.FileSystemObject");

    if (file_exists(settings_dir + optname + ".txt") == true) {
        ts = fso.OpenTextFile(settings_dir + optname + ".txt", ForReading);
        s = ts.ReadLine();
        ts.Close();
        return s;
    } else {
        ts = fso.CreateTextFile(settings_dir + optname + ".txt", ForWriting);
        ts.WriteLine(initvalue);
        ts.Close();
        ts2 = fso.CreateTextFile(settings_dir + optname + "_" + initvalue, ForWriting);
        ts2.Close();
        return initvalue;
    }
}



This is the imported Buttons.txt

Code: [Select]
var imgPath = fb.FoobarPath + "skins\\foooffice\\images\\";
var FILETAB = gdi.Image(imgPath +"buttons\\tab_file_sprite.png");
var PLAYINGTAB = gdi.Image(imgPath +"buttons\\tab_playing_sprite.png");
var button_timer = false;
var button_timeout;
var button_font = gdi.font("Lucida Sans Unicode", 10, 0);
var g_font = gdi.font("segoe_ui", 14, 0);
var xy = false;
var hbtn;
var dbtn;

function Button(x, y, w, h, o, onclick) {

    this.x = x;
    this.y = y;
    this.w = w;
    this.h = h;
    this.o = o;
    this.onclick = onclick;
    this.oldstate = 0;
    this.state = 0;
    this.opacity = 0;
    this.refresh = 0;
    

    this.xy = function (x, y) {
        
        return (this.x <= x) && (x <= this.x + this.w) && (this.y <= y) && (y <= this.y + this.h);
    }

// ===================================  
    
    this.changeState = function (state) {
    
        if (!button_timer) button_timer = window.CreateTimerInterval(60);
        
        this.oldstate = this.state;
        this.state = state;
        this.opacity = 0;
        this.refresh = 1;

        switch (state) {

        case 0:
            this.step = 35;
            window.SetCursor(32512);
            break;

        case 1:
            this.step = 55;
            window.SetCursor(32649);
            break;

        case 2:
            this.step = 75;
            break;

        };

    }

// =================================== Image Button
    
    this.draw = function (gr) {

        if (this.opacity < 255) gr.DrawImage(this.o, this.x, this.y, this.w, this.h, this.oldstate * this.w, 0, this.w, this.h, 0, 255);
        if (this.opacity) gr.DrawImage(this.o, this.x, this.y, this.w, this.h, this.state * this.w, 0, this.w, this.h, 0, this.opacity);
  };
  
// ===================================
    
    this.RefreshOpacity = function () {
        
        if (this.opacity < 255) this.opacity = Math.min(this.opacity + this.step, 255);
        else {            
            this.oldstate = this.state;
            this.opacity = 0;
            this.refresh = 0;
        if (this.opacity == 0) button_timeout = window.CreateTimerTimeout(5000);
           }
          
         window.RepaintRect(this.x, this.y, this.w, this.h+2);

    };

// ===================================
    
    this.onClick = function () {
        
        this.onclick && this.onclick();
    }
}

// ========================================================================== //

buttons_on_mouse_move = function(x, y){

    xy = false;

    for (var i in $buttons)

    if ($buttons[i].xy(x, y)) {

    xy = true;

    if (hbtn != $buttons[i]) {
      if (hbtn) hbtn.changeState(0);
        hbtn = $buttons[i];
        hbtn.changeState(1);
        };
    }
    
    if (xy == false) {
        if (hbtn) {
        hbtn.changeState(0);
        hbtn = undefined;
        };
    }
}

// ========================================================================== //

buttons_on_lbtn_down = function (x, y) {

    if (hbtn) {
        dbtn = hbtn;
        dbtn.changeState(2);
        hbtn = undefined;
    }
}

// ========================================================================== //

buttons_on_mouse_lbtn_up = function (x, y) {

    if (dbtn) {
        dbtn.changeState(1);
        dbtn.onClick();
        dbtn = undefined;
    }
}

// ========================================================================== //

buttons_on_mouse_leave = function () {

    if (hbtn) {
        hbtn.changeState(0);
        hbtn = undefined;
    }

    on_size();
    window.Repaint();
    
    }


// ===================================

button_on_timer = function (id) {

    if (button_timeout && id == button_timeout.ID) {
        if (button_timer) window.KillTimer(button_timer);
        button_timer = false;

    }

    for (var i in $buttons) {
        if ($buttons[i].refresh) {
            $buttons[i].RefreshOpacity();
        }
    };

}


Here you can download the pack for use in columnsUI

http://hotfile.com/dl/63610538/4ccaadb/foooffice.zip.html

Wshpanel Pastebin

Buttons.txt Pastebin

WSH Panel Mod script discussion/help

Reply #515

Hi marc2003, your sample scripts are awesome! Finally something a newbie can use without cracking his head!

I just have problems making the scripts (e.g. "now playing") to follow the current selection instead of the song played. I tried this, but it didnt work (replaced line #131):

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.


Any ideas?

WSH Panel Mod script discussion/help

Reply #516
Does anyone know of a way to differentiate whether or not the current playlist is an autoplaylist?  If there's no variable available to WSH Panel Mod is there a component that can automatically append something to the playlist's name that I can parse in WSH Panel Mod?  Thanks.

 

WSH Panel Mod script discussion/help

Reply #517
Any ideas?

If you're running Vista or Win7, maybe you have not edited the right file.  Due to the way Windows now redirects your changes in protected directories to %AppData%\Local\VirtualStore, your edits are not stored where WSH expects to find them.  You should copy common.js somewhere where you have all access rights, edit it, and copy the modified version in the scripts folder, overwriting the original file.
(I'm not sure it's really your problem, but I've faced a similar problem under Win7.)

BTW, Marc, could you consider to change the default location of your scripts?  With UAC enabled, it is a pain to modify them in the foobar installation folder.  Anyway, the Program Files folder should never be modified directly by the user.  And now, the new beta version of foobar stores the optional components in the user's profile directory.  It seems logical to do the same thing for the WSH scripts.

WSH Panel Mod script discussion/help

Reply #518
Any ideas?

If you're running Vista or Win7, maybe you have not edited the right file.  Due to the way Windows now redirects your changes in protected directories to %AppData%\Local\VirtualStore, your edits are not stored where WSH expects to find them.  You should copy common.js somewhere where you have all access rights, edit it, and copy the modified version in the scripts folder, overwriting the original file.
(I'm not sure it's really your problem, but I've faced a similar problem under Win7.)


Thanks for the help, but this wasn't the problem. I just figured out I made a mistake in testing and also some of the scripts needed some tweaking to work.

WSH Panel Mod script discussion/help

Reply #519
FooTheEchoNest

Provides information from http://developer.echonest.com

  • Song (screenshot)
  • Biography
  • Review
  • Blog
  • News
  • Terms
  • Similar Artists




Installation:
Download of "Powered By The Echo Nest" banner:
http://the.echonest.com/media/images/logos/140x50_dk.gif
Copy banner to (Profile)\foobar2000\pictures\

Script download: http://pastebin.de/9468

Updates: http://foobar-users.de/index.php?topic=200...g17505#msg17505

WSH Panel Mod script discussion/help

Reply #520
Hallo,

I'm looking to create a button that changes when you mouse over it, like you get with the standard panel stack splitter behavior. I'm mostly sorted except I cant find out what function I need to create the mouse over behavior. Is it on_mouse_over I need or something similar?

Cheers

WSH Panel Mod script discussion/help

Reply #521
Marc, having trouble with your similar artists script in regards to playing a last.fm radio station...

I have foo_lastfm_radio installed, with my username and pass filled in, as well as all associations regarding last.fm:// squared away, yet I'm still getting the error message when I try to click on a radio link.


WSH Panel Mod script discussion/help

Reply #523
Marc, having trouble with your similar artists script in regards to playing a last.fm radio station...

I have foo_lastfm_radio installed, with my username and pass filled in, as well as all associations regarding last.fm:// squared away, yet I'm still getting the error message when I try to click on a radio link.


Fixed this by inseting sa_artists[index] into line 156 instead of whatever was there before for the artist name 

WSH Panel Mod script discussion/help

Reply #524
oops. i've fixed the online version as well. i stupidly copy/pasted that section from another script which uses different names.