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

Re: WSH Panel Mod script discussion/help

Reply #4525
Sorry, it's unlikely anyone can help you with those versions - wshpanel is abandonned, but you could at least try to upgrade yours:
https://code.google.com/archive/p/foo-wsh-panel-mod/downloads

An old user Marc2003 created wshpanel scripts, and the one you want to find was called "status bar.txt" however I think he's wiped his online archive/presence.

All of the WSH work has been updated to JSPanel (also currently discontinued)
https://github.com/marc2k3/foo_jscript_panel/releases

and currently spider monkey panel (active):
https://hydrogenaud.io/index.php/topic,116669.0.html

Re: WSH Panel Mod script discussion/help

Reply #4526
i cannot upgrade my wshpanel (1.2.1) because the following version (1.3.0) requires different version of foobar
there are no plans to change my version of foobar
it's in use since 2009, and i's too complicated to create everything from scratch
i also don't need anything from the new foobar versions, i only try to make my setup more convenient, tidy and good-looking

even if i upgraded the wshpanel, then what are the commands/code/scripts that could help? (to obtain the 3 desired possibilities):
- selected tracks' total length
- total length of all tracks
- total quantity of tracks

does anyone still remember some aspects/commands/fuctions/scripts that could be useful in case of these 3 small and obvious wishes?

Re: WSH Panel Mod script discussion/help

Reply #4527
i found the "status bar + volume" txt:
Code: [Select]
// ==PREPROCESSOR==
// @name "Status Bar + Volume"
// @author "marc2003"
// @import "%fb2k_component_path%samples\complete\js\lodash.min.js"
// @import "%fb2k_component_path%samples\complete\js\helpers.js"
// @import "%fb2k_component_path%samples\complete\js\volume.js"
// ==/PREPROCESSOR==

var tfo = fb.TitleFormat('%__bitrate% kbps %codec% [%codec_profile% ][%__tool% ][%__tagtype% ]');

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

var properties = {
name : new _.p('2K3.STATUS.SHOW.NAME', true),
count : new _.p('2K3.STATUS.SHOW.COUNT', true),
duration : new _.p('2K3.STATUS.SHOW.DURATION', true),
size : new _.p('2K3.STATUS.SHOW.SIZE', true),
background : new _.p('2K3.STATUS.BACKGROUND', _.RGB(240, 240, 240)),
text : new _.p('2K3.STATUS.TEXT', _.RGB(0, 0, 0))
};
var font = _.gdiFont('Segoe UI', 11);
var ww = 0;
var wh = 0;
var right_text = '';
var right_text_width = 0;

var volume = new _.volume(0, 3, 100, font.Height - 9);

refresh();

function on_size() {
ww = window.Width;
wh = window.Height;
volume.x = ww - 190;
}

function on_paint(gr) {
gr.FillSolidRect(0, 0, ww, wh, properties.background.value);
if (fb.IsPlaying) {
gr.GdiDrawText(tfo.Eval(), font, properties.text.value, 5, -1, ww - right_text_width - 300, font.Height, LEFT);
}
if (plman.ActivePlaylist > -1 && plman.ActivePlaylist < plman.PlaylistCount) {
gr.GdiDrawText(right_text, font, properties.text.value, 0, -1, ww - 250, font.Height, RIGHT);
}
gr.DrawRect(volume.x, volume.y, volume.w, volume.h, 1, properties.text.value);
gr.FillSolidRect(volume.x, volume.y, volume.pos(), volume.h, properties.text.value);
gr.GdiDrawText(fb.Volume.toFixed(2) + ' dB', font, properties.text.value, 0, -1, ww - 5, font.Height, RIGHT);
}

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

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

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

function on_mouse_wheel(s) {
volume.wheel(s);
}

function on_mouse_move(x, y) {
volume.move(x, y);
}

function on_mouse_lbtn_down(x, y) {
volume.lbtn_down(x, y);
}

function on_mouse_lbtn_up(x, y) {
volume.lbtn_up(x, y);
}

function on_mouse_lbtn_dblclk() {
fb.RunMainMenuCommand('View/Show now playing in playlist');
}

