IPB

Welcome Guest ( Log In | Register )

> foobar2000 General Forum Rules

This is NOT a tech support forum.
Tech support questions go to foobar2000 Tech Support forum instead.

See also: Hydrogenaudio Terms of Service.

 
Reply to this topicStart new topic
Is it possible to have an 'always alive' toolbar button, which is independent of active, selected, or playing states?
derty2
post May 13 2012, 04:52
Post #1





Group: Members
Posts: 580
Joined: 5-June 11
Member No.: 91257



I use fb2k with Columns UI.

I have been adding custom buttons to my fb2k layout, some are via the standard toolbar and some are via a WSH Panel Mod panel.
After a lot of playing around, I have noticed that it is not possible to have a button which will always run regardless if there
is nothing selected or playing in the playlist.

This particular button I had in mind is using the foo_run (Run services) component to run a VBS script which launches a custom
pop-up menu of my own creation. I want to get access to my pop-up menu at any time while foobar2000 is running, irrespective
of the playlist activity.

I can't seem to get it to work.
The buttons called via the WSH script will only run relative to a playing track in the playlist; if no playing track, then no working button.
The buttons called via the Toolbar will only run relative to a selected item in the playlist; if no selected item, then no working button.

While foobar2000 is running, if you go to "View -> Console" then the console window will pop up, irrespective of the playlist activity
or any other state.

Basically, I want a toolbar button with the same capability. Is it possible to do this (from a basic layout editing perspective)?
Go to the top of the page
+Quote Post
marc2003
post May 13 2012, 11:18
Post #2





Group: Members
Posts: 4440
Joined: 27-January 05
From: England
Member No.: 19379



it's perfectly possible to have a WSH panel mod button work at any time independent of any playlist selection/playback.
Go to the top of the page
+Quote Post
q-stankovic
post May 13 2012, 11:50
Post #3





Group: Members
Posts: 1740
Joined: 28-May 06
From: Düsseldorf
Member No.: 31251



QUOTE (derty2 @ May 13 2012, 05:52) *
The buttons called via the Toolbar will only run relative to a selected item in the playlist; if no selected item, then no working button.
You like to call a command that act like one from the main menu (independent of any selection) but foo_run commands are placed in context menu and therefore require a selection.


--------------------
german support forum: www.foobar-users.de / user: qwert73
Go to the top of the page
+Quote Post
derty2
post May 13 2012, 12:09
Post #4





Group: Members
Posts: 580
Joined: 5-June 11
Member No.: 91257



marc2003, I can't do this alone I need your help; please elaborate and offer some working WSH code for one button ...PLEASE.
Go to the top of the page
+Quote Post
marc2003
post May 13 2012, 12:22
Post #5





Group: Members
Posts: 4440
Joined: 27-January 05
From: England
Member No.: 19379



as it's only one button, the whole panel reacts to the mouse click...

CODE
var WshShell = new ActiveXObject("WScript.Shell");
var img = gdi.Image("path\\to\\image.png");

function on_paint(gr) {
    gr.DrawImage(img, 0, 0, 20, 20, 0, 0, img.Width, img.Height);
}

function on_mouse_lbtn_up(x, y) {
    try {
        //put your command in the quotes. if running a local file, remember to use double backslashes in the path like in the img line above.
        WshShell.Run("http://hydrogenaudio.org");
    } catch(e) {
    }
}


on the line beginning gr.Draw... the first 0 is the left margin, the 2nd 0 is the top margin, and the 2 20s are width and height respectively. you can change those but don't edit the other stuff on the same line.

edit: file>preferences>tools>wsh panel mod. make sure safe mode is disabled. you need to do this if running external commands.

This post has been edited by marc2003: May 13 2012, 12:29
Go to the top of the page
+Quote Post
derty2
post May 13 2012, 13:26
Post #6





Group: Members
Posts: 580
Joined: 5-June 11
Member No.: 91257



Your code works perfect marc +++++ ...5 gold stars for you! ...Thanks a lot.

It ran a DOS Batch file perfectly and independently of the playlist.

One last question about your script;
I run foobar2000 in portable mode, and I tried to enter the path to my image as: "%fb2k_path%images\\M.png" but it did not get accepted.
So I entered the path as absolute: "F:\\music\\foobar2000\\images\\M.png" and the panel then worked.
Is it possible to enter relative paths in the WSH script ?
Go to the top of the page
+Quote Post
marc2003
post May 13 2012, 13:32
Post #7





Group: Members
Posts: 4440
Joined: 27-January 05
From: England
Member No.: 19379



there's no such thing as %fb2k_path% (even if it did exist, you'd have to use it with the fb.TitleFormat function in WSH panel mod)

in WSH panel mod, you can use these...

fb.FoobarPath
fb.ProfilePath (points to %appdata%\foobar2000 in normal mode or the same as fb.FoobarPath in portable mode)

This post has been edited by marc2003: May 13 2012, 13:37
Go to the top of the page
+Quote Post
derty2
post May 13 2012, 14:30
Post #8





Group: Members
Posts: 580
Joined: 5-June 11
Member No.: 91257



Thanks again marc.
For anybody else reading this thread looking for the exact same function, here is marc's WSH code fully tested and with helpful comments added
ready for your "copy-paste" pleasure into your own foobar2000:
CODE

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * WSH Panel Mod script for foobar2000 *
// * by marc2003 *
// * *
// * 'ALWAYS ALIVE' TOOLBAR BUTTON *
// * which works independently of active, selected or playing states *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
//
// * Notes:
// Variables to use for retrieving relative path to foobar2000.exe:
// ("fb.FoobarPath" or "fb.ProfilePath") . "fb.ProfilePath" points
// to "%appdata%\foobar2000" in normal mode or the same as "fb.FoobarPath"
// in portable mode .
//
// * Important !!!!!!
// Go to "File->Preferences->Tools>WSH Panel Mod" and make sure safe mode
// is disabled . You need to do this if running external commands .
//
// * WSH Panel Mod Configuration:
// Script Engine ..............: JScript
// Edge Style .................: None
// Pseudo Transparent .........: Unchecked
// Grab Focus .................: Checked
// Delay Load .................: Unchecked
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *


//////////////////////////////////////////////////////////////////////////
// PROGRAM DESCRIPTION: Launch a custom pop-up menu via a batch file //
//////////////////////////////////////////////////////////////////////////

var WshShell = new ActiveXObject("WScript.Shell");
//var img = gdi.Image("path\\to\\image.png");
var img = gdi.Image(fb.ProfilePath + "images\\M.bmp");

function on_paint(gr) {
// gr.DrawImage(img, left_margin, top_margin, width, height, 0, 0, img.Width, img.Height);
gr.DrawImage(img, 0, 0, 20, 20, 0, 0, img.Width, img.Height);
}

function on_mouse_lbtn_up(x, y) {
try {
//put your command in the quotes. if running a local file, remember to use double backslashes in the path like in the img line above.
WshShell.Run(fb.ProfilePath + "tools\\Menu-Launcher\\launcher.bat");
} catch(e) {
}
}
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 31st July 2014 - 10:58