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: Multiple keyboard shortcuts in foobar2000? (foo_run or other method?) (Read 1519 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Multiple keyboard shortcuts in foobar2000? (foo_run or other method?)

Hi again. So, whenever I add new music to my library, I run a series of commands, and I've figured that rather than multiple combinations it'd be really useful to be able to use one shortcut and have that do all of them.

However, the keyboard shortcuts feature within foobar2000 doesn't allow me to assign multiple commands to one shortcut, they'll just conflict if I try. Given this isn't a feature, is there any other way I can do this reliably?

The issue came up briefly in one thread from 2011. The conversation was brief and didn't present a good code example I could go off, but somebody said foo_run can do this. I already use foo_run, but only to open links. Does anyone use it for this, and how does your code to run off multiple keyboard shortcuts look?

Any ideas? ;D

Re: Multiple keyboard shortcuts in foobar2000? (foo_run or other method?)

Reply #1
Hi there,

So happens I was looking into this myself to solve another issue :D

Currently I reckon the best way to run macro commands is with Spider Monkey Panel (or I guess JScript Panel can as well). It offers 10 customizable preset menu commands, on (hold shift key) File menu > Spider Monkey Panel > 1-10.

Once installed, you have to put a panel somewhere in your layout with the relevant script (in CUI, I believe you can hide the panel somehow?), -or- add/edit the code to an existing script you are using (and if it already uses the function, make sure to not duplicate it and use a different preset).

Here is the description from the documentation (which installs to foobar user folder: user-components/foo_spider_monkey_panel/docs/html/index.html, under Modules > Callbacks > on_main_menu) -

Quote
[inner] on_main_menu(index)       Callbacks.js, line 191

On the main menu>File>Spider Monkey Panel, there are 10 menu items and whichever number is selected is sent as the "index" to this callback. Being main menu items now means you can bind them to global keyboard shortcuts, standard toolbar buttons, panel stack splitter buttons, etc. Remember to think carefully about where you use this code as you probably only want it to run once and so don't include it in common files and scripts where you might have multiple instances. Important: you should avoid sharing scripts containing this code so as not to conflict with what other users may already be using.

I will share my example :P -

Code: [Select]
"use strict";

function on_main_menu(index) {
    switch (index) {
    case 1: // triggered when File>Spider Monkey Panel>1 is run
        break;
    case 2: // triggered when File>Spider Monkey Panel>2 is run
        fb.PlayOrPause();
        fb.RunMainMenuCommand("Show now playing");
        fb.RunContextCommand("Open containing folder");
        break;
    }
}
^ Here you can see I've added a few menu commands ("fb.") to the 2 preset. (See docs for some others, under Namespaces > fb. It seems you only need the name of the command as it appears on the menu, and not any sub-menus?). Then in the usual manner you can bind a keyboard shortcut or toolbar button to the preset, in this case - [main] > File > Spider Monkey Panel > 2.

It seems to be able to call context menu Masstagger scripts too which is handy.

As for the foo_run method, I guess it would just be running a foobar.exe command line.(?) For multiple commands probably put them in a batch (".bat") file and run that. (I've never tested it, but theoretically). You can run almost any menu command that way, except for the pesky dynamic ones that only get created after foobar has started up (such as (hold shift key) > View > Switch to playlist).

Then I was wondering something about foo_scheduler, whether that can run multiple commands.(?) I need to investigate it.

Hope that helps! If anyone has any other info to add I'd certainly be interested. ;)

Cheers

Re: Multiple keyboard shortcuts in foobar2000? (foo_run or other method?)

Reply #2
Wow, I'm looking for something like this for years. Great! I will give it a try. Thank you so much!