function on_mouse_rbtn_up(x, y) {
var m = window.CreatePopupMenu();
var s = window.CreatePopupMenu();
var c = fb.CreateContextMenuManager();
var col = window.CreatePopupMenu();
if (fb.IsPlaying) {
c.InitNowPlaying();
c.BuildMenu(s, 1);
s.AppendTo(m, MF_STRING, 'Now playing');
m.AppendMenuSeparator();
}
m.AppendMenuItem(MF_STRING, 10000, 'Show playlist name');
m.CheckMenuItem(10000, properties.name.enabled);
m.AppendMenuItem(MF_STRING, 10001, 'Show playlist item count');
m.CheckMenuItem(10001, properties.count.enabled);
m.AppendMenuItem(MF_STRING, 10002, 'Show playlist duration');
m.CheckMenuItem(10002, properties.duration.enabled);
m.AppendMenuItem(MF_STRING, 10003, 'Show playlist size');
m.CheckMenuItem(10003, properties.size.enabled);
m.AppendMenuSeparator();
col.AppendMenuItem(MF_STRING, 10004, 'Background...');
col.AppendMenuItem(MF_STRING, 10005, 'Text...');
col.AppendTo(m, MF_STRING, 'Colours');
m.AppendMenuSeparator();
m.AppendMenuItem(MF_STRING, 10010, 'Configure...');
var idx = m.TrackPopupMenu(x, y);
switch (idx) {
case 0:
break;
case 10000:
properties.name.toggle();
refresh();
break;
case 10001:
properties.count.toggle();
refresh();
break;
case 10002:
properties.duration.toggle();
refresh();
break;
case 10003:
properties.size.toggle();
refresh();
break;
case 10004:
properties.background.set(utils.ColourPicker(window.ID, properties.background.value));
window.Repaint();
break;
case 10005:
properties.text.set(utils.ColourPicker(window.ID, properties.text.value));
window.Repaint();
break;
case 10010:
window.ShowConfigure();
break;
default:
c.ExecuteByID(idx - 1);
break;
}
_.dispose(m, s, c, col);
return true;
}

function on_playlist_items_added(p) {
if (p == plman.ActivePlaylist) {
refresh();
}
}

function on_playlist_items_removed(p) {
if (p == plman.ActivePlaylist) {
refresh();
}
}

function on_playlists_changed() {
if (properties.name.enabled) {
refresh();
}
}

function on_playlist_switch() {
refresh();
}

function refresh() {
var items = plman.GetPlaylistItems(plman.ActivePlaylist);
var count = items.Count;
var tmp = [];
if (properties.name.enabled) {
tmp.push(plman.GetPlaylistName(plman.ActivePlaylist));
}
if (properties.count.enabled) {
tmp.push(count + (count == 1 ? ' track' : ' tracks'));
}
if (properties.duration.enabled) {
tmp.push(utils.FormatDuration(items.CalcTotalDuration()));
}
if (properties.size.enabled) {
tmp.push(utils.FormatFileSize(items.CalcTotalSize()));
}
right_text = tmp.join(' :: ');
right_text_width = _.textWidth(right_text, font);
window.Repaint();
_.dispose(items);
}
it contains potentially interesting words like:
- plman.PlaylistCount
- plman.ActivePlaylist
- items.CalcTotalDuration
- Show playlist item count
- Show playlist duration
but i don't know how it should be modified

and i haven't noticed anything related to the "selected tracks' total length"
for example, something like "Show playlist selected items duration"

when simply trying this code as it is, foobar indicates the following error: Scripting Engine Initialization Failed

Re: WSH Panel Mod script discussion/help

Reply #4528
We've already been down that path - that sample is for JSPanel/spider monkey panel.

Your time is better spent posting your setup and getting assistance to update; it's unlikely to be as difficult as you think.
There are more people here suited to help with that, than there are to troubleshoot expired components and scripts.

Re: WSH Panel Mod script discussion/help

Reply #4529
Quote
you should find a sample script "status bar + volume.txt"
so the necessary original wsh-version of this script doesn't exist anymore. and seemingly nobody has any copies. is it correct?

