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

WSH Panel Mod script discussion/help

Reply #400
use that same script on pastebin but change

line 29:
func = function() { g_metadb.UpdateFileInfoSimple("love", ''); }

line 34:
func = function() { g_metadb.UpdateFileInfoSimple("love", 1); }

WSH Panel Mod script discussion/help

Reply #401
cool, thanks 

WSH Panel Mod script discussion/help

Reply #402
Hello, everyone.  I am very new to creating WSH panel mod scripts.  I've managed to read enough to learn how to make a working volume and playback slider so I have a basic understanding of how things work but I'm trying to create a track info "ticker" that scrolls the now playing info across a window (not bounce back and forth) and it seems to be quite a bit more complicated.  I'm not asking for someone to do my work for me, I'm just hoping someone could point me/tell me if I'm headed in the right direction as far as how I might go about creating this.  Anyways, here are my attempts to understand how I might go about doing this:

on a new track, use this titleformatting script of the now playing item as a string "%track% - %artist% - %album%"  and constantly make it scroll to the right by 1px increments
get the last character of the string
get the width of the last character of the string
delete the last character of the string
insert the last character of the string at beginning when the string has been scrolled to the right a distance equal to the width of the last character which was just deleted

To instruct the info to be gathered each time a new track is played I know I'll need to use: function on_playback_new_track(metadb) {}

I will need to update these variables each time the string is scrolled a distance equal to the width of the last character (I am going to use "hello" as an example string because I am unsure of how to get the "%track% - %artist% - %album%" of the currently playing track at the moment).

var ww = window.Width;
var wh = window.Height;
var txt = "hello"
var lastpos = txt.length-1;   
var info = txt.replace(txt.charAt(-1), txt.charAt(lastpos));
var info_new = info.slice(0, -1)

I don't think I've got this quite right yet but this is the effect I want to acheive:

hello
then "hello" continues to scroll to the right until the o is no longer visible in the window at which time it will be inserted before h...
ohell
then "ohell" continues to scroll to the right until the l is no longer visible in the window at which time it will be inserted before o...
lohel

etc...

What I DON'T want is for it to happen like this:

hello
ohell
oohell
ooohell

etc...

Maybe I'm going about this task completely wrong and you know a much more simple way.  In that case I'd love to hear it.  Thanks
Thank you so much for any advice.


WSH Panel Mod script discussion/help

Reply #404
Thanks.  I saw one similar to that but the one thing I wanted to do differently is to have it scroll in just one direction over and over again.  I might be wrong, but it seems like achieving this would require something very different than how the script does it there.


WSH Panel Mod script discussion/help

Reply #405
Maybe you looking something like this?




Code: [Select]
function RGB(r, g, b) {
    return (0xff000000 | (r << 16) | (g << 8) | (b));
}

var g_font = gdi.font("Tahoma", 24, 0);
var g_timer;
var i = 0;
var interval = 20;
var tw = 0;

function on_paint(gr) {

    gr.SetTextRenderingHint(5);

    var text = fb.TitleFormat("%title% - %artist% - %album%").Eval();

    tw = gr.CalcTextWidth(text, g_font);

    if (fb.IsPlaying) {

        if (g_timer) {

            gr.GdiDrawText(text, g_font, RGB(0, 0, 0), ww - i, 20, ww + tw, g_font.height + 5, format = 0)

        }

    }
}

function on_timer(id) {

    i = i + 1 * 1;
    if (i == ww + tw) i = 0;
    window.RepaintRect(ww - i -10, 17, tw + 20, g_font.height + 6);

}

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

   
        if (i == ww + tw) i = 0;
        if (i == 0) g_timer = window.CreateTimerInterval(interval);
   
}

function on_playback_new_track() {

    i = 0;
window.Repaint();
}

WSH Panel Mod script discussion/help

Reply #406
Thank you so much, ExtremeHunter!  Hahaha I can't believe I how complicated my ideas were compared to this. 

While I was trying to figure out how to get the automated scrolling, i managed to modify one of the wsh panel mod samples so that it allows the info to be dragged horizontally back and forth in case the window isn't displaying all of the text.  I'm sure there is a better way of doing this too but I thought I'd share it since it took me so much work to figure out (you'll probably notice some strange things going on here since i'm not very experienced, but it works just fine):

