Just my mediainfo panel.
Needs Safe mode turned off I guess since it calls new ActiveXObject();
Also requires the wonderful scrollbar.js library.
// scrollbar_demo.js: totally useless and stupid demo of my scrollbar.
// written by r0lZ September 2003
//
// ==PREPROCESSOR==
// @import "%fb2k_profile_path%\wsh_scripts\scrollbar.js"
// ==/PREPROCESSOR==
// Our own global variables
// the text that we display in the viewport
var g_text = "Shit";
//var g_font = g_dui == 1 ? window.GetFontDUI(0) : window.GetFontCUI(0);
var g_font = gdi.Font("Consolas", 12, 0);
// the bitmap that will be displayed in the viewport
var g_bitmap = null;
// flag set to true when the window size changes, as we will need to compute
// a new viewport size and redraw the bitmap.
var g_need_vp_refresh = true;
// font flags
DT_TOP = 0x00000000;
DT_LEFT = 0x00000000;
DT_CENTER = 0x00000001;
DT_RIGHT = 0x00000002;
DT_VCENTER = 0x00000004;
DT_BOTTOM = 0x00000008;
DT_WORDBREAK = 0x00000010;
DT_CALCRECT = 0x00000400;
DT_NOPREFIX = 0x00000800;
DT_END_ELLIPSIS = 0x00008000;
// Configuration options for the scrollbar and the viewport
// foreground color of the scrollbar (alpha supported)
var sb_fg = window.InstanceType == 1 ? window.GetColorDUI(0) : window.GetColorCUI(0);
// background color of the scrollbar (alpha supported)
var sb_bg = 0x40FFFFFF; // transluscent white background
// scroll increment, in pixels, for the scrollbar arrows, the mouse wheel and the Up/Down keys
var sb_small_inc = g_font.Height * 3;
// allow drag the viewport with the mouse?
var sb_drag_enabled = true;
// allow scroll with the mouse wheel?
var sb_mouse_wheel_enabled = true;
// allow scroll with PageUp/Down and Cursor Up/Down?
var sb_keyboard_enabled = true;
// hide the scrollbar when the whole bitmap fits in the viewport?
var sb_hide_useless_scrollbar = true;
// hide the scrollbar when the mouse is not over it?
var sb_auto_hide_scrollbar = true;
// place the scrollbar at the left side of the viewport?
var sb_scrollbar_at_left_side = false;
// draw a 1 pixel border using the sb_fg color in the viewport?
var sb_draw_border = true;
////////////////// Example code ///////////////
function on_size()
{
// sets the flag telling that the viewport and bitmap must be reinitialized.
g_need_vp_refresh = true;
}
function on_paint(gr)
{
// compute the dimentions of our viewport
var x = 2;
var y = 2;
var w = window.Width-4;
var h = window.Height-4;
// draw elements that are outside the viewport
var bg = window.InstanceType == 1 ? window.GetColorDUI(1) : window.GetColorCUI(3);
gr.FillSolidRect(0,0, window.Width,window.Height, bg);
if (g_need_vp_refresh) {
// if necessary, create the bitmap and init the viewport
g_bitmap = draw_bitmap(x, y, w, h);
sb_init_viewport(x, y, w, h, g_bitmap);
}
// paint the viewport (without the scrollbar)
sb_paint_viewport(gr);
// and finally, draw the scrollbar
sb_paint_scrollbar(gr);
}
function getmediainfo(filename) {
//var fso = new ActiveXObject("Scripting.FileSystemObject");
var wsh = new ActiveXObject("WScript.Shell");
var pp = "cmd.exe /C\"\"H:\\codecs and players\\mediainfo_cli\\MediaInfo.exe\" \""+filename+"\" > h:\\out.txt\"";
//fb.trace(pp);
var app = wsh.Run(pp, 0, 1);
return utils.ReadTextFile("h:\\out.txt");
}
function on_selection_changed(metadb) {
if (metadb) {
g_text = getmediainfo(metadb.Path);
g_need_vp_refresh = true;
window.Repaint();
}
}
function init() {
var mdb = fb.GetSelection();
if (mdb) {
g_text = getmediainfo(mdb.Path);
g_need_vp_refresh = true;
window.Repaint();
}
}
// create and draw in the bitmap
function draw_bitmap(x, y, w, h)
{
var bg = window.InstanceType == 1 ? window.GetColorDUI(1) : window.GetColorCUI(3);
g_need_vp_refresh = false;
// compute the height of the bitmap that will be scrolled through the viewport
var bitmapheight = sb_MeasureStringHeight(g_text, g_font, w)+8;
if (bitmapheight == -1) return;
if (bitmapheight < h) bitmapheight = h;
// create the bitmap
g_bitmap && g_bitmap.Dispose();
g_bitmap = gdi.CreateImage(w, bitmapheight);
// (the bitmap may be null when foobar starts, so we need to check it)
if (g_bitmap) {
// fill the bitmap with some colourful graphics
var bitmap_gr = g_bitmap.GetGraphics();
bitmap_gr.FillGradRect(x,y, w, bitmapheight, 0, 0xFFFFFFFF, 0xFF808080);
bitmap_gr.DrawString(g_text, g_font, 0xFF000000, 4, 4, w-8, DT_NOPREFIX);
// Do not forget to release the graphics!
g_bitmap.ReleaseGraphics(bitmap_gr);
}
return(g_bitmap);
}
// Page Down with middle mouse button
// Demonstrates how to use sb_set_bitmap_pos() and sb_set_bitmap_pos_percent()
function on_mouse_mbtn_down(x, y, mask)
{
if (! sb_bitmap) return;
var curpos = sb_offset/(g_bitmap.Height-sb_vp_h);
if (curpos > 0.999) {
sb_set_bitmap_pos(0, 1);
} else {
sb_set_bitmap_pos_percent(curpos + sb_vp_h / g_bitmap.Height * 0.8, 1);
}
}
// clean exit
function on_script_unload()
{
g_bitmap && g_bitmap.Dispose(); // Is it really necessary?
}
init();
Scrollbar.js (put in profile folder\wsh_scripts):
// scrollbar.js v0.1
// WSH script for foobar2000, written by r0lZ, september 2010.
// Requires foobar v1.0 with WSH Panel Mod v1.3.6 or greater.
//
// Define a viewport in your WSH window and a larger bitmap. This script generates a
// vertical scrollbar that you can draw in the viewport, and automatically scrolls the bitmap
// in the viewport according to the user actions.
// Additionnaly, the viewport can also be dragged with the mouse, and scrolled with the mouse
// wheel or the keyboard. Horizontal scrolling is not supported.
//
//
// Functions that you should use:
//
// function sb_init_viewport(x, y, width, height, bitmap, reset_scrollbar_position)
// Initialize the internal variables. You should call it each time you need to refresh the
// bitmap that is drawn in the viewport, or if you need to change the viewport position or size.
// The x, y, width and height parameters define the viewport window.
// The height of the viewport must be >= 30, or the slider is not drawn.
// The width of the bitmap should be identical (or greater but that's useless) than the width
// of the viewport.
// The height of the bitmap is normally greater than the height of the viewport (as otherwise
// the scrollbar is useless).
// If reset_scrollbar_position is true, the top of the bitmap will be shown. Otherwise,
// the previous position will be kept.
// The function returns true if the bitmap is not null.
//
// function sb_paint_viewport(gr)
// Paint the viewport. This function should be called from the on_paint() callback.
// sb_init_viewport() should have been called BEFORE this function.
//
// function sb_paint_scrollbar(gr)
// Paint the scrollbar (if it is currently visible)
// This function should be called from the on_paint() callback, after sb_paint_viewport().
//
// function sb_set_bitmap_pos(y_position, mode)
// change the Y position of the bitmap in the viewport
// y_position (in pixels): 0 = top, bitmap.Height-1 = bottom
// mode: 1=place specified bitmap position on top of the viewport,
// -1=on bottom, 0=center
// Return true if the bitmap has been moved.
//
// function sb_set_bitmap_pos_percent(y_percent, mode)
// same as sb_set_bitmap_pos(), but here the position is a float
// between 0 (top) and 1 (bottom)
//
// function sb_CenterStringHorizontally(gr, str, font, color, x, y, maxwidth, fontflags)
// Simple helper function, to draw multi-line text with word wrapping centered in the bitmap.
// It is necessary to use that function, as strings written with GdiDrawText() look horrible
// when they are drawn in a bitmap.
// The function returns the latest Y position, so you can use the return value to draw another
// string.
//
// function sb_MeasureStringHeight(str, font, maxwidth)
// This is a simple helper function that returns the height of a string to draw with the previous
// function. It can be used to compute the height of the bitmap.
//
//
// Callback functions used by this script:
//
// Several standard callback functions are used by this script, and are therefore not available
// directly in your own script. However, you can still use them (with some minor limitations),
// but you have to replace "on_" with "on_sb_" in the function name. For example, if you need
// to be notified when the mouse moves, you should define the function on_sb_mouse_move(x, y)
// instead of on_mouse_move(x, y).
//
// on_sb_mouse_lbtn_down(x, y, mask) // You will not recieve the mouse clicks on the scrollbar
// // (and on the viewport if sb_drag_enabled == true)
// on_sb_mouse_lbtn_up(x, y, mask) // No limitations
// on_sb_mouse_move(x, y) // No limitation, except when the user scrolls the bitmap
// on_sb_mouse_leave() // No limitation
// on_sb_mouse_wheel(offset) // Available only if sb_mouse_wheel_enabled == false
// on_sb_key_down(vkey) // The Up, Down, PgUp, PgDown, Home and End keys are not
// // available when sb_keyboard_enabled == true
// on_sb_timer(timerid) // No limitations
//
// It is your responsibility to rebuild the bitmap when needed. In most cases, it is sufficient
// to rebuild it when you have to change its content and when the WSH window size changes.
// Then, you should call sb_init_viewport(). Call sb_paint_viewport() and sb_paint_scrollbar()
// from on_paint() to draw the viewport and the slider.
//
// Notes:
//
// - The behavior of the scrollbar is determined by global variables. See below.
//
// - All functions and global variables defined in this script begin with "sb_".
//
// - The width of the scrollbar is 16 pixels. If you do not use the option to hide it automatically,
// You should not draw important things in the area occupied by the scrollbar.
//
// - You can define only one viewport and scrollbar per WSH window.
//
// - Unfortunately, GdiDrawText() doesn't work well when it writes in a bitmap. Use DrawString() or
// the helper functions above.
////// configuration variables that you can overwrite in your script (Do not modify them here!):
// foreground color of the scrollbar (alpha supported)
var sb_fg = window.InstanceType == 1 ? window.GetColorDUI(0) : window.GetColorCUI(0);
// background color of the scrollbar (alpha supported)
var sb_bg = window.InstanceType == 1 ? window.GetColorDUI(1) : window.GetColorCUI(3);
// scroll increment, in pixels, for the scrollbar arrows, the mouse wheel and the Up/Down keys
var sb_small_inc = 40;
// allow drag the viewport with the mouse?
var sb_drag_enabled = true;
// allow scroll with the mouse wheel?
var sb_mouse_wheel_enabled = true;
// allow scroll with Up, Down, PgUp, PgDown, Home and End keys?
var sb_keyboard_enabled = true;
// hide the scrollbar when the whole bitmap fits in the viewport?
var sb_hide_useless_scrollbar = true;
// hide the scrollbar when the mouse is not over it?
var sb_auto_hide_scrollbar = true;
// place the scrollbar at the left side of the viewport?
var sb_scrollbar_at_left_side = false;
// draw a 1 pixel border using the sb_fg color in the viewport?
var sb_draw_border = false;
// if the bitmap is smaller than the viewport, center it
var sb_center_small_bitmaps = true;
////// end of configuration variables section
// Read-only global variables that you can examine. Do NOT overwrite them directly!
var sb_bitmap = null; // the bitmap
var sb_offset = 0; // Height of the bitmap zone that is above the top border of the viewport.
var sb_vp_x = 0; // Position of the viewport in the WSH window
var sb_vp_y = 0;
var sb_vp_w = window.Width; // Size of the viewport
var sb_vp_h = window.Height;
var sb_sb_x = window.Width-16; // X position of the scrollbar in the WSH window.
/////////////////////////////////////////////////////////////////////////////////////////////
// Other global variables. You should not need them.
var sb_slider_y = sb_slider_h = 0;
var sb_drag_slider = sb_drag_bitmap = false;
var sb_drag_y = sb_mouse_y = 0;
var sb_is_hidden = sb_mouse_is_outside = true;
var sb_timer = null;
var sb_timer_increment = 0;
var sb_timer_big_jumps = false;
/////////////////////// main scrollbar functions ////////////////////////
// initialize the internal variables
function sb_init_viewport(x, y, width, height, bitmap, reset_scrollbar_position)
{
sb_bitmap = bitmap;
sb_vp_x = x;
sb_vp_y = y;
sb_vp_w = width;
sb_vp_h = height;
if (sb_scrollbar_at_left_side) {
sb_sb_x = sb_vp_x;
} else {
sb_sb_x = sb_vp_x+sb_vp_w-15;
}
if (sb_bitmap && (sb_bitmap.Height == 0 || sb_bitmap.Width == 0)) sb_bitmap = null;
if (reset_scrollbar_position || ! bitmap) {
sb_offset = 0;
} else if (sb_offset > sb_bitmap.Height-sb_vp_h) {
sb_offset = sb_bitmap.Height-sb_vp_h;
if (sb_offset < 0) {
if (sb_center_small_bitmaps) {
sb_offset = Math.floor(sb_offset/2);
} else {
sb_offset = 0;
}
}
}
return sb_bitmap ? true : false;
}
// paint the content of the viewport
function sb_paint_viewport(gr)
{
//gr.FillSolidRect(sb_vp_x,sb_vp_y, sb_vp_w,sb_vp_h, sb_bg);
if (sb_bitmap) {
var x = sb_vp_x;
var sbw = (sb_hide_useless_scrollbar && sb_bitmap.Height <= sb_vp_h) || sb_auto_hide_scrollbar ? 0:16;
if (sb_bitmap.Width < sb_vp_w-sbw && sb_center_small_bitmaps) {
x += Math.round((sb_vp_w-sbw - sb_bitmap.Width)/2);
}
gr.DrawImage(sb_bitmap, x,sb_vp_y, sb_vp_w,sb_vp_h, 0,sb_offset, sb_vp_w,sb_vp_h, 0, 255);
}
if (sb_draw_border) {
gr.DrawRect(sb_vp_x,sb_vp_y, sb_vp_w-1,sb_vp_h-1, 1,sb_fg);
}
}
// paint the scrollbar (if it is currently visible)
function sb_paint_scrollbar(gr)
{
var arrow;
if (!sb_bitmap || (sb_hide_useless_scrollbar && sb_bitmap.Height <= sb_vp_h) || (sb_auto_hide_scrollbar && sb_mouse_is_outside) || sb_vp_h <= 30) {
sb_is_hidden = true;
return;
}
sb_is_hidden = false;
gr.FillSolidRect(sb_sb_x,sb_vp_y, 14,sb_vp_h, sb_bg);
gr.DrawRect(sb_sb_x,sb_vp_y, 14,sb_vp_h-1, 1,sb_fg);
gr.DrawLine(sb_sb_x,sb_vp_y+12, sb_sb_x+13,sb_vp_y+12, 1,sb_fg);
gr.DrawLine(sb_sb_x,sb_vp_y+sb_vp_h-13, sb_sb_x+14,sb_vp_y+sb_vp_h-13, 1,sb_fg);
arrow = new Array(sb_sb_x+2,sb_vp_y+9, sb_sb_x+12,sb_vp_y+9, sb_sb_x+7,sb_vp_y+3);
gr.FillPolygon(sb_fg,0,arrow);
arrow = new Array(sb_sb_x+3,sb_vp_y+sb_vp_h-9, sb_sb_x+12,sb_vp_y+sb_vp_h-9, sb_sb_x+7,sb_vp_y+sb_vp_h-4);
gr.FillPolygon(sb_fg,0,arrow);
sb_draw_slider(gr);
}
// change y position of the bitmap in the viewport
function sb_set_bitmap_pos(y_position, mode)
{
if (!sb_bitmap) return(false);
if (mode == -1) {
y_position -= sb_vp_h-1;
} else if (mode == 0) {
y_position -= Math.round(sb_vp_h/2);
}
if (y_position < 0) {
y_position = 0;
} else if (y_position > sb_bitmap.Height-sb_vp_h) {
y_position = sb_bitmap.Height-sb_vp_h;
}
if (y_position != sb_offset) {
sb_offset = y_position;
window.Repaint();
return(true);
}
return(false);
}
// same as sb_set_bitmap_pos(), in percent
function sb_set_bitmap_pos_percent(y_percent, mode)
{
if (!sb_bitmap) return(false);
return(sb_set_bitmap_pos(Math.round(sb_bitmap.Height*y_percent), mode));
}
//////////////// the functions below should not be called directly
// scroll the bitmap by big increrment
function sb_big_increment(dir)
{
if (! sb_bitmap) return;
var incr;
var pc_shown = sb_vp_h/sb_bitmap.Height;
if (pc_shown >= 1) {
return;
} else {
incr = dir*sb_slider_h*1/pc_shown*Math.abs(sb_vp_h/(sb_vp_h-32));
if (incr > 0 && incr > sb_small_inc) incr -= sb_small_inc;
if (incr < 0 && incr < sb_small_inc) incr += sb_small_inc;
sb_increment_bitmap_pos(incr);
sb_timer_increment = incr;
sb_timer_big_jumps = true;
sb_timer = window.CreateTimerTimeout(500);
}
}
// scroll the bitmap by any number of pixels
function sb_increment_bitmap_pos(increment)
{
if (!sb_bitmap) return(false);
var tmp = sb_offset + Math.round(increment) * -1;
if (tmp < 0) {
tmp = 0;
} else if (tmp > sb_bitmap.Height-sb_vp_h) {
tmp = sb_bitmap.Height-sb_vp_h;
}
if (tmp != sb_offset) {
sb_offset = tmp;
window.Repaint();
return(true);
}
return(false);
}
// Called when the user moves the scrollbar slider
function sb_apply_scroll(y)
{
if (! sb_bitmap) return;
var pc_shown = sb_vp_h/sb_bitmap.Height;
if (pc_shown >= 1) {
return;
} else {
delta = y - sb_drag_y;
if (sb_increment_bitmap_pos(delta*-1/pc_shown*Math.abs(sb_vp_h/(sb_vp_h-32)))) {
sb_drag_y = y;
}
}
}
// draw the slider in the scrollbar
function sb_draw_slider(gr)
{
if (!sb_bitmap || sb_is_hidden || (sb_hide_useless_scrollbar && sb_bitmap.Height <= sb_vp_h)) return;
var pc_shown, pc_offset;
var s_max = sb_vp_h-32;
pc_shown = sb_vp_h/sb_bitmap.Height;
if (pc_shown >= 1) {
pc_shown = 1;
pc_offset = 0;
} else {
pc_offset = sb_offset/sb_bitmap.Height;
if (pc_offset < 0) {pc_offset = 0}; // not necessary?
}
sb_slider_y = sb_vp_y + s_max * pc_offset + 14;
sb_slider_h = s_max * pc_shown + 4;
if (sb_vp_h > 50) {
gr.FillSolidRect(sb_sb_x+2,sb_slider_y, 11,sb_slider_h, sb_fg);
}
}
/////////////////////////// callbacks //////////////////////
function on_mouse_lbtn_down(x, y, mask)
{
sb_timer && window.KillTimer(sb_timer);
if (! sb_is_hidden && sb_bitmap && sb_bitmap.Height > sb_vp_h && x > sb_sb_x && x < sb_sb_x+15 && y > sb_vp_y && y < sb_vp_y+sb_vp_h) {
if (y < sb_vp_y+12) {
sb_timer_increment = sb_small_inc;
sb_timer_big_jumps = false;
sb_increment_bitmap_pos(sb_timer_increment);
sb_timer = window.CreateTimerTimeout(500);
return;
}
if (y >= sb_vp_y+sb_vp_h-12) {
sb_timer_increment = sb_small_inc*-1;
sb_timer_big_jumps = false;
sb_increment_bitmap_pos(sb_timer_increment);
sb_timer = window.CreateTimerTimeout(500);
return;
}
if (sb_vp_h > 50) {
if (y >= sb_slider_y && y < sb_slider_y+sb_slider_h) {
sb_drag_slider = true;
sb_drag_y = y;
return;
}
if (y >= sb_vp_y+12 && y < sb_slider_y) {
sb_big_increment(1);
return;
}
if (y < sb_vp_y+sb_vp_h-12 && y > sb_slider_y + sb_slider_h) {
sb_big_increment(-1);
return;
}
} else {
sb_timer_increment = sb_vp_h * -0.9;
sb_timer_big_jumps = false;
if (sb_offset + sb_vp_h + 1 >= sb_bitmap.Height) {
sb_set_bitmap_pos(0, 1);
} else {
sb_increment_bitmap_pos(sb_timer_increment);
}
sb_timer = window.CreateTimerTimeout(500);
return;
}
}
if (sb_drag_enabled && x > sb_vp_x && x < sb_vp_x+sb_vp_w && y > sb_vp_y && y < sb_vp_y+sb_vp_h) {
if (sb_bitmap && sb_bitmap.Height > sb_vp_h) {
sb_drag_bitmap = true;
sb_drag_y = y;
window.SetCursor(32645); // IDC_SIZENS
}
return;
}
// call user's callback function
try {on_sb_mouse_lbtn_down(x, y, mask)} catch(e) {}
return;
}
function on_mouse_lbtn_up(x, y, mask)
{
sb_timer && window.KillTimer(sb_timer);
sb_drag_slider = false;
if (sb_drag_bitmap) {
window.SetCursor(32512); // IDC_ARROW
sb_drag_bitmap = false;
}
try {on_sb_mouse_lbtn_up(x, y, mask)} catch(e) {}
}
function on_mouse_move(x, y)
{
sb_mouse_y = y;
if (sb_drag_slider) {
sb_apply_scroll(y);
return;
}
if (sb_drag_bitmap) {
sb_increment_bitmap_pos(y - sb_drag_y);
sb_drag_y = y;
return;
}
if (sb_is_hidden && sb_auto_hide_scrollbar && sb_bitmap && sb_bitmap.Height > sb_vp_h && x >= sb_sb_x && x <= sb_sb_x+15 && y >= sb_vp_y && y <= sb_vp_y+sb_vp_h) {
window.Repaint();
sb_mouse_is_outside = false;
}
try {on_sb_mouse_move(x, y)} catch(e) {}
}
function on_mouse_leave()
{
if (! sb_is_hidden && sb_auto_hide_scrollbar) {
window.Repaint();
}
sb_mouse_is_outside = true;
try {on_sb_mouse_leave()} catch(e) {}
}
function on_mouse_wheel(offset)
{
if (sb_mouse_wheel_enabled && sb_bitmap && sb_bitmap.Height > sb_vp_h) {
sb_increment_bitmap_pos(offset*sb_small_inc);
} else {
try {on_sb_mouse_wheel(offset)} catch(e) {}
}
}
function on_key_down(vkey)
{
if (sb_keyboard_enabled && sb_bitmap && sb_bitmap.Height > sb_vp_h) {
switch(vkey) {
case 33:
// PgUp
sb_big_increment(1);
break;
case 34:
// PgDn
sb_big_increment(-1);
break;
case 35:
// End
sb_increment_bitmap_pos(sb_bitmap.Height*-1);
break;
case 36:
// Home
sb_increment_bitmap_pos(sb_bitmap.Height);
break;
case 38:
// Up
sb_increment_bitmap_pos(sb_small_inc);
break;
case 40:
// Down
sb_increment_bitmap_pos(sb_small_inc*-1);
break;
}
return;
}
try {on_sb_key_down(vkey)} catch(e) {}
}
function on_timer(timerid)
{
if (sb_timer && timerid == sb_timer.ID) {
sb_timer && window.KillTimer(sb_timer);
if (sb_timer_big_jumps && sb_mouse_y >= sb_slider_y && sb_mouse_y < sb_slider_y+sb_slider_h) return;
if (sb_increment_bitmap_pos(sb_timer_increment)) {
sb_timer = window.CreateTimerTimeout(100);
}
return;
}
try {on_sb_timer(timerid)} catch(e) {}
}
//////////////////////////// helper functions ///////////////////////////////
// These functions are not necessary for the scrollbar. You can remove them.
// Draw multi-line text with word wrapping centered in the bitmap.
function sb_CenterStringHorizontally(gr, str, font, color, x, y, maxwidth, fontflags)
{
if (window.Height == 0) return(-1); // safety check: foobar enters in an infinite loop if bitmap.GetGraphics() is called when foobar is initializing.
var i, j, xpos, ypos, arr2;
var arr1 = str.split("\n");
ypos = y;
for (i=0; i<arr1.length; i++) {
arr2 = gr.EstimateLineWrap(arr1[i], font, maxwidth).toArray();
for (j=0; j<arr2.length; j+=2) {
xpos = x+(maxwidth-arr2[j+1])/2;
gr.DrawString(arr2[j], font, color, xpos, ypos, maxwidth, font.Height+50, fontflags);
ypos = ypos + font.Height;
}
}
return(ypos);
}
// Returns the height of a string to draw with the previous function.
function sb_MeasureStringHeight(str, font, maxwidth)
{
var temp_bmp = gdi.CreateImage(1, 1);
var temp_gr = temp_bmp.GetGraphics();
var i, arr2;
var arr1 = str.split("\n");
var h = 0;
for (i=0; i<arr1.length; i++) {
arr2 = temp_gr.EstimateLineWrap(arr1[i], font, maxwidth).toArray();
h = h + font.Height*arr2.length/2;
}
temp_bmp.ReleaseGraphics(temp_gr);
temp_bmp.Dispose();
return(h);
}
Too bad using wsh.Exec() shows the console dialog when running console applications and wanting to capture the output.
So the solution is to use wsh.Run() with cmd.exe to redirect the output to a temporary text file which you can then read with utils.ReadTextFile()
I struggled with getting this to work because cmd.exe requries a lot of quoting for the > character to be parsed correctly.
So I ended up with this:
cmd.exe /C""H:\codecs and players\mediainfo_cli\MediaInfo.exe" "E:\music\Above & Beyond - Trance Around The World\Above & Beyond - Trance Around the World 353 (2010-12-31).mka" > h:\out.txt"
as you can see the entire string after /C is quoted. then you got quotes for the long filenames. When escaped for use in javascript it looks even worse:
var pp = "cmd.exe /C\"\"H:\\codecs and players\\mediainfo_cli\\MediaInfo.exe\" \""+filename+"\" > h:\\out.txt\"";
No wonder it is so easy to get tripped up here.
Someone ought to have made this simpler to do. Basically what I'm requesting is for a function in WSH panels mod that lets you run and capture output of console apps without this ugly code.