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

WSH Panel Mod script discussion/help

Reply #1850
can i get somewhere windows8 metro desktop colors of current user?

WSH Panel Mod script discussion/help

Reply #1851
@marc2003

I am probably doing something stupid, but I cannot get the allmusic script to work even for popular albums that are at the allmusic site. Can you confirm that the actual foo_allmusic_mod.vbs and allmusic.txt scripts in the recent download link of post #1845 are the correct ones and working? I always get [fetching info] followed by [nothing found]. Or do you have any other suggestions or special instructions? The other internet search scripts like musicbrainz.txt & news-reviews-blogs.txt work fine.

WSH Panel Mod script discussion/help

Reply #1852
@marc2003

Thank you for the reply.
Yes, I was talking about your very useful allmusic script; as it by nature is dual mode I have implemented it in two WSH Panel Mod tabs: AMG bio/AMG review). A third tab is used for another of your charms, Musicbrainz Releases.
Offline reading in fb2k is really time-saving!
Getting back on topic: I will dig deeper into allmusic.txt, common4.js, and your modded version of romor's foo_allmusic.vbs to get a better understanding of what's happening. Plus of course the WSH Panel Mod documentation.
I'll be back, as someone once said in a movie.

WSH Panel Mod script discussion/help

Reply #1853
@romka18, maybe utils.GetSysColor(x). x is number, range 0 to 30 i *think*

@WilB, i doubt you're doing anything wrong - it does seem a bit temporamental. all i can suggest is try clearing the IE browser cache through its options and trying again.

@PeteG, in the allmusic script, inside the on_paint function, replace the default: section with this...

Code: [Select]
            gr.GdiDrawText(g_text, normal_font, g_textcolor, 6, 45 - (offset * row_height), ww - 16, text_rows * row_height, DT_WORDBREAK | DT_CALCRECT | DT_NOPREFIX);
            gr.FillSolidRect(0, 0, ww, 45, g_backcolor);
            gr.FillSolidRect(0, wh - 15, ww, 15, g_backcolor);
            gr.GdiDrawText(allmusic_type == 1 ? "Allmusic review" : "Allmusic bio", title_font, g_textcolor_hl, 6, 6, ww - 77, 24, DT_VCENTER | DT_END_ELLIPSIS | DT_CALCRECT | DT_NOPREFIX);
            gr.DrawLine(5, 29, ww - 10, 29, 1, g_textcolor_hl);
            up_btn.draw(gr);
            down_btn.draw(gr);


it seems ok on XP. i can't test on vista/7 at tmoment.

WSH Panel Mod script discussion/help

Reply #1854
hi please could someone post a nice volume bar script?

WSH Panel Mod script discussion/help

Reply #1855
@PeteG, in the allmusic script, inside the on_paint function, replace the default: section with this...

Yes! Colour me impressed! Thank you very much, marc2003.
Your new code snippet is doing the job flawlessly, except for a minor drawback: words compounded with a hyphen - record-making, fine-tuning
- are no longer wrapped after the hyphen, they are sent to the next line as a whole. It's just an observation. I've got precisely what I
asked for and I'm a happy man.
Dare I suggest that you put the new lines in the allmusic scipt, commented out and with a single line of explanation (I mean, why waste good
code)? Or am I the only person on Planet Earth with these nitpicking idiosynchrasies in regard of parentheses and quotation marks?

By the way: I haven't got the faintest idea of what's happing. I can see the difference between the new and the old default: section,
that's all. I have a long piece of homework to do, I guess. In the end DIYing is (well, can be) much more satisfying than begging others for
help. But for now GDI coding is close to Sanskrit in my view; my old arteries a hardening just fine, thank you.

it seems ok on XP. i can't test on vista/7 at tmoment.

On Vista 32-bit and 7 64-bit: Tested & Passed. foobar2000 1.1.15, WSH Panel Mod 1.5.6.
I created two Popup Panels (v0.1.4) each with an instance of WSH PM, one running the old allmusic script, the other the new script.
And did a lot of resizing the panels.

WSH Panel Mod script discussion/help

Reply #1856
i can improve the snippet i posted above. it's bit of an ugly hack but the main thing i wanted to test was appearance. now that's confirmed ok, i'll be updating all my scripts. infact i'm giving them all a major overhaul so it'll be a few weeks before i post the new version.

edit: samples updated with an updated allmusic script. just the marc2003 folder needs extracting. the script in the panel doesn't need updating. thanks to romor again - this is definitely working more consistently than before.

http://dl.dropbox.com/u/22801321/samples.zip


WSH Panel Mod script discussion/help