Code: [Select]
var DT_VCENTER = 0x00000004;
var DT_CALCRECT = 0x00000400;
var DT_NOPREFIX = 0x00000800;
var DT_SINGLELINE = 0x00000020;
var DT_END_ELLIPSIS = 0x00008000;
var DT_WORD_ELLIPSIS = 0x00040000;

var g_text;
var g_font = gdi.Font("Tahoma", 10);
var ww = 0, wh = 0;
var g_textcolor = 0xff787878;
var g_need_calc = true;
var g_textheight = 0;
var g_offset = 0;
var g_drag = false;
var g_drag_x = 0;
var g_textwidth;
var title_tf =  fb.TitleFormat("%title%");
var album_tf = fb.TitleFormat("%album%");
var artist_tf = fb.TitleFormat("%artist%");
var title;
var album;
var artist;


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

if(fb.IsPlaying) on_playback_new_track();

function on_playback_new_track(){
    g_metadb = fb.GetNowPlaying();
artist = artist_tf.EvalWithMetadb(g_metadb);
title = title_tf.EvalWithMetadb(g_metadb);
album = album_tf.EvalWithMetadb(g_metadb);
}

function on_paint(gr) {
    g_text = title + " - " + artist  + " - " + album;
    g_textwidth = gr.CalcTextWidth(g_text, g_font);
    if (g_need_calc) {
        calc();
    } else {
            if(fb.IsPlaying) {
        gr.GdiDrawText(g_text,g_font, g_textcolor, g_offset, 1, ww - g_offset, wh, DT_VCENTER | DT_END_ELLIPSIS | DT_NOPREFIX | DT_SINGLELINE);
            }
        }
}

function on_mouse_lbtn_down(x) {
    g_drag = true;
    g_drag_x = x;
}

function on_mouse_lbtn_up(x) {
    g_drag = false;
    g_offset=0;
    window.Repaint();
}

function on_mouse_move(x) {
    if (g_drag) {
        applyDelta(x - g_drag_x);
        g_drag_x = x;
    }
}

function calc() {
    var temp_bmp = gdi.CreateImage(1, 1);
    var temp_gr = temp_bmp.GetGraphics();
    arr = temp_gr.GdiDrawText(g_text, g_font, g_textcolor, 0, 0, ww, wh, DT_VCENTER | DT_SINGLELINE | DT_CALCRECT | DT_NOPREFIX).toArray();
    g_offset = 0;
    g_need_calc = false;
    temp_bmp.ReleaseGraphics(temp_gr);
    temp_bmp.Dispose();
    temp_gr = null;
    temp_bmp = null;
    window.Repaint();
}

function applyDelta(delta) {
    var temp = g_offset + delta;
    if ((temp <= ww / 2) && (temp >= ww / 2  - g_textwidth)) {
        g_offset = temp;
        window.Repaint();
    }
}

function reset() {
    g_need_calc = true;
    g_offset = 0;
}

WSH Panel Mod script discussion/help

Reply #407
Gentlemen, I wonder if any of you good scripters might be up to a bit of a challenge?

I've seen quite a few nice title bar panels throughout the thread, but I don't quite have the knowledge to figure out exactly what I need to make this work.

First of all, here's a picture of my setup:



What I'd like is a panel that replicates the behavior of titlebar (highlighted in red), but better. Perhaps having the time segment permantly placed at the left hand side without having to make two seperate panels as in this instance. I also wouldn't mind having color controls over different parts of the tag information.


But anyway, I realize this isn't a request thread, but if anyone has a script that might help me get started, please let me know. Thanks.

 

WSH Panel Mod script discussion/help

Reply #408
Gentlemen, I wonder if any of you good scripters might be up to a bit of a challenge?

I've seen quite a few nice title bar panels throughout the thread, but I don't quite have the knowledge to figure out exactly what I need to make this work.

First of all, here's a picture of my setup:



What I'd like is a panel that replicates the behavior of titlebar (highlighted in red), but better. Perhaps having the time segment permantly placed at the left hand side without having to make two seperate panels as in this instance. I also wouldn't mind having color controls over different parts of the tag information.


