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: JScript Panel script discussion/help (Read 295144 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Re: JScript Panel script discussion/help

Reply #250
By the way do any of you know how to remove the track # for this playlist? I remember I did it on the other one with whs mod
Still looking for a way to do this if any of you know please tell me

 

Re: JScript Panel script discussion/help

Reply #251
What playlist are you talking about? Falstaff's JSplaylist (which I modded for JScript Panel) uses columns like other playlists which you can toggle on/off. Press CTRL+t if you've hidden the column headers.

If you're using Falstaff's JSsmooth playlist, you might need to edit the script.

Re: JScript Panel script discussion/help

Reply #252
marc2003, using your old script for writing playcount from last.fm and getting following error with both the updated WSH and JScript Panel.
Code: [Select]
JScript Panel (Playcount Sync (file tags) by marc2003): Microsoft JScript runtime error:
Object doesn't support this property or method
File: D:\Apps\PortableApps\foobar2000\scripts\marc2003\common.js
Line: 130, Col: 16
<source text only available at compile time>
Error row:
Code: [Select]
if (g_metadb) window.UnwatchMetadb();

Any suggestion how to make it work again?
Thanks.

Panel code:
Spoiler (click to show/hide)
Windows 10 Pro x64 // foobar2000 1.3.10



Re: JScript Panel script discussion/help

Reply #255
Problem  with mouse wheel scrolling, in last fm bio  text, steps are big, about 5 strings, and breaks appear in reading text. problem in the computer or in a script? changed computer mouse options does nothing

Re: JScript Panel script discussion/help

Reply #256
Put this in a panel and show me the results from the console when scrolling up and then down...

Code: [Select]
function on_mouse_wheel(a, b, c) {
    fb.trace("a: " + a);
    fb.trace("b: " + b);
    fb.trace("c: " + c);
}

In the meantime, you can use the up/down buttons to scroll (install the font if you can't see them). If using the now playing (basic) script, there is a bug where clicking too quickly will open the background image so this has been fixed.

https://github.com/19379/js-marc2003/releases

I've also added a Stop button to track info + seekbar + buttons.

Re: JScript Panel script discussion/help

Reply #257
Down
a: -1
b: -120
c: 120
Up
a: 1
b: 120
c: 120
using up/down buttons same too

Re: JScript Panel script discussion/help

Reply #258
Ah, you don't have the problem I was thinking of.

The default of 5 shouldn't be a problem so long as you don't do anything stupid like having a really small panel. If you want to change the default of 5 lines, you can open js_marc2003\js\text.js and look for the this.wheel function. Inside, change the number 5 to whatever.

If you're getting big gaps between lines/paragraphs then that will be because of how the source text is formatted on Last.fm. Anyone with an account can edit the wiki pages.

Re: JScript Panel script discussion/help

Reply #259
.......... I just solved my problem 5 minutes after this post. Dismiss this please.

Re: JScript Panel script discussion/help

Reply #260
Another problem came up.
It seems that if I create an empty image (gdi.CreateImage), and write some text in it (GdiDrawText), the edge of the characters' shape are seen as 1px dark lines. If the image is going to be used on a white background, the dark edges can be annoying.
Are there any methods to avoid them, without giving up using gdi.CreateImage? I thought this was due to SetTextRenderingHint, but soon it was denied in experiments.
screenshot:

Re: JScript Panel script discussion/help

Reply #261
Try DrawString instead...

Code: [Select]
temp_gr.SetTextRenderingHint(4);
temp_gr.DrawString(...);


Re: JScript Panel script discussion/help

Reply #263
I've knocked up a quick and dirty script for downloading album art from Last.fm if anyone wants to test it.

https://gist.github.com/19379/685a2fac5d45fd9a6231fe5fab156dc5

Make sure you edit the filename to match what you want and also update the main foobar2000 album art preferences to match.

It requires the js_marc2003 folder from my main samples (link in sig).

Re: JScript Panel script discussion/help

Reply #264
Seems to be working fine, thanks marc2003!

A suggestion: add a toggle to set whether art should be downloaded for all tracks, or tracks in the library only.

Re: JScript Panel script discussion/help

Reply #265
marc2003, thank you so much for replying here so often and supporting your component in this wonderful way. I flung more than a few pennies towards charities and artists and also supporting Foobar mobile & component developers. Yet, your support, time and effort is much appreciated and I'd still like to contribute somehow. So if money's not an option, let's see what scripts I can make :).

Now I have a question concerning hotkeys. I am quite keyboard-focused and for me it's essential to be able to navigate through a program using the keyboard. My question is this:

Is it possible for each JS Panel to hook into Foobar's keyboard shortcuts system and register a shortcut for bringing the keyboard focus to that panel? I'm asking this because I plan to have 2-3 JS Panels open, plus a ColumnsUI playlist and I'd like to navigate between them. In the same time, I'd like each panel to react to its own keyboard shortcuts only when I'm inside that panel (I've seen that scripts already do this, for example when doing name searches inside a JS Panel you see those letters show up that show what you've been typing).

Another question: are CTRL, ALT modifiers usable with the JS Panel?

Re: JScript Panel script discussion/help

Reply #266
A suggestion: add a toggle to set whether art should be downloaded for all tracks, or tracks in the library only.

Yep, I'll post in this thread when I update it.

Now I have a question concerning hotkeys.

Currently, the panel has to have focus to accept input. You can use modifiers like this...

Code: [Select]
var VK_SHIFT = 0x10;
var VK_CONTROL = 0x11;
var VK_ALT = 0x12;

function on_key_down(vkey) {
if (utils.IsKeyPressed(VK_CONTROL) && utils.IsKeyPressed(VK_ALT) && vkey == 65)
fb.ShowPopupMessage("ctrl + alt + a");
}

The likelihood of me creating keyboard shortcuts to focus a panel is pretty much zero but I think it would be possible to create main menu items which could trigger callbacks in all panels. Obviously those menu items have to be shared across all scripts from all users so my recommendation would be to implement them in personal scripts only and of course each user would have to bind these menu items to their own keyboard combinations in the main preferences.

Re: JScript Panel script discussion/help

Reply #267
I've updated my samples...

Quote
status bar: now shows playlist name next to stats. Use the right click menu to toggle details on/off. For existing users, this update requires importing the new txt file in to the panel.

All list/text based scripts have the mouse scroll step set to 3 lines.

https://github.com/19379/js-marc2003/releases

Re: JScript Panel script discussion/help

Reply #268
marc2003: I've checked the window structure of Foobar. I noticed that the JS panel windows have the class "uie_jscript_panel_class". Initially, I thought of a really ugly workaround: I will try to write a simple C++ application which can do the focusing of the JS panels for me, by using WIN32 API calls. But now I realize I could make a Foobar component that offers shortcuts for the user to set. I'd like to do this :), but a few pointers from you would be priceless to say the least. Here are 2 questions:

1. Can you indicate a way through which I can separate one JS Panel from another? They have the same class but no caption, no window title. A window title would be very handy, because I could use it when creating keyboard shortcuts for focusing the panels: <Activate JS Panel "Smooth Browser">, <Activate JS Panel "Custom Buttons">.

2. Can you (or anybody here knowledgeable in Foobar components) give me a link to a component that registers shortcuts in Foobar? An example always goes a long way :).

Thank you in advance! :)

Re: JScript Panel script discussion/help

Reply #269
^I have no idea. I have zero C++ knowledge and only created this component because a) WSH panel mod was already rock solid with barely any issues and b) adding new stuff from the foobar2000 SDK is easy enough when so much similar code already existed in the original component. I'm just good at copy/paste.

As I mentioned above, the code already exists for when the panel has focus and I believe the only way to create global shortcuts is by generating main menu or context menu items. These can then be bound to global keys in the main foobar preferences.






Re: JScript Panel script discussion/help

Reply #270
I've updated my samples so Last.fm chart data is now accurate. There was nothing wrong with my previous code - it's just that I stupidly followed Last.fm's documented methods which I no longer do.

https://github.com/19379/js-marc2003/releases


Re: JScript Panel script discussion/help

Reply #271
When playing tracks in Random order, as I do most of the time, the Previous button stops playback. Since I already have a Stop button, I decided to eliminate the redundancy by repurposing Previous to act as a Back button, which restarts playback of the current track from the beginning.

I changed this (slightly modified) line from marc2003's "track info + seekbar + buttons" sample script...

Code: [Select]
this.buttons.previous = new _.button(722, 364, 36, 36, {normal : "mono\\appbar.control.rewind.png"}, function () { fb.Prev(); }, "Previous");
...to this:

Code: [Select]
this.buttons.previous = new _.button(722, 364, 36, 36, {normal : "mono\\appbar.control.rewind.png"}, plman.PlaybackOrder == random_order ? function () {fb.PlaybackTime = 0;} : function () { fb.Prev(); }, "Previous");

random_order is a var set to 3 to clarify what I'm testing for.

The Previous button works normally when not in Random order playback mode.

Re: JScript Panel script discussion/help

Reply #272
What playlist are you talking about? Falstaff's JSplaylist (which I modded for JScript Panel) uses columns like other playlists which you can toggle on/off. Press CTRL+t if you've hidden the column headers.

If you're using Falstaff's JSsmooth playlist, you might need to edit the script.


I am talking about the default one, I just want to remove the track numbers on the left.

Re: JScript Panel script discussion/help

Reply #273
Do you have any idea what thread you're posting in?

Re: JScript Panel script discussion/help

Reply #274
Hi, this is my litte work for auto tag from file name in playlist, I wrote it long time ago, grabbed from my foobar200 skin.

If file name is "Artist - Title", and no tag, in playlist this code will make list itme show "Artist*" - "Title*", " * " means it grab from file name, then you can auto tag it, the sample code is use in playlist's context menu.
Code: [Select]
var tf_artist = fb.TitleFormat("$if(%length%,$if2(%artist%,$ifgreater($strchr(%filename%,-),0,$trim($substr(%filename%,1,$sub($strchr(%filename%,-),1)))*,?)),)");
var tf_title = fb.TitleFormat("$ifgreater($strchr(%filename%,-),0,$trim($substr(%filename%,$add($strchr(%filename%,-),1),100)*),%title%)");
//......make tf_artist & tf_title use in your playlist or elsewhere you want.

function new_context_menu(x, y, id, array_id) {
//......
list.metadblist_selection = plman.GetPlaylistSelectedItems(plman.ActivePlaylist);
var info = list.metadblist_selection.item(i).GetFileInfo();
var o_title = info.MetaValue(info.MetaFind("TITLE"), 0) ? tf_titleO : fb.TitleFormat("");
var o_artist = fb.TitleFormat("$ifequal($stricmp(%artist%,?),1,,%artist%)");
var o_album = fb.TitleFormat("$ifequal($stricmp(%album%,?),1,,%album%)");
//......
_menu.AppendMenuItem(list.metadblist_selection.count==1 && info.MetaValue(info.MetaFind("TITLE"), 0) && !tf_artist.EvalWithMetadb(list.metadblist_selection.item(i)).match(/\*/) ? MF_GRAYED|MF_DISABLED : MF_STRING, 3000, list.metadblist_selection.count==1 && ( !info.MetaValue(info.MetaFind("TITLE"), 0) || tf_artist.EvalWithMetadb(list.metadblist_selection.item(i)).match(/\*/) ) ? "Auto Tag *:" + (o_title.EvalWithMetadb(list.metadblist_selection.item(i)) ? "" : tf_title.EvalWithMetadb(list.metadblist_selection.item(i)).replace("*", "") + (o_artist.EvalWithMetadb(list.metadblist_selection.item(i)) ? "" : ", ")) + (o_artist.EvalWithMetadb(list.metadblist_selection.item(i)) ? "" : tf_artist.EvalWithMetadb(list.metadblist_selection.item(i)).replace("*", "")) : "Auto Tag *");
//......
case 3000:
for (i=0; i<list.metadblist_selection.count; i++) {
if (tf_title.EvalWithMetadb(list.metadblist_selection.item(i)).match(/\*/)) {
var title = tf_title.EvalWithMetadb(list.metadblist_selection.item(i)).replace("*", "");
list.metadblist_selection.item(i).UpdateFileInfoSimple("TITLE", title);
}
if (tf_artist.EvalWithMetadb(list.metadblist_selection.item(i)).match(/\*/)) {
var artist = tf_artist.EvalWithMetadb(list.metadblist_selection.item(i)).replace("*", "");
list.metadblist_selection.item(i).UpdateFileInfoSimple("ARTIST", artist);
}
}
break;
//......please shows source if you use this, thanks ;)......

I don't if it work in JScript Panel, just share, maybe useful for someone.