Skip to main content

Topic: JScript Panel script discussion/help (Read 49066 times) previous topic - next topic

0 Members and 1 Guest are viewing this topic.
Re: JScript Panel script discussion/help
Reply #525
Thanks marc2003.

I've just this minute got a solution working with a file system object. Seems to work fine.

  • marc2003
  • [*][*][*][*][*]
  • Developer
Re: JScript Panel script discussion/help
Reply #526
Ah yes, using fso is much better.  8)

Re: JScript Panel script discussion/help
Reply #527
Last.fm have updated their website to use https therefore the scripts need to be updated. Edit your text.js/thumbs.js files and replace http with https.

text.js
Code: [Select]
var url = "https://" + this.bio_lastfm_sites[this.bio_lastfm_site] + "/music/" + encodeURIComponent(this.artist) + "/+wiki";

thumbs.js
Code: [Select]
this.xmlhttp.open("GET", "https://www.last.fm/music/" + encodeURIComponent(this.artist) + "/+images", true);

latest version here. there are no such lines in these files. can't get biography to work anymore, due to „Last.fm Bio: HTTP error: 0”. any help?

reminder
edit with solution for idiots like me:

these files are located at *user_name*\AppData\Roaming\foobar2000\js_marc2003\js if installed version is standalone (not portable)
  • Last Edit: 30 April, 2017, 09:58:43 AM by alekksander
————————
♭———————

Re: JScript Panel script discussion/help
Reply #528
I gave up WSH Cover Panel, switch to 'complete\album art.txt'.
Could you consider making these changes? change the (\complete\album art.txt)'s right menu Google image search to two level menu? Like:WSH Cover Panel, the search source is defined in a separate text. Easy to modify the search source and do not affect the search source when the main code updates. the right menu can be added to some attached pictures menu?

  • Viewmax
  • [*]
Re: JScript Panel script discussion/help
Reply #529
Help please. Is it possible to have two buttons on toolbar "set volume to -10db" and "set volume to -30db" with this component?

Thank you!

  • marc2003
  • [*][*][*][*][*]
  • Developer
Re: JScript Panel script discussion/help
Reply #530
Well you can't add toolbars in default UI but here's a custom panel with 2 buttons...

Code: [Select]
// ==PREPROCESSOR==
// @name "SimpleThemedButton"
// @author "T.P Wang"
// @import "%fb2k_component_path%docs\flags.txt"
// @import "%fb2k_component_path%docs\helpers.txt"
// ==/PREPROCESSOR==

var cur_btn = null;
var g_down = false;
var g_theme = window.CreateThemeManager("Button");
var g_font = gdi.Font("Segoe UI", 12);
var ButtonStates = {
normal: 0,
hover: 1,
down: 2,
hide: 3
}

var buttons = {
v30: new SimpleButton(10, 10, 80, 26, "-30 dB", function () {
fb.Volume = -30;
}),
v10: new SimpleButton(100, 10, 80, 26, "-10 dB", function () {
fb.Volume = -10
})
}

function SimpleButton(x, y, w, h, text, fonClick, state) {
this.state = state ? state : ButtonStates.normal;
this.x = x;
this.y = y;
this.w = w;
this.h = h;
this.text = text;
this.fonClick = fonClick;

this.containXY = function (x, y) {
return (this.x <= x) && (x <= this.x + this.w) && (this.y <= y) && (y <= this.y + this.h);
}

this.changeState = function (state) {
var old = this.state;
this.state = state;
return old;
}

this.draw = function (gr) {
if (this.state == ButtonStates.hide) return;

switch (this.state)
{
case ButtonStates.normal:
g_theme.SetPartAndStateId(1, 1);
break;

case ButtonStates.hover:
g_theme.SetPartAndStateId(1, 2);
break;

case ButtonStates.down:
g_theme.SetPartAndStateId(1, 3);
break;

case ButtonStates.hide:
return;
}

g_theme.DrawThemeBackground(gr, this.x, this.y, this.w, this.h);
// RGB function is defined in docs\helpers.txt
// DT_* are defined in docs\flags.txt
gr.GdiDrawText(this.text, g_font, RGB(0,0,0), this.x, this.y, this.w, this.h, DT_CENTER| DT_VCENTER | DT_CALCRECT | DT_NOPREFIX);
}

this.onClick = function () {
this.fonClick && this.fonClick();
}
}

function drawAllButtons(gr) {
for (var i in buttons) {
buttons[i].draw(gr);
}
}

function chooseButton(x, y) {
for (var i in buttons) {
if (buttons[i].containXY(x, y) && buttons[i].state != ButtonStates.hide) return buttons[i];
}

return null;
}

