### 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: Run Main (foo_run_main) (Read 1640 times)
0 Members and 1 Guest are viewing this topic.

## Run Main (foo_run_main)

##### 2022-01-05 05:46:45
Some of you may have seen this mentioned in random comments across the forums but I thought I'd start a new thread for it.

Quote
Unlike the built in command line handler/foo_runcmd, this component has full support for dynamically generated menu commands meaning you can use Edit commands and switch playlists, change output devices etc.

To avoid ambiguity with common names that might appear more than once under different sub menus, you must supply the full path to the command. Examples:

Code: [Select]
foobar2000.exe /run_main:Edit/Sort/Randomizefoobar2000.exe /run_main:Library/Search// use double quotes when command contains spacesfoobar2000.exe /run_main:"Playback/Device/Primary Sound Driver"

As of v0.0.2, there is a new /select_item option so you can select a track from the active playlist.

It means you can do something like this:

Code: [Select]
foobar2000.exe /run_main:"View/Switch to playlist/stranger in the alps"foobar2000.exe /select_item:5foobar2000.exe /play

https://github.com/marc2k3/fb2k-component#foo_run_main
https://github.com/marc2k3/fb2k-component/releases

## Re: Run Main (foo_run_main)

##### Reply #1 – 2022-01-05 07:07:37
Do it is possible to execute commands from context menu?

## Re: Run Main (foo_run_main)

##### Reply #2 – 2022-01-05 07:10:57
Um, why? That already exists in the player.

## Re: Run Main (foo_run_main)

##### Reply #3 – 2022-01-05 07:17:04
Are you saying these limitations no longer exist??

Quote
Unlike the built in command line handler/foo_runcmd, this component has full support for dynamically generated menu commands meaning you can use Edit commands and switch playlists, change output devices etc.

## Re: Run Main (foo_run_main)

##### Reply #4 – 2022-01-06 00:06:23
I don't know, actually.

## Re: Run Main (foo_run_main)

##### Reply #5 – 2022-01-06 03:57:52
Yesterday, I added /select_item and gave this example...

Code: [Select]
foobar2000.exe /select_item:5foobar2000.exe /play

Soon after, I realised this only works if people have Playback follows cursor enabled which was a lack of foresight on my part.

v0.0.3 released just now has /select_item_and_play which works regardless of settings.

Also, valid numbers are now clamped so anything in excess of the playlist item count will result in the last track being selected.

https://github.com/marc2k3/fb2k-component/releases

## Re: Run Main (foo_run_main)

##### Reply #6 – 2022-01-10 07:41:19
v0.0.4 released just now takes an optional delay when using /select_item_and_play.

https://github.com/marc2k3/fb2k-component#foo_run_main

It means commands like this can now work.

Code: [Select]
foobar2000.exe /add "d:\path\to\blah.mp3" /select_item_and_play:1:1500

The delay is in milliseconds and I found 1000 too low which I is why i used 1500 as an example. YMMV.

## Re: Run Main (foo_run_main)

##### Reply #7 – 2022-04-30 06:33:38
Not sure how to understand above discussion on context menu commands execution:
Is foo_run_main able to start context menu commands like ReplayGain/Scan per track gain? I tried but it didn't work (just to be sure I didn't make any stupid error...)
Background: I would like to execute two (or more) context menu commands with one shortcut or button.

## Re: Run Main (foo_run_main)

##### Reply #8 – 2022-04-30 08:04:47
This component is for main menu commands only.

You can look at the built in support for running context commands...

https://wiki.hydrogenaud.io/index.php?title=Foobar2000:Commandline_Guide

## Re: Run Main (foo_run_main)

##### Reply #9 – 2022-04-30 08:58:55
@Marc: great, that works
Code: [Select]
".\foobar2000.exe" /playlist_command:"ReplayGain/Scan per-file track gain"

😮