Reply #1857
Argh - struggling to capture in a js script the maximum pixel resolution of a display.  I thought window.MaxWidth was the correct command, but it returns a nonsensical answer of 2147483647.  I tried window.width and it returns the correct pixel width of my current display window and correctly changes as I resize that window, so I would expect MaxWidth to also return a pixel width.  For what it's worth, window.MaxHeight returns the same value of 2147483647 that I don't understand, while window.Height correctly returns the pixel height of my display window.  Any advice appreciated!

WSH Panel Mod script discussion/help

Reply #1858
use utils.GetSystemMetrics....

Code: [Select]
fb.trace(utils.GetSystemMetrics(16) + "x" + utils.GetSystemMetrics(17));


edit: this only gets the current resolution. i'm not sure if you can query what your monitor actually supports if you're running at a lower res.

window.Width and window.Height are the dimensions of the panel.

window.max/min width/height are for setting the max/min panel heights. this is useful if you want to lock the size.

WSH Panel Mod script discussion/help

Reply #1859
Works great, and thanks for the explanation as well.

WSH Panel Mod script discussion/help

Reply #1860
I thought window.MaxWidth was the correct command, but it returns a nonsensical answer of 2147483647.

Heh, it is not really a nonsensical answer. 2 147 483 647 (231 ? 1) is the maximum value that 32-bit signed integer can have

WSH Panel Mod script discussion/help

Reply #1861
2marc2003
no, GetSysColor() returns this colors:

but i try to get this ones:

i searched it in registry but didnt find them.

WSH Panel Mod script discussion/help

Reply #1862
Is there a script that replicates the information shown by CUI's Status Pane? I'd like to study such a thing for my own learning purposes.

WSH Panel Mod script discussion/help

Reply #1863
Is there a script that replicates the information shown by CUI's Status Pane? I'd like to study such a thing for my own learning purposes.


i've done a close thing for a config, but it's more the status bar than the status pane, get it and check the script here : http://fav.me/d4maqsc

WSH Panel Mod script discussion/help

Reply #1864
I'm trying to use utils.glob to return directories in a path, instead of files in the path. This appears to be possible based off of the FILE_ATTRIBUTE_DIRECTORY flag, but it doesn't seem to work. I've tried passing:
"C:\\temp\\"
"C:\\temp\\*"
"C:\\temp\\*."
"C:\\temp\\."

etc. and I only get the files in that path, but never the directories in that path which is all I want. I've tried some of the other flags, but still no joy.

Anybody have any ideas?

WSH Panel Mod script discussion/help

Reply #1865
I don't know of an elegant approach, but a crude method that works is to use utils.glob to grab the full file paths, then whack everything from the right up to the first \ for each array element, and then use a duplicate elimination function borrowed from ojdo's HTPC scripts with which you're probably familiar:
Code: [Select]
function eliminateDuplicates(arr) {
  var i,
      len = arr.length,
      out = [],
      obj = {};

  for (i=0; i<len; i++) {
    obj[arr[i]] = 0;
  }
  for (i in obj) {
    out.push(i);
  }
  return out;
}





WSH Panel Mod script discussion/help

Reply #1867
Any idea why I get an “invalid pointer” error on line 19 ever now and then (it has happened 3 times in 2 and a half months)?

WSH Panel Mod script discussion/help

Reply #1868
Help welcome - I recently updated obsolete timer functions in all my scripts, only below script refuses to work when I replace window.CreateTimerInterval with window.SetInterval.
I'm a non-coder, so you're welcome to point out my mistakes, important stuff missing, redundant stuff, runaway timers, endless loops etc.
Code: [Select]
// ==PREPROCESSOR==
// @name "Cover Panel" by Br3tt, mod by Zin-Uru, mod by TEA
// ==/PREPROCESSOR==

var g_tooltip = window.CreateTooltip();
var hover = null;
var g_img = null;

cover = function () {
    this.reset = function () {
        this.x = 0;
        this.y = 0;
    }
    this.update = function () {
        this.x = img_info.x;
        this.y = img_info.y;
    }
    this.swap = function (cover_source) {
        this.image = cover_source.image;
        this.x = cover_source.x;
        this.y = cover_source.y;
    }
}

var covers = Array(new cover, new cover);
var fader = 0;
var alphamax = 255;
var fading_step = 15.0;
var g_timer;
var g_refresh_timer = 40;
var g_metadb;
var is_stream = false;
var is_embedded;
var is_art;
var art_path = "";
var WshShell = new ActiveXObject("WScript.Shell");
var bg_dir = fb.FoobarPath + "\\skin\\";
var id = 0;
var img_info = {x: 0, y: 0, w: 0, h: 0};