function on_paint(gr) {
gr.FillSolidRect(0, 0, window.Width, window.Height, utils.GetSysColor(15));
drawAllButtons(gr);
}

function on_mouse_move(x, y) {
var old = cur_btn;
cur_btn = chooseButton(x, y);

if (old == cur_btn) {
if (g_down) return;
} else if (g_down && cur_btn && cur_btn.state != ButtonStates.down) {
cur_btn.changeState(ButtonStates.down);
window.Repaint();
return;
}

old && old.changeState(ButtonStates.normal);
cur_btn && cur_btn.changeState(ButtonStates.hover);
window.Repaint();
}

function on_mouse_leave() {
g_down = false;

if (cur_btn) {
cur_btn.changeState(ButtonStates.normal);
window.Repaint();
}
}

function on_mouse_lbtn_down(x, y) {
g_down = true;

if (cur_btn) {
cur_btn.changeState(ButtonStates.down);
window.Repaint();
}
}

function on_mouse_lbtn_up(x, y) {
g_down = false;

if (cur_btn) {
cur_btn.onClick();
cur_btn.changeState(ButtonStates.hover);
window.Repaint();
}
}

  • Viewmax
  • [*]
Re: JScript Panel script discussion/help
Reply #531
OMG! Huge props! I can't PM you :( Could you send me your Paypal? You should have donation button!

  • Viewmax
  • [*]
Re: JScript Panel script discussion/help
Reply #532
One more question, is it possible to assign a hotkeys to these custom buttons?

  • marc2003
  • [*][*][*][*][*]
  • Developer
Re: JScript Panel script discussion/help
Reply #533
Not really. The component can accept keyboard input but only when the panel has focus. Click anywhere else on the foobar UI or any other program and the panel loses focus meaning keyboard shortcuts no longer work.

I have an idea of how to make it possible but it's highly convoluted and I'm not really sure if it's worth the effort.

  • Viewmax
  • [*]
Re: JScript Panel script discussion/help
Reply #534
Not really. The component can accept keyboard input but only when the panel has focus. Click anywhere else on the foobar UI or any other program and the panel loses focus meaning keyboard shortcuts no longer work.
I have an idea of how to make it possible but it's highly convoluted and I'm not really sure if it's worth the effort.
It's not worth, you're right. Thank you one more time for your answers and customized buttons!

  • marc2003
  • [*][*][*][*][*]
  • Developer
Re: JScript Panel script discussion/help
Reply #535
It's now possible with the latest component version released just now. Here's the code snippet to go in your panel..

Code: [Select]
function on_main_menu(index) {
switch (index) {
case 1: // triggered when File>JScript Panel>1 is run
fb.Volume = -30;
break;
case 2: // triggered when File>JScript Panel>2 is run
fb.Volume = -10;
break;
}
}

You then have to bind commands 1 & 2 under File>JScript Panel to your keyboard shortcuts in the main preferences...

  • Last Edit: 18 May, 2017, 02:24:35 AM by marc2003

  • Viewmax
  • [*]
Re: JScript Panel script discussion/help
Reply #536
It's just a brilliant! Working absolutely fantastically!

Re: JScript Panel script discussion/help
Reply #537
jsplaylist-mod. Change requests:

I'm not sure who is now maintaining this script but I've just started using it as an alternative to ELPlaylist and it seems a lot quicker.

There are a few things I miss though:
1) Focus the display on a particular playlist
2) Don't show the extra line for each track if none of the columns are displaying anything in it ie all set to null
3) Don't collapse the list if the number of groups is less than a configurable number

Thanks to anyone prepared to implement these.

  • marc2003
  • [*][*][*][*][*]
  • Developer
Re: JScript Panel script discussion/help
Reply #538
I don't understand the code well enough to make those sorts of changes. I can fix things I break with my component updates but that's about it.

  • MachineHead
  • [*][*][*][*][*]
Re: JScript Panel script discussion/help
Reply #539
@marc2003

Is it possible for the switcher script to use one single button to cycle through scripts or does it have to be one per script?

  • marc2003
  • [*][*][*][*][*]
  • Developer
Re: JScript Panel script discussion/help
Reply #540
It's just this function that does the important bit...

Code: [Select]
window.NotifyOthers(name, info);

How you determine the name and info is entirely up to you.

  • Lucidae
  • [*]
Re: JScript Panel script discussion/help
Reply #541
Long time lurker, first time poster - I just wanted to thank marc2003 for developing and maintaining this incredibly useful plugin.