But anyway, I realize this isn't a request thread, but if anyone has a script that might help me get started, please let me know. Thanks.

maybe a easy task?
what's the current panel that shows time and info now?looks so bad
if my brain works,i guess what you want is a panel which can show the info and time in fixed places.
pin out your idea in a picture to let me get the right idea in your brain.....or what you want is just a WSH panel which can realize the effect in your current photo?
mad messy misanthropist morbid mused

WSH Panel Mod script discussion/help

Reply #409
Gentlemen, I wonder if any of you good scripters might be up to a bit of a challenge?

I've seen quite a few nice title bar panels throughout the thread, but I don't quite have the knowledge to figure out exactly what I need to make this work.

First of all, here's a picture of my setup:

. And like I said, I'd also love if it had $rgb support.

WSH Panel Mod script discussion/help

Reply #410
here you go-

Code: [Select]
function RGB(r,g,b) {
return (0xff000000|(r<<16)|(g<<8)|(b));
}

var DT_CENTER = 0x00000001;
var DT_VCENTER = 0x00000004;
var DT_END_ELLIPSIS = 0x00008000;
var DT_CALCRECT = 0x00000400;
var DT_NOPREFIX = 0x00000800;

var ww = 0, wh = 0;

var g_textcolor = RGB(19,240,236);
var g_backcolor = RGB(0,0,0);
var g_font = gdi.Font("Segoe UI", 26,1);

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

function on_paint(gr) {
    gr.FillSolidRect(0, 0, ww, wh, g_backcolor);
    if(fb.IsPlaying) {
        gr.GdiDrawText(fb.TitleFormat("%playback_time%[ / %length%]").Eval(), g_font, g_textcolor, 0, 0, 250, wh, DT_VCENTER | DT_CENTER | DT_END_ELLIPSIS | DT_CALCRECT | DT_NOPREFIX);
        gr.GdiDrawText(fb.TitleFormat("[%tracknumber% [/ %totaltracks% ]- ]%title%").Eval(), g_font, g_textcolor, 250, 0, ww-270, wh, DT_VCENTER | DT_CENTER | DT_END_ELLIPSIS | DT_CALCRECT | DT_NOPREFIX);
    }
}

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

function on_playback_stop(reason) {
if(reason != 2) window.Repaint();
}

function on_playback_time() {
    window.Repaint();
}


WSH Panel Mod script discussion/help

Reply #412
Maybe you looking something like this?

Hello ExtremeHunter, I have this old script that is a scrollbar with now playing info. It works well (for me) except for the scroll speed that is very slow. Do you think that your script can be adapted to this? Or you know another way to make this modify? I'm not a programmer so I don't know how to make working changes 
Many thanks in advance
Fabio

Code: [Select]
//--------
var weight_normal =400;
var weight_bold  =800;
var italic_no =0;
var italic    =1;
var uline_no  =0;
var uline    =1;
//--------
var align_top  =0;
var align_middle=1;
var align_bottom=2;

var align_left  =0;
var align_center=1;
var align_right =2;

var trim_no    =0;
var trim_chara  =1;
var trim_word  =2;
var trim_elips_chara =3;
var trim_elips_word  =4;
var trim_elips_path  =5;

var flag_rtl        =0x0001;
var flag_vert      =0x0002;
var flag_nofit      =0x0004;
var flag_dispctrl  =0x0020;
var flag_nofallback =0x0400;
var flag_trailspace =0x0800;
var flag_nowrap    =0x1000;
var flag_linelimit  =0x2000;
var flag_noclip    =0x4000;

function StrFmt(alignH,alignV,trim,flag){ return ((alignH<<28)|(alignV<<24)|(trim<<20)|flag); }
//--------
function RGB(r,g,b){ return (0xff000000|(r<<16)|(g<<8)|(b)); }
function RGBA(r,g,b,a){ return ((a<<24)|(r<<16)|(g<<8)|(b)); }
//--------
function TimeFmt(t){
var zpad = function(n){
var str = n.toString();
return (str.length<2) ? "0"+str : str;
}
var h = Math.floor(t/3600); t-=h*3600;
var m = Math.floor(t/60); t-=m*60;
var s = Math.floor(t);
if(h>0) return h.toString()+":"+zpad(m)+":"+zpad(s);
return m.toString()+":"+zpad(s);
}
//----------------------------------------------------------------------------