function FormatImage(image, iw, ih) {
    if (!image || !iw || !ih) return image;

    var scale_w = ww / image.Width;
    var scale_h = wh / image.Height;
    var scale = Math.min(scale_w, scale_h);
    var pos_x = 0,
        pos_y = 0;
    img_info.w = iw;
    img_info.h = ih;

    if (scale_w < scale_h) pos_y = (wh - image.height * scale) / 2;
    else if (scale_w > scale_h) pos_x = (ww - image.Width * scale) / 2;

    var tmp_img = gdi.CreateImage(img_info.w, img_info.h);
    var gp = tmp_img.GetGraphics();
    gp.DrawImage(image, pos_x, pos_y, image.Width * scale, image.Height * scale, 0, 0, image.Width, image.Height);
    tmp_img.ReleaseGraphics(gp);
    CollectGarbage();
    return tmp_img;
}

function refresh_cover() {
    covers[0].swap(covers[1]);
    covers[1].reset();

    if (fb.PlaybackLength > 0 || !fb.IsPlaying) {
        is_stream = false;

        g_metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();
        if (!g_metadb) {
            on_playback_stop(4);
            return;
        }
        utils.GetAlbumArtAsync(window.ID, g_metadb, 0);

        is_embedded = false;
        if (g_metadb) {
            covers[1].image = FormatImage(utils.GetAlbumArtEmbedded(g_metadb.rawpath, 0), ww, wh, 7, 1, 0);
            g_img = utils.GetAlbumArtEmbedded(g_metadb.rawpath, 0);
            covers[1].update();
            if (covers[1].image) {
                is_embedded = true;
                is_art = false;
            } else {
                covers[1].image = FormatImage(utils.GetAlbumArtV2(g_metadb, 0), ww, wh, 7, 1, 0);
                g_img = utils.GetAlbumArtV2(g_metadb, 0);
                covers[1].update();
                if (!covers[1].image) {
                    is_art = false;
                    covers[1].image = FormatImage(gdi.Image(bg_dir + "no_cover.jpg"), ww, wh, 7, 1, 0);
                    covers[1].update();
                }
            }
        }

    } else if (fb.IsPlaying && fb.TitleFormat("$right($left(%path%,2),1)").Eval() != ":") {
        is_art = false;
        is_stream = true;
        covers[1].image = FormatImage(gdi.Image(bg_dir + "stream.jpg"), ww, wh, 7, 1, 0);
        covers[1].update();
    }
    window.Repaint();
}

function on_timer(id) {
    if (g_timer) {
        if (id == g_timer.ID) {
            fader = (fader > 0) ? fader - fading_step : 0;
            if (fader <= 0) g_timer && window.KillTimer(g_timer);
            window.Repaint();
        }
    }
}

function on_playback_stop(reason) {
    if (reason == 4 || (reason == 0 && !is_art)) {
        covers[0].swap(covers[1]);
        covers[1].image = FormatImage(gdi.Image(bg_dir + "no_cover.jpg"), ww, wh, 7, 1, 0);
        covers[1].update();
        fader = alphamax;
        g_img = null;
        g_timer = window.CreateTimerInterval(g_refresh_timer);
    }
    if (reason == 1 || reason == 0) {
        refresh_cover();
    }
}

function on_playback_new_track(info) {
    refresh_cover();
    fader = alphamax;
    g_timer = window.CreateTimerInterval(g_refresh_timer);
}

function on_paint(gr) {
    gr.FillSolidRect(0, 0, ww, wh, 0xFF000000);
    if (fader > 0) covers[0].image && gr.DrawImage(covers[0].image, covers[0].x, covers[0].y, covers[0].image.Width, covers[0].image.Height, 0, 0, covers[0].image.Width, covers[0].image.Height, 0, fader);
    covers[1].image && gr.DrawImage(covers[1].image, covers[1].x, covers[1].y, covers[1].image.Width, covers[1].image.Height, 0, 0, covers[1].image.Width, covers[1].image.Height, 0, 255 - fader);
}

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

function on_item_focus_change() {
    if (!fb.IsPlaying) {
        refresh_cover();
        fader = alphamax;
        g_timer = window.CreateTimerInterval(g_refresh_timer);
    }
}

function on_playlists_changed() {
    if (!fb.IsPlaying) on_item_focus_change();
}

function on_get_album_art_done(metadb, art_id, image, image_path) {
    art_path = image_path;
}

function on_mouse_lbtn_down(x, y) {
    var meta = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();

    if (!meta || !is_art) return;
    switch (true) {
    case(art_path == ""):
        break;
    default:
//      WshShell.run('"JPEGView.exe"' + '"' + art_path + '"');
        break;
    }
}