I was playing around with the album art jscript panel and I noticed the picture is cropped around the sides compared to the default UI album art panel. Is there anything I can do to adjust this setting?
  • Last Edit: 05 June, 2017, 08:34:32 PM by Lucidae

  • marc2003
  • [*][*][*][*][*]
  • Developer
Re: JScript Panel script discussion/help
Reply #542
I've tweaked it so the "Centre" and "Stretch" options no longer get trimmed. The "Crop" and "Crop Top" still get trimmed but by a lesser amount. Save this inside your foobar2000 profile\user-components\foo_jscript_panel\samples\complete\js (overwrite the existing helpers.js)

https://raw.githubusercontent.com/19379/foo-jscript-panel/master/component/samples/complete/js/helpers.js

  • davideleo
  • [*][*][*][*]
Re: JScript Panel script discussion/help
Reply #543
You can use GetColorScheme like this...

Code: [Select]
var img = utils.GetAlbumArtV2(fb.GetFocusItem(), 0);
if (img) {
    var arr = img.GetColorScheme(1).toArray();
    var col = arr[0];
}

You can increase the number 1 to get more colours. The first is the most dominant and so on...

I'm trying to use this GetColorScheme function, but it gives me a 10-digit number. How do I convert it to RGB values?
I'm late

  • davideleo
  • [*][*][*][*]
Re: JScript Panel script discussion/help
Reply #544
You can use GetColorScheme like this...

Code: [Select]
var img = utils.GetAlbumArtV2(fb.GetFocusItem(), 0);
if (img) {
    var arr = img.GetColorScheme(1).toArray();
    var col = arr[0];
}

You can increase the number 1 to get more colours. The first is the most dominant and so on...

I'm trying to use this GetColorScheme function, but it gives me a 10-digit number. How do I convert it to RGB values?


Alright, I managed with Falstaff's GetColorSchemFromImage function.
I'm late

  • davideleo
  • [*][*][*][*]
Re: JScript Panel script discussion/help
Reply #545
Is it possible to get windows 10 accent color with jscript?
I'm late

  • davideleo
  • [*][*][*][*]
Re: JScript Panel script discussion/help
Reply #546
Is it possible to get windows 10 accent color with jscript?

Eventually I found out the custom windows accent color is stored in the ColorizationColor registry key in HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\DWM, therefore I managed to get it with the RegRead method.
I can't find a registry key for the taskbar color, though, so I guess it must be a darker shade of the accent color. Is there a formula to get the taskbar color from the accent color?
I'm late

  • davideleo
  • [*][*][*][*]
Re: JScript Panel script discussion/help
Reply #547
Is it possible to get windows 10 accent color with jscript?

Eventually I found out the custom windows accent color is stored in the ColorizationColor registry key in HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\DWM, therefore I managed to get it with the RegRead method.
I can't find a registry key for the taskbar color, though, so I guess it must be a darker shade of the accent color. Is there a formula to get the taskbar color from the accent color?


For those who are interested, I found out all shades and tints of the accent color are stored in the registry key AccentPalette in HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Accent. The taskbar color is the 6th in the list when the transparency option is off and the 7th when it is on. Unfortunately the RegRead method does not seem to work with this registry key and I have no idea how to get its value. Any help would be appreciated.
I'm late

  • marc2003
  • [*][*][*][*][*]
  • Developer
Re: JScript Panel script discussion/help
Reply #548
If you look at the type of the value in regedit, it's REG_BINARY and if you look at the documentation for it here...

https://msdn.microsoft.com/en-gb/library/x05fawxd(v=vs.84).aspx

... it says it's a VBarray. Therefore you can try using toArray() on the result..

Code: [Select]
var something = WshShell.RegRead("HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Accent\\AccentPalette").toArray();

edit: Since I'm feeling nice, I found out how...

Code: [Select]
function RGB(r, g, b) {
    return 0xFF000000 | r << 16 | g << 8 | b;
}

var WshShell = new ActiveXObject("WScript.Shell");
var colours = WshShell.RegRead("HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Accent\\AccentPalette").toArray();
var colour = RGB(colours[20], colours[21], colours[22]);

function on_paint(gr) {
    gr.FillSolidRect(0, 0, window.Width, window.Height, colour);
}
  • Last Edit: 04 July, 2017, 11:18:29 AM by marc2003

  • davideleo
  • [*][*][*][*]
Re: JScript Panel script discussion/help
Reply #549
edit: Since I'm feeling nice, I found out how...

Thanks, it worked! Glad you're feeling nice  :)
I'm late