var g_font = gdi.Font( "bitstream vera sans mono",40);
var g_font1 = gdi.Font( "bitstream vera sans mono",40);
var g_timeFmt = fb.TitleFormat("%playback_time%[ / %length%]");
var g_titleFmt = fb.TitleFormat("%ARTIST% - %title%");
var g_fileinfo = null;

var g_drag = 0;
var g_drag_seek = 0;

var tic_ArtistAlbumText= { size:26, step:1};
var tic_SongTimeText= { size:20, step: 2};
resetTics();

function on_paint(gr){
var ww = window.Width;
var wh = window.Height;
var pos = 0;
var length = fb.PlaybackLength;
var songTimeText;
var artistAlbumText;
if(length > 0){
if(g_drag){
pos = window.Width * g_drag_seek;
songTimeText= "Seek " + TimeFmt(g_drag_seek * length) + " / " + TimeFmt(length);
} else{
pos = window.Width * (fb.PlaybackTime / length);
songTimeText= g_timeFmt.Eval();
artistAlbumText = g_titleFmt.Eval();
}
}

gr.FillGradRect(  0, 0,    pos, wh, 90, RGB(5,150,35), RGB(5,100,35)); //green scroll
gr.FillGradRect(pos, 0, ww-pos, wh, 90, RGB(0,0,0), RGB(0,0,0)); //black background

if(artistAlbumText==null) artistAlbumText= "";
gr.DrawString(getScrolledText(artistAlbumText, tic_ArtistAlbumText), g_font, RGB(255,255,255), 0, 0, ww, wh, StrFmt(align_left, align_center, trim_no, flag_nowrap | flag_noclip));

if(songTimeText==null) songTimeText= "";
gr.DrawString(getScrolledText(songTimeText, tic_SongTimeText), g_font1, RGB(255,255,255), 0, 0, ww, wh, StrFmt(align_right, align_center, trim_no, flag_nowrap | flag_noclip));
}

function getScrolledText(txt,tic) {
if(txt.length<=tic.size)
return txt;
if(tic.val>=(txt.length+tic.spacer.length))
tic.val= 0;
else
tic.val+= tic.step;
return (txt+tic.spacer+txt).substring(tic.val, tic.val+tic.size);
}

function resetTics() {
tic_ArtistAlbumText.val=0;
tic_ArtistAlbumText.spacer= "";
for(var i=0; i<=(tic_ArtistAlbumText.size/2); i++) tic_ArtistAlbumText.spacer+=' ';
tic_SongTimeText.val=0;
tic_SongTimeText.spacer= "";
for(var i=0; i<=(tic_SongTimeText.size/2); i++) tic_SongTimeText.spacer+=' ';
}

function on_size(){
resetTics();
}

function on_focus(focused){
//fb.trace("focus " + focused);
}
function on_key_down(key){
//fb.trace("key " + key);
}
function on_mouse_lbtn_down(x,y){
g_drag = 1;
}
function on_mouse_lbtn_up(x,y){
if(g_drag){
g_drag = 0;
g_drag_seek = x / window.Width;
g_drag_seek = (g_drag_seek<0) ? 0 : (g_drag_seek<1) ? g_drag_seek : 1;
fb.PlaybackTime = fb.PlaybackLength * g_drag_seek;
}
}
function on_mouse_move(x,y){
if(g_drag){
g_drag_seek = x / window.Width;
g_drag_seek = (g_drag_seek<0) ? 0 : (g_drag_seek<1) ? g_drag_seek : 1;
window.Repaint();
}
}
function on_mouse_wheel(delta){
//fb.trace("wheel " + delta);
}
//--------
function on_playback_starting(cmd, paused){
resetTics();
}
function on_playback_new_track(info){
resetTics();
window.Repaint();
}
function on_playback_stop(){
resetTics();
window.Repaint();
}
function on_playback_seek(time){
window.Repaint();
}
function on_playback_pause(state){
}
function on_playback_edited(){
}
function on_playback_dynamic_info(){
}
function on_playback_dynamic_info_track(){
}
function on_playback_time(time){
window.Repaint();
}
function on_volume_change(val){
}
//EOF