function on_mouse_move(x, y) {
    if (!hover && g_img) {
        g_tooltip.Text = (is_embedded ? "Embedded - " : "External - ") + g_img.Width + " x " + g_img.Height;
        g_tooltip.Activate();
        hover = true;
    }
}

function on_mouse_leave() {
    g_tooltip.Deactivate();
    hover = null;
}

WSH Panel Mod script discussion/help

Reply #1869
here is the modded version with new timer api

Code: [Select]
// ==PREPROCESSOR==
// @name "Cover Panel" by Br3tt, mod by Zin-Uru, mod by TEA
// ==/PREPROCESSOR==

var g_tooltip = window.CreateTooltip();
var hover = null;
var g_img = null;

cover = function () {
this.reset = function () {
this.x = 0;
this.y = 0;
}
this.update = function () {
this.x = img_info.x;
this.y = img_info.y;
}
this.swap = function (cover_source) {
this.image = cover_source.image;
this.x = cover_source.x;
this.y = cover_source.y;
}
}

var covers = Array(new cover, new cover);
var fader = 0;
var alphamax = 255;
var fading_step = 15.0;
var g_timer = false;
var g_refresh_timer = 40;
var g_metadb;
var is_stream = false;
var is_embedded;
var is_art;
var art_path = "";
var WshShell = new ActiveXObject("WScript.Shell");
var bg_dir = fb.FoobarPath + "\\skin\\";
var id = 0;
var img_info = {x: 0, y: 0, w: 0, h: 0};

function FormatImage(image, iw, ih) {
if (!image || !iw || !ih) return image;

var scale_w = ww / image.Width;
var scale_h = wh / image.Height;
var scale = Math.min(scale_w, scale_h);
var pos_x = 0,
pos_y = 0;
img_info.w = iw;
img_info.h = ih;

if (scale_w < scale_h) pos_y = (wh - image.height * scale) / 2;
else if (scale_w > scale_h) pos_x = (ww - image.Width * scale) / 2;

var tmp_img = gdi.CreateImage(img_info.w, img_info.h);
var gp = tmp_img.GetGraphics();
gp.DrawImage(image, pos_x, pos_y, image.Width * scale, image.Height * scale, 0, 0, image.Width, image.Height);
tmp_img.ReleaseGraphics(gp);
CollectGarbage();
return tmp_img;
}

function refresh_cover() {
covers[0].swap(covers[1]);
covers[1].reset();

if (fb.PlaybackLength > 0 || !fb.IsPlaying) {
is_stream = false;

g_metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();
if (!g_metadb) {
on_playback_stop(4);
return;
}
utils.GetAlbumArtAsync(window.ID, g_metadb, 0);

is_embedded = false;
if (g_metadb) {
covers[1].image = FormatImage(utils.GetAlbumArtEmbedded(g_metadb.rawpath, 0), ww, wh, 7, 1, 0);
g_img = utils.GetAlbumArtEmbedded(g_metadb.rawpath, 0);
covers[1].update();
if (covers[1].image) {
is_embedded = true;
is_art = false;
} else {
covers[1].image = FormatImage(utils.GetAlbumArtV2(g_metadb, 0), ww, wh, 7, 1, 0);
g_img = utils.GetAlbumArtV2(g_metadb, 0);
covers[1].update();
if (!covers[1].image) {
is_art = false;
covers[1].image = FormatImage(gdi.Image(bg_dir + "no_cover.jpg"), ww, wh, 7, 1, 0);
covers[1].update();
}
}
}

} else if (fb.IsPlaying && fb.TitleFormat("$right($left(%path%,2),1)").Eval() != ":") {
is_art = false;
is_stream = true;
covers[1].image = FormatImage(gdi.Image(bg_dir + "stream.jpg"), ww, wh, 7, 1, 0);
covers[1].update();
}
window.Repaint();
}

function on_playback_stop(reason) {
    if (reason == 4 || (reason == 0 && !is_art)) {
        covers[0].swap(covers[1]);
        covers[1].image = FormatImage(gdi.Image(bg_dir + "no_cover.jpg"), ww, wh, 7, 1, 0);
        covers[1].update();
        fader = alphamax;
        g_img = null;
        g_timer && window.ClearInterval(g_timer);
        g_timer = false;
        g_timer = window.SetInterval(function () {
            fader = (fader > 0) ? fader - fading_step : 0;
            if (fader <= 0) {
                g_timer && window.ClearInterval(g_timer);
                g_timer = false;
            }
            window.Repaint();
        }, g_refresh_timer);
    }
    if (reason == 1 || reason == 0) {
        refresh_cover();
    }
}

function on_playback_new_track(info) {
    refresh_cover();
    fader = alphamax;
    g_timer && window.ClearInterval(g_timer);
    g_timer = false;
    g_timer = window.SetInterval(function () {
        fader = (fader > 0) ? fader - fading_step : 0;
        if (fader <= 0) {
            g_timer && window.ClearInterval(g_timer);
            g_timer = false;
        }
        window.Repaint();
    }, g_refresh_timer);
}

function on_paint(gr) {
gr.FillSolidRect(0, 0, ww, wh, 0xFF000000);
if (fader > 0) covers[0].image && gr.DrawImage(covers[0].image, covers[0].x, covers[0].y, covers[0].image.Width, covers[0].image.Height, 0, 0, covers[0].image.Width, covers[0].image.Height, 0, fader);
covers[1].image && gr.DrawImage(covers[1].image, covers[1].x, covers[1].y, covers[1].image.Width, covers[1].image.Height, 0, 0, covers[1].image.Width, covers[1].image.Height, 0, 255 - fader);
}

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

function on_item_focus_change() {
    if (!fb.IsPlaying) {
        refresh_cover();
        fader = alphamax;
        g_timer && window.ClearInterval(g_timer);
        g_timer = false;
        g_timer = window.SetInterval(function () {
            fader = (fader > 0) ? fader - fading_step : 0;
            if (fader <= 0) {
                g_timer && window.ClearInterval(g_timer);
                g_timer = false;
            }
            window.Repaint();
        }, g_refresh_timer);
    }
}

function on_playlists_changed() {
if (!fb.IsPlaying) on_item_focus_change();
}

function on_get_album_art_done(metadb, art_id, image, image_path) {
art_path = image_path;
}

function on_mouse_lbtn_down(x, y) {
var meta = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();

if (!meta || !is_art) return;
switch (true) {
case(art_path == ""):
break;
default:
// WshShell.run('"JPEGView.exe"' + '"' + art_path + '"');
break;
}
}

function on_mouse_move(x, y) {
if (!hover && g_img) {
g_tooltip.Text = (is_embedded ? "Embedded - " : "External - ") + g_img.Width + " x " + g_img.Height;
g_tooltip.Activate();
hover = true;
}
}

function on_mouse_leave() {
g_tooltip.Deactivate();
hover = null;
}

WSH Panel Mod script discussion/help

Reply #1870
I don't know of an elegant approach, but a crude method that works is to use utils.glob to grab the full file paths, then whack everything from the right up to the first \ for each array element, and then use a duplicate elimination function borrowed from ojdo's HTPC scripts with which you're probably familiar:

I'm very familiar with ojdo's script (the one I'm working on is a HEAVILY modified version of his) but the remove duplicates function wouldn't really work for me. The problem was that I wanted to use wildcards in the folder paths. My use case is that I wanted to be able to detect other versions of an album on my hard drive. My folder naming convention is always the same, but I'll use differentiator tags at the end to denote other things. i.e. %Artist% - 2012 - %Album% [FLAC], etc. I wanted to be able to search for /%artist% - $year(%date%) - %album%*/ but it doesn't appear to be possible with what we have available in WSHPanelMod. I ended up creating a glob list and creating entries for each file type like so: "%artist% - $year(%date%) - %album% [FLAC]/*.flac" and "%artist% - $year(%date%) - %album% [dts]/*.dts" etc. Then if I get files returned from in that folder I know the folder exists.

http://msdn.microsoft.com/en-us/library/e1...v=vs.84%29.aspx

How do you use this in WSHPanelMod? Can I just drop that JScript code in? I've never used ActiveX objects before.


WSH Panel Mod script discussion/help

Reply #1872
Wow, that's slick.  I hereby dump the use of my crude method and will use this instead.  Thanks for the suggestion and showing an example, marc2003.

WSH Panel Mod script discussion/help

Reply #1873
Does anybody have an answer about this:

Any idea why I get an “invalid pointer” error on line 19 ever now and then (it has happened 3 times in 2 and a half months)?


Is it possible that the window global object is invalid in on_paint(graphics)? If yes, what could cause such behavior?

WSH Panel Mod script discussion/help

Reply #1874
step 6 from the notes & hints:

Quote
It's better to retrieve window width and height in callback function on_size(), because their values during startup is not reliable.


so i just follow the example that came in the scripts from the component developer....

Code: [Select]
var ww = 0, wh = 0;

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


then use ww & wh as you like in on_paint. never had any problems.