HydrogenAudio

Hosted Forums => foobar2000 => 3rd Party Plugins - (fb2k) => Topic started by: zeremy on 2017-03-13 10:37:09

Title: ConEmu Windows terminal in jscript panel
Post by: zeremy on 2017-03-13 10:37:09
This guide will describe how to add a ConEmu panel inside foobar2000.

(http://i.imgur.com/wwRlWKm.jpg)(http://i.imgur.com/0Vd2aln.jpg)(http://i.imgur.com/pLukyLZ.jpg)

What is ConEmu?
https://conemu.github.io/en/ (https://conemu.github.io/en/)
ConEmu-Maximus5 is a Windows console emulator with tabs, which presents multiple consoles and simple GUI applications as one customizable GUI window with various features.

What will we achieve?
We will have a panel inside foobar2000 to run command line applications and simple GUI windows.

Installation.

1. Install ConEmu from https://www.fosshub.com/ConEmu.html ( you can use any version x86 or x64 )

2. Run ConEmu and change the following values in settings.
2a. Main > Appearance  - Select Single instance mode
2b. Main Taskbar - Deselect Close ConEmu with last tab

3. In an empty jscript panel http://www.foobar2000.org/components/view/foo_jscript_panel (http://www.foobar2000.org/components/view/foo_jscript_panel) add the following code.

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

hex = window.ID.toString(16);

var cmd = "cmd /c \"" + "\"C:\\Program Files \(x86\)\\ConEmu\\ConEmu.exe\" -insidewnd " + hex + "\"";
fb.trace(cmd);
WshShell.Run(cmd, 0, false);

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

hex = window.ID.toString(16);

var cmd = "cmd /c \"" + "\"C:\\Program Files\\ConEmu\\ConEmu64.exe\" -insidewnd " + hex + "\"";
fb.trace(cmd);
WshShell.Run(cmd, 0, false);

You should now have the ConEmu panel hooked inside your jscript panel to use anyway you please.
You can dragndrop files from your playlist to the command window to process.

For jscript programmers you can "attach" your commands from another jscript panel  using the following code:

Code: [Select]
cmd = "cmd /k \""+ "\"C:\\Program Files \(x86\)\\ConEmu\\ConEmu\\attach.cmd\" & " + "add_your_command_here" + "\"" ; 

WshShell.Run(cmd, 1, true);