WSH Panel Mod script discussion/help

Reply #413
@Fabio258


Well your scroll uses per second window update and mine uses different timing, so they cannot be overlaped like this, but i made a little compromise  . It's a quick and ugly hack but ...


link

WSH Panel Mod script discussion/help

Reply #414
@Fabio258


Well your scroll uses per second window update and mine uses different timing, so they cannot be overlaped like this, but i made a little compromise  . It's a quick and ugly hack but ...


link


Many thanks, but it returns me this error:
Error: WSH Panel Mod (GUID: 97DC514D-0A5C-4D8F-875B-57D83D56C051): Errore di compilazione di Microsoft JScript:
Errore di sintassi
Ln: 242, Col: 7
      else


 

Fabio

WSH Panel Mod script discussion/help

Reply #415
How is that possible? There is only 206 lines in the script and your error is in line 242. 

WSH Panel Mod script discussion/help

Reply #416
How is that possible? There is only 206 lines in the script and your error is in line 242. 


I'm sorry, my mistake, having hurry to try before going to work, I didn't realize that copying and pasting the script had been added strange characters. 
Now it works fine.  I'm sorry that it's not possible to group all in one line because I use a seven inch touch screen monitor and have optimized the layout for this size, but obviously I can't have everything. 

Thanks again

Fabio

WSH Panel Mod script discussion/help

Reply #417
samples updated:

http://cid-649d3bfeaf541fbb.office.live.co...ide/samples.zip

contains a new script that displays thumbnails of images in a folder.


-no support for scrolling in thumbnail view if you have too many images to fit in the panel (in full view, you can use the mouse wheel to scroll through all images)
-it chokes a bit if you have a folder full of lots of large images

WSH Panel Mod script discussion/help

Reply #418
Hello

I'm trying to open album art with default Windows image viewer using wscript.shell. For some reason I get "source text only available in compile time" error with below script. g_metadb is defined.
Code: [Select]
var WshShell = new ActiveXObject("WScript.Shell");
var img_path = fb.titleformat("$replace(%path%,%filename_ext%,front.jpg)").EvalWithMetadb(g_metadb);

function(){WshShell.run("file://" + img_path);}

I tested a simple version (below) which works fine, so problem is with img_path variable. Also seems to work without "file://".
Code: [Select]
var WshShell = new ActiveXObject("WScript.Shell");

function(){WshShell.run("file://C:/1.png");}

WSH Panel Mod script discussion/help

Reply #419
Just a little update with my problem. Figured WScript.Shell doesn't like backslashes or spaces. img_path.replace(/\\/g, "/") sorted the slashes but I have no clue what to do with spaces. Googleing suggested using double or triple quotes but these give errors in wsh panel.

WSH Panel Mod script discussion/help

Reply #420
Maybe this helps.

Code: [Select]
var WshShell = new ActiveXObject("WScript.Shell");

function on_mouse_lbtn_dblclk() {

    g_metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();

    var img_path = fb.titleformat("$replace(%path%,%filename_ext%,front.jpg)").EvalWithMetadb(g_metadb);

    try {
        WshShell.Run("\"" + img_path + "\"");
    } catch (e) {};

}

WSH Panel Mod script discussion/help

Reply #421
Thanks "\"" + img_path + "\"" worked

WSH Panel Mod script discussion/help

Reply #422
[a href="http://matthijsb.deviantart.com/art/foo-silk-4-0-beta-4-170546750" target="_blank"]

WSH Panel Mod script discussion/help

Reply #423
i've updated my scripts with some last.fm charts as well....

http://cid-649d3bfeaf541fbb.office.live.co...ide/samples.zip



features:

click the last.fm logo in the top right to switch between artist, album and track. you can also change the period.
the text is clickable and it will open the corresponding page in your web browser
the artist charts have "play" buttons which will launch last.fm radio directly in foobar (requires foo_lastfm radio)
charts update once a day but you can force an update using the context menu if you really must