Quote
which has the foundation of what you are looking for
is this foundation totally absent in the posted JSPanel-version of the script? and nobody has absolutely nothing to advice/suggest/help. i hope it's not true
(thank you for the answers, i appreciate that. but words about switching/migrating/upgrading are not the help in my case)

Quote
It will be much easier to modify than starting over
this is really the appropriate way for me - "to modify". can you please help me with it?
"starting over" is not an option (there are reasons for it. for example, i'm using the windows-OS which is not 10/8/7)

there are just 3 small and very simple and understandable things that are missing in my setup:

1. show total quantity of tracks of the active playlist
(i have it now as i need via the "playlist switcher"-panel but there is huge trouble with it)

2. show total length of all tracks of the active playlist
(i also have it now as i need via the "playlist switcher"-panel but there is the same huge trouble with it
the trouble is quite hard to describe properly:
it is a graphical issue and the main problem is that the vertical scrollbar of the playlist switcher is visible
are there any ways to just hide it? unfortunately, i don't think it's possible)

3. show selected tracks' total length
(this is the most important thing among these 3 items)
(status bar should stay hidden so there is no way for me to get this option/functionality at the moment)


are there some different ways to get/achieve/script/implement these 3 items?
for example, there is the "duration" line in the "properties (propertis tab)"
the line can display the total length of the selected tracks
are there any ways to grab the necessary info from this line and display this info via wsh-panel or some other panel?

another example: there is the "foo_uie_playlists_dropdown.dll" component. i never used it but tried it yesterday
after a short and easy process of customizing, this component allowed me to have the first 2 items implemented (of the above-mentioned 3 items)
unfortunately, there were several graphical aspects/issues that didn't allow me to keep and to use this component

Re: WSH Panel Mod script discussion/help

Reply #4530
after many days of different attempts to re-customize foobar, i managed to get some success (various forced compromises and inconveniences are still present)

(speaking about the 3 tasks that were previously mentioned in this topic)
here is the only task that's left to be done:
a code which allows foobar to show selected tracks' total length (status bar is always hidden)

i cannot write this code. and i'm not absolutely sure that such code could be created
but in case it could:
i found a list which contains some kind of related commands. could they really be useful as parts of the code?:

window.GetProperty(name[, defaultval])
fb.ActivePlaylist
fb.TitleFormat(expression)
fb.GetSelection()
fb.GetSelectionType()
fb.GetSelections([flags])
fb.AcquireUiSelectionHolder()
fb.PlaylistItemCount(idx)
plman.ActivePlaylist
plman.PlaylistItemCount
plman.InsertPlaylistItems(playlistIndex, base, handles[, select])
plman.InsertPlaylistItemsFilter(playlistIndex, base, handles[, select])
plman.MovePlaylistSelection(playlistIndex, delta)
plman.GetPlaylistSelectedItems(playlistIndex)
plman.IsPlaylistItemSelected(playlistIndex, itemIndex)
on_playlist_items_selection_change()

Re: WSH Panel Mod script discussion/help

Reply #4531
Quote
you should find a sample script "status bar + volume.txt"
so the necessary original wsh-version of this script doesn't exist anymore. and seemingly nobody has any copies. is it correct?
- I have some old 'status bar' WSH samples, newest dated 12.10.2015. I didn't test it (compatibility, installation)
- I can send it to you in a private message just in case it's against the wishes of the author to distribute it publicly.
- There may be some incompatibilites (paths, versions etc.)
- I think it shows playlist's not selection's total time 



Re: WSH Panel Mod script discussion/help

Reply #4532
michtar
i'm starting to lose any hope to solve this problem so yes, please send me these samples
although i'm almost sure that i won't get something really useful in them
at the moment i tend to think that if the solution exists, it is somewhere in those related commands which are used in a new code

Re: WSH Panel Mod script discussion/help

Reply #4533
michtar, thank you for trying to help
sadly but i haven't found anything useful in that older 'status bar.txt':

- %playback_time%, %length%, %__bitrate%, %codec%, %codec_profile%, %__tool%, %__tagtype%
- the 'colors' stuff, the 'volume' stuff
- function on_paint, functions on_mouse...

does anyone know the way to get the possibility to see the total length of the selected tracks immediately?
(without a necessity to open the 'properties (properties tab)' sub-window every time)
(and without constant contemplating of almost empty and useless and ugly status bar)

Re: WSH Panel Mod script discussion/help

Reply #4534
michtar, thank you for trying to help
sadly but i haven't found anything useful in that older 'status bar.txt':

- %playback_time%, %length%, %__bitrate%, %codec%, %codec_profile%, %__tool%, %__tagtype%
- the 'colors' stuff, the 'volume' stuff
- function on_paint, functions on_mouse...

thout constant contemplating of almost empty and useless and ugly status bar)
I tested it and the old WSH sample works almost the same way as foo_jscript_panel one. It shows total length of the tracks in the playlist.

You can check it for yourself:
- install newer foobar version
- install wsh_panel_mod
- copy content of the .zip from the link I posted into wsh_marc2003 directory in foobar's config directory
- if I were to guess  :) which part is responsible for the feature you seek it would be somewhere here:
Code: [Select]
function refresh() {
var items = plman.GetPlaylistItems(plman.ActivePlaylist);
count = items.Count;
var size = 0;
var length = 0;
for (var i = 0; i < count; i++) {
size += _.parseInt(_.tf("$if2(%filesize%,0)", items.item(i)));
length += Math.max(items.item(i).Length, 0);
}
right_text = count + (count == 1 ? " track :: " : " tracks :: ") +


Re: WSH Panel Mod script discussion/help

Reply #4535
There's an upload of the "WSH_Artwork_Viewer.7z" here:
https://www.4shared.com/archive/jTKjPJaS/WSH_Artwork_Viewer.html
The 4shared website isn't working for me, and it's also generally more suspicious and unreliable compared to other file sharing services.

Can someone either:
1. Upload the file elsewhere (whether by downloading it again or by finding a copy of it, if they have one saved)
2. Paste the contents of the file in this thread

Thanks

Edit: Disregard that, I suck cocks. Apparently the newest iteration of this plugin has included a script that's even better:
https://hydrogenaud.io/index.php?topic=116669.msg991455#msg991455
Although I have different issues with that particular script, so I would still appreciate someone reuploading the WSH_Artwork_Viewer.

Re: WSH Panel Mod script discussion/help

Reply #4536
I haven't been here a long time ..

now I like to ask the following:
is a function available to start playing of a track?
the information of the playlistlist and the desired item of it is available by another function.
I just dont't have a command or function of wsh to start playing the track.....

any ideas?


Re: WSH Panel Mod script discussion/help

Reply #4538
thanks

.. I tried it, but it doesn't play the track (nor another one)
what might be a reason for a lock as indicated in interfaces.txt?

Re: WSH Panel Mod script discussion/help

Reply #4539
A lock would prevent you from double clicking items in a normal playlist to start playback so it's unlikely to be that.

Make sure you have the latest version of fb2k because older versions had a bug preventing this from working properly if the specified playlistIndex wasn't already active. See the changelog for v1.6.3 http://foobar2000.org/changelog

Re: WSH Panel Mod script discussion/help

Reply #4540
the new version does not 'help' with this

even if i place
plman.ExecutePlaylistDefaultAction(fb.PlaylistItemCount(fb.ActivePlaylist), 2);

at the begiining of the script it does not play,
on the other hand
plman.SetPlaylistFocusItem(fb.ActivePlaylist, 2);
sets the focus to the 3rd item properly

hmmm...


Re: WSH Panel Mod script discussion/help

Reply #4542
a question to GetPlaylistSelectedItems
I understand how to use it to find out how many are selected with
plman.GetPlaylistSelectedItems(fb.ActivePlaylist).count;
this works

but i do not know how to get all the itemindices which are selected ...

 

Re: WSH Panel Mod script discussion/help

Reply #4543
I made the two forementioned work ...

another question:
is a write line to a text file possible in WSH panel?
I found the ReadTextFile function, but nothing to write a line

Re: WSH Panel Mod script discussion/help

Reply #4544
is a write line to a text file possible in WSH panel?
I found the ReadTextFile function, but nothing to write a line
https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/opentextfile-method
example
Code: [Select]
var fso = new ActiveXObject("Scripting.FileSystemObject");
var file_path = "C:\\text.txt"
if (!fso.FileExists(file_path)) fso.CreateTextFile(file_path);

file = fso.OpenTextFile(file_path, 8);
file.WriteLine("Hello, pakpak");
file.Close();
UR5EQF. Ukraine

Re: WSH Panel Mod script discussion/help

Reply #4545

ok, thanks.

but i am using the WSH with javascript along with other WSH code..
and with this somehow i cannot make a write working  like this:

var fs = require('fs');
fs.writeFile('helloworld.txt', 'Hello World!');

Re: WSH Panel Mod script discussion/help

Reply #4546
oh great discontinued.  well maybe someone can help i spent 1 hour finguring this out lol,
i'm trying to get a big text to show the current hour:minute
got that part done,
but how do i make it refresh? i cant figure it out (im no programmer) (edit: spidermonkey script seems to be different than wsh not been able to show time yet)
thanks !

 code:
basically i changed the initial WSH code only at the
var g_font = gdi.Font("Impact", 300, 0);
and
var g_text = g_date.getHours()+":"+g_date.getMinutes();
everything else basically stock

Re: WSH Panel Mod script discussion/help

Reply #4547
p90036
Code: [Select]
var g_text;
var clock_timer = window.SetInterval(on_timer, 1000);

function on_timer(id) {
    g_date = new Date();
    g_text = g_date.getHours() + ":" + g_date.getMinutes();
    window.Repaint();
}
UR5EQF. Ukraine

Re: WSH Panel Mod script discussion/help

Reply #4548
awesome thank you !!

Re: WSH Panel Mod script discussion/help

Reply #4549

ok, thanks.

but i am using the WSH with javascript along with other WSH code..
and with this somehow i cannot make a write working  like this:

var fs = require('fs');
fs.writeFile('helloworld.txt', 'Hello World!');


Here is a function I use to write to a file when playing each track with JScript Panel.

Code: [Select]
function on_playback_new_track(){
    var objFSO = new ActiveXObject("Scripting.FileSystemObject");
    var trktxt = (fb.ProfilePath + "\\played\\p.t");
    if (objFSO.Fileexists(trktxt)){
    }
    else {
            objFile = objFSO.CreateTextFile(trktxt, false);
            //objFile.Close();
    }
// add to played playlist
var timestamp = getTimestamp();
    timestamp = timestamp.replace(/^[0-9]{2}/g,"");
    timestamp = timestamp.replace(/:[0-9]{2}$/g,"");
//fb.trace(timestamp);
// add to played.txt
var checkpath1 = new RegExp("M:", "i");
var checkpath2 = new RegExp("E:\Music", "i");
if(fb.TitleFormat("%_path_raw%").Eval(true).match(checkpath1)){
return;
}
if(fb.TitleFormat("%_path_raw%").Eval(true).match(checkpath2)){
//return;
}

var metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();
    var ctrack;
    var ctrack2;
    var cpath;
    cpath = fb.TitleFormat("$directory_path(%path%)").Eval();
    cpath = cpath.replace(/^.{2}/g,"");
ctrack = fb.TitleFormat("%artist% - %title%, %filename_ext%, "+cpath+", ").Eval();
    ctrack2 = ctrack.replace(/((?![a-zA-Z0-9\s\)\(\-\_\&\!\'\<\>\.\,\+\:\;\?\\\{\}\=\*\^\%\$\#\@\~\`]).)+/g, "");
    ctrack2 = ctrack2.replace(/\.mp3/g, "");
    //ctrack2 = ctrack2.replace(/(I|D|E|H):\\\\/g, "");
//stream = (fb.TitleFormat("%_path_raw%").Eval()) + " - " + (fb.TitleFormat("%title%").EvalWithMetadb(metadb));
//fb.trace(ctrack + "(" + ctrack2 + ")");
    try {
        file_err = 0;
        objFile = objFSO.OpenTextFile(trktxt, 8, -1);
        if(objFile) {
        objFile.WriteLine(ctrack2 + timestamp);
        objFile.Close();
        }
    }
    catch(Err)
    {
            file_err = 1;
            fb.trace("objFile: " + Err);
    };
}