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: WSH Panel Mod script discussion/help (Read 1399797 times) previous topic - next topic
0 Members and 3 Guests are viewing this topic.

WSH Panel Mod script discussion/help

Reply #3450
[deleted]

WSH Panel Mod script discussion/help

Reply #3451
Script download only small images.
You should look in html and find where is link for full size images..


we have a comedian in the house. there's no way i'm looking at the source of google images. 

to use this, you need the latest version of my common8.js updated today as it needed changes to suppress the options provided by my own thumbs script.

https://dl.dropboxusercontent.com/u/2280132...2003/common8.js

you stil get the normal options not related to the source/last.fm...



you can create your own menu using the top right button which i've included.

script here and check the comments. i've not included your code but it should be easy enough for you to add in yourself.

https://dl.dropboxusercontent.com/u/2280132...e777_thumbs.txt

if you think i've missed anything, give me a shout.

WSH Panel Mod script discussion/help

Reply #3452
we have a comedian in the house. there's no way i'm looking at the source of google images. 

to use this, you need the latest version of my common8.js updated today as it needed changes to suppress the options provided by my own thumbs script.

https://dl.dropboxusercontent.com/u/2280132...2003/common8.js

you stil get the normal options not related to the source/last.fm...



I know that you don't want to use google.
Google s not perfect, but, it's easy to set..
I'm use this only as alternative.
Last.fm is still no1..

I will see if something missing..
Great is that people now can use your original script with other sources.
Thank you for this

WSH Panel Mod script discussion/help

Reply #3453
I have a questions for marc2003:

I'm using your scripts to build my control area. I have successfully added albums art, track info and playback time, playback buttons, a stop after current button and a volume scroller all to one WSH panel. What I'm trying to add now is simple shuffle tracks and repeat track button. I've taken a look at the preloaded WSH sample "PBOButton" but it uses a different method of displaying buttons then your playback buttons. My question is, is there a way I can add shuffle and repeat to my script using the same method used for playback buttons? If not, what's the cleanest way to add repeat and shuffle buttons?

WSH Panel Mod script discussion/help

Reply #3454
if you want 3 buttons (normal, shuffle, repeat track) that simply sets the mode when clicked then simply create an image for each one.

Code: [Select]
var pbo_default_img = gdi.Image(fb.ProfilePath + "my images\\pbo_default.png")


if you want to stick your images in the same folder as my playback buttons (marc2003\images8\buttons), you can use this to get there...

Code: [Select]
var pbo_default_img = gdi.Image(p.ip + "buttons\\pbo_default.png")


now add the line of code into the b.update function

Code: [Select]
b.update = function() {
    pbo_default: new button(x, y, w, h, bw, bh, {normal: pbo_default_img}, function() {fb.PlaybackOrder = 0;}, "Normal"),
    previous: .....
    .....
}


for shuffle tracks the function would be...

Code: [Select]
fb.PlaybackOrder = 4;


then you just need to add this callback function

Code: [Select]
function on_playback_order_changed() {
    b.update();
}



WSH Panel Mod script discussion/help

Reply #3455
if you want 3 buttons (normal, shuffle, repeat track) that simply sets the mode when clicked then simply create an image for each one.

Code: [Select]
var pbo_default_img = gdi.Image(fb.ProfilePath + "my images\\pbo_default.png")


Thanks, but I actually want two buttons that have ON and OFF states. I have already created the icons, dropped them in your images8 folder, and updated common8.js to point to them. Their triggers are this.images.repeat, this.images.repeat_ON, this.images.shuffle, this.images.shuffle_ON.

I need, for example, the repeat button to go from this.image.repeat to this.images.repeat_ON when hit, and back to this.images.repeat when hit again or when repeat is turned off via the menu.

WSH Panel Mod script discussion/help

Reply #3456
you shouldn't edit common8.js - you can use stand alone images like my post above or extend b.images like this.

Code: [Select]
var b = new buttons("playback");
b.images.repeat = gdi.Image(....
b.images.repeat_ON =


you have to use b rather than this because the code is not inside any buttons function.

but when inside b.update, you can use this again.

Code: [Select]
b.update = function() {
    repeat: new button(x, y, w, h, bw, bh, {normal: fb.PlaybackOrder == 0 ? this.images.repeat : this.image.repeat_ON, hover: fb.PlaybackOrder == 0 ? this.images.repeat_ON : this.images.repeat}, function() {fb.PlaybackOrder = fb.PlaybackOrder == 1 ? 0 : 1;}, "Repeat"),
    previous: .....
    .....
}


edit: fix typo for hover image

WSH Panel Mod script discussion/help

Reply #3457
you shouldn't edit common8.js - you can use stand alone images like my post above or extend b.images like this.

Code: [Select]
var b = new buttons("playback");
b.images.repeat = gdi.Image(....
b.images.repeat_ON =


you have to use b rather than this because the code is not inside any buttons function.

but when inside b.update, you can use this again.

Code: [Select]
b.update = function() {
    repeat: new button(x, y, w, h, bw, bh, {normal: fb.PlaybackOrder == 0 ? this.images.repeat : this.image.repeat_ON, hover: fb.PlaybackOrder == 1 ? this.images.repeat_ON : this.images.repeat}, function() {fb.PlaybackOrder = fb.PlaybackOrder == 1 ? 0 : 1;}, "Repeat"),
    previous: .....
    .....
}


It works but the button never changes it's image to repeat_on. Hmmm...

WSH Panel Mod script discussion/help

Reply #3458
perhaps you missed my edit. 

WSH Panel Mod script discussion/help

Reply #3459
perhaps you missed my edit. 


Yup, I missed your edit

It now changes image to _on, but it also changes to _on when any of the other modes are selected. So if I select shuffle, repeat will also turn on.

WSH Panel Mod script discussion/help

Reply #3460
sorry, i didn't test because i'm too lazy to mess about with the images. you could try this - but again it's guess work.

Code: [Select]
repeat: new button(x, y, w, h, bw, bh, {normal: fb.PlaybackOrder == 1 ? this.images.repeat_ON : this.images.repeat, hover: fb.PlaybackOrder == 1 ? this.images.repeat : this.images.repeat_ON}, function() {fb.PlaybackOrder = fb.PlaybackOrder == 1 ? 0 : 1;}, "Repeat")


edit: typos again

WSH Panel Mod script discussion/help

Reply #3461
That was almost right, the only thing that needed to change was hover's image order. Thanks for all your help.


For anyone interested, here's the finished script:

Code: [Select]
b.update = function() {
    b.buttons = {
        repeat: new button(p.w / 2 - bw * 2 - bw / 2 - b2w * 2 - 25, 0, bw, bh, {normal: fb.PlaybackOrder == 2 ? this.images.repeat_on : this.images.repeat, hover: fb.PlaybackOrder == 0 ? this.images.repeat_on : this.images.repeat}, function() {fb.PlaybackOrder = fb.PlaybackOrder == 2 ? 0 : 2;}, "Repeat"),
        shuffle: new button(p.w / 2 - bw * 2 - bw / 2 - b2w - 25, 0, bw, bh, {normal: fb.PlaybackOrder == 4 ? this.images.shuffle_on : this.images.shuffle, hover: fb.PlaybackOrder == 0 ? this.images.shuffle_on : this.images.shuffle}, function() {fb.PlaybackOrder = fb.PlaybackOrder == 4 ? 0 : 4;}, "Repeat"),
    }
    window.Repaint();
}


You also have to add this to get it to update:

Code: [Select]
function on_playback_order_changed() {
    b.update();
}


It can be inserted in any of marc2003's scripts, but you'll need to point it to your own images.

WSH Panel Mod script discussion/help

Reply #3462
marc2003, I have a few more question regarding your scripts.

I'm also using your "simple volume" script in my control area at 120px x 10px and although it's working fine, it's preventing tool tips from all other elements to show. I know this because when I comment out "v.move" under "function_on_mouse_move" tool tips start showing, but volume stops responding to mouse clicks or drags.
Code: [Select]
function on_mouse_move(x, y) {
    p.move(x, y);
    a.move(x, y);
    b.move(x, y);
    v.move(x, y); // <---- THIS
}
My question is, is there an easy way to limit the area v.move effects?

Also, on a related note, I've notice that dragging the volume quickly all the way to the right doesn't actually get it to 100%. You have to drag it very slowly or use the mouse wheel to get to 100%. This issue is not related to my particular setup as it happens on the sample script as well as you theme 'yuck foo'. Was this a design decision?

 

WSH Panel Mod script discussion/help

Reply #3463
Also, on a related note, I've notice that dragging the volume quickly all the way to the right doesn't actually get it to 100%. You have to drag it very slowly or use the mouse wheel to get to 100%. This issue is not related to my particular setup as it happens on the sample script as well as you theme 'yuck foo'. Was this a design decision?


I've noticed other oddities with the volume control, too. If you hover over say themed buttons you can change the volume with the mouse wheel. I think it did it while hovering over ratings as well. Note, this is when they are all crammed into one WSH panel. Singularly they behave as expected.

WSH Panel Mod script discussion/help

Reply #3464
Also, on a related note, I've notice that dragging the volume quickly all the way to the right doesn't actually get it to 100%. You have to drag it very slowly or use the mouse wheel to get to 100%. This issue is not related to my particular setup as it happens on the sample script as well as you theme 'yuck foo'. Was this a design decision?


the problem was that my code released the "grip" immediately after the mouse passes the right most edge of the volume bar. if you moved too quick, it couldn't keep up.

i've uploaded a fix. right click the panel>Update script.

as for the tooltip thing, i'll have to look into that. i did encounter that problem with a seekbar before but then i forgot about it. 


WSH Panel Mod script discussion/help

Reply #3466
i fixed the tooltip problem when you have multiple scripts in the same panel.


Awesome! Both tool tips and the volume have been fixed, but I did catch a small bug. Here's how to reproduce it:

1. hover over an object with a tool tip then move your mouse off the WSH panel

2. hover back over an object in WSH that does not have a tool tip

3. you should now see the tool tip of the last object you hovered over that had a tool tip

Screen shot for reference here. Notice the "Next" tool tip on the bottom under the track title.

WSH Panel Mod script discussion/help

Reply #3467
i'm not really sure how that happens but i think i've fixed it. right click>Update script.


WSH Panel Mod script discussion/help

Reply #3469
@ godrick and anyone else who might be interested, my musicbrainz script now displays up to 500 releases now instead of the previous 100. there are just 25 artists on the whole of musicbrainz with more than that! bach has 2400 odd and there's no need to see all of that in one panel.

right click>Update script.
full download: https://dl.dropboxusercontent.com/u/2280132...sh/samples8.zip

an overview of all scripts and setup guide can be found here.

WSH Panel Mod script discussion/help

Reply #3470
another update for my musicbrainz script. previously, only releases with a primary type of album, single or EP were shown. now it can show everything with the new Include others option. mostly these will be live performances without a primary type set but it can include normal releases which haven't been tagged properly, interviews, broadcasts etc. as always, these options can be toggled on/off.

same instructions as above for update.

WSH Panel Mod script discussion/help

Reply #3471
The latest musicbrainz script works great! Well thought-out, as always. The improvement I see is not so much that one can scroll through to see more, but with the enhanced release limit the script can now sift though more of the sometimes spotty release info at MB, such that the short list of just albums (for example) can be reliably comprehensive for prolific artists.

Many thanks!

WSH Panel Mod script discussion/help

Reply #3472
Marc, this is my old Thumbs modification.
I changed code to receive full google size images.
And it works

I have problem, that -google changes domain depending on country.
So i add 'google domain' in properties, if doesn't work, must change to your 'Google country domain'..
Can you test please, and tell if it works well?
Later I will set this to work with commons8.

Code: [Select]
// ==PREPROCESSOR==
// @name "Biography Photos"
// @author "Mire777"
// @feature "v1.4"
// @feature "watch-metadb"
// ==/PREPROCESSOR==

// Paths
var fbfolder = (fb.ProfilePath + "Artist_info");
var lfm_folder = window.GetProperty("Custom folder", fbfolder);

//Image download size
size = window.GetProperty("Download quality","medium");

//Download server
server = window.GetProperty("Download  source", "last.fm");

//Search terms(google)
terms = window.GetProperty("Custom search terms", "");

//Google domen
g_domain = window.GetProperty("Google domain", "com");

//Cycle
cycle2 = window.GetProperty("Image cycle", 10);

var MF_GRAYED = 0x00000001;
var MF_STRING = 0x00000000;
var IDC_ARROW = 32512;
var IDC_HAND = 32649;

function on_colors_changed() {
p.colors_changed();
}

function on_font_changed() {
//p.font_changed();
}

function on_selection_changed() {
p.item_focus_change();
}

function on_playlist_switch() {
p.item_focus_change();
}

function on_playback_new_track() {
p.item_focus_change();
}

function on_playback_dynamic_info_track() {
p.item_focus_change();
}

function on_playback_stop() {
p.item_focus_change();
}

function on_item_focus_change() {
p.item_focus_change();
}

function on_mouse_rbtn_up(x, y) {
p.rbtn_up(x, y);
return true;
}

//Start Futures
function panel(name, features) {
this.item_focus_change = function() {
if (!this.metadb_func) return;
  switch(this.selection_mode) {
  case 0:
this.metadb = fb.GetSelection();
break;
  case 1:
this.metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();
break;
  case 2:
this.metadb = fb.GetFocusItem();
break;
}
if (this.metadb) on_metadb_changed();
}

//Size
this.size = function() {
this.w = window.Width;
this.h = window.Height;
}

//Move
this.move = function(x, y) {
this.mx = x;
this.my = y;
}

//Menu
this.rbtn_up = function(x, y) {
var _menu = window.CreatePopupMenu();

var idx;
switch(true) {
case typeof a == "object" && a.trace(x, y):

_menu.AppendMenuItem(MF_STRING, 17, "adjust");
_menu.AppendMenuItem(MF_STRING, 18, "Stretch");
_menu.CheckMenuRadioItem(15, 18, a.type == "centre" ? 15 : a.type == "top" ? 16 : a.type == "adjust" ? 17 : 18);
_menu.AppendMenuSeparator();
break;

case typeof th == "object":
case typeof im == "object" && im.trace(x, y):

var _settings = window.CreatePopupMenu();
var _auto_cycle = window.CreatePopupMenu();
var _download_source = window.CreatePopupMenu();
var _download_limit = window.CreatePopupMenu();
var _download_quality = window.CreatePopupMenu();
var _thumbs = window.CreatePopupMenu();
var MF_POPUP = 0x00000010;  

_menu.AppendMenuItem(MF_STRING, 403, "Refresh");
_menu.AppendMenuSeparator();

//Settings Menu
_menu.AppendMenuItem(MF_STRING | MF_POPUP, _settings.ID, "Settings");
_menu.AppendMenuSeparator();
_settings.AppendMenuItem(MF_STRING | MF_POPUP, _auto_cycle.ID, "Auto Cycle");

_auto_cycle.AppendMenuItem(MF_STRING, 415, "05 sec");
_auto_cycle.AppendMenuItem(MF_STRING, 420, "10 sec");
_auto_cycle.AppendMenuItem(MF_STRING, 425, "15 sec");
_auto_cycle.AppendMenuItem(MF_STRING, 430, "20 sec");
_auto_cycle.AppendMenuItem(MF_STRING, 410, "Off");
_auto_cycle.CheckMenuRadioItem(410, 430, cycle2 + 410);


_settings.AppendMenuItem(MF_STRING | MF_POPUP, _download_source.ID, "Download Source");

_download_source.AppendMenuItem(MF_STRING, 1902, "Last.fm");
_download_source.AppendMenuItem(MF_STRING, 1903, "Google");
_download_source.CheckMenuRadioItem(1902, 1904, server == "last.fm" ? 1902 : server == "google" ? 1903 : 1903);

_settings.AppendMenuItem(MF_STRING | MF_POPUP, _download_limit.ID, "Download Limit");
 
_download_limit.AppendMenuItem(MF_STRING, 1905, "1x");
_download_limit.AppendMenuItem(MF_STRING, 1906, "2x");
_download_limit.AppendMenuItem(MF_STRING, 1907, "3x");
_download_limit.AppendMenuItem(MF_STRING, 1908, "4x");
_download_limit.AppendMenuItem(MF_STRING, 1909, "5x");
_download_limit.AppendMenuItem(MF_STRING, 1910, "6x");
_download_limit.CheckMenuRadioItem(1905, 1910, im.limit + 1904);


if (server=="last.fm") _settings.AppendMenuItem(MF_STRING | MF_POPUP, _download_quality.ID, "Download Quality");
_download_quality.AppendMenuItem(MF_STRING, 1911, "Low");
_download_quality.AppendMenuItem(MF_STRING, 1912, "Medium");
_download_quality.AppendMenuItem(MF_STRING, 1913, "High");
_download_quality.CheckMenuRadioItem(1911, 1913, size == "low" ? 1911 : size == "medium" ? 1912 : size == "high" ? 1913 : 1913);

_settings.AppendMenuItem(MF_STRING | MF_POPUP, _thumbs.ID, "Thumbs");

_thumbs.AppendMenuItem(MF_STRING, 1201, "Left");
_thumbs.AppendMenuItem(MF_STRING, 1202, "Right");
_thumbs.AppendMenuItem(MF_STRING, 1203, "Top");
_thumbs.AppendMenuItem(MF_STRING, 1204, "Bottom");
_thumbs.AppendMenuItem(MF_STRING, 1205, "Off");
_thumbs.CheckMenuRadioItem(1200, 1205, th.mode == "grid" ? 1200 : th.mode == "left" ? 1201 : th.mode == "right" ? 1202 : th.mode == "top" ? 1203 : th.mode == "bottom" ? 1204 : 1205);

if (th.mode == "left" | th.mode == "right" | th.mode == "top" | th.mode == "bottom")
{
_thumbs.AppendMenuSeparator();
_thumbs.AppendMenuItem(MF_STRING, 1240, "40px");
_thumbs.AppendMenuItem(MF_STRING, 1250, "50px");
_thumbs.AppendMenuItem(MF_STRING, 1260, "60px");
_thumbs.AppendMenuItem(MF_STRING, 1270, "70px");
_thumbs.AppendMenuItem(MF_STRING, 1280, "80px");
_thumbs.AppendMenuItem(MF_STRING, 1290, "90px");
_thumbs.AppendMenuItem(MF_STRING, 1300, "100px");
_thumbs.AppendMenuItem(MF_STRING, 1350, "150px");
_thumbs.AppendMenuItem(MF_STRING, 1400, "200px");
_thumbs.AppendMenuItem(MF_STRING, 1450, "250px");
_thumbs.AppendMenuItem(MF_STRING, 1500, "300px");
_thumbs.CheckMenuRadioItem(1240, 1500, th.px + 1200);
}
  {
_menu.AppendMenuItem(MF_STRING, 400, "Open Folder");
if (server=="last.fm") _menu.AppendMenuItem(MF_STRING, 21, "Open Last.fm");
if (server=="google")  _menu.AppendMenuItem(MF_STRING, 21, "Open Google");
//_menu.AppendMenuItem(MF_STRING, 402, "Delete image");
_menu.AppendMenuSeparator();
_menu.AppendMenuItem(MF_STRING, 405, "Top");
_menu.AppendMenuItem(MF_STRING, 404, "Centre");
_menu.AppendMenuItem(MF_STRING, 406, "Adjust");
_menu.AppendMenuItem(MF_STRING, 407, "Stretch");
_menu.CheckMenuRadioItem(404, 407, im.type == "centre" ? 404 : im.type == "top" ? 405 : im.type == "adjust" ? 406 : 407);
_menu.AppendMenuSeparator();
}
break;
}

if (typeof ps == "object") _menu.AppendMenuItem(l.username.length > 0 ? MF_STRING : MF_GRAYED, 1901, "Last.fm password...");

_menu.AppendMenuItem(MF_STRING, 9, "Properties...");
if (utils.IsKeyPressed(0x10)) _menu.AppendMenuItem(MF_STRING, 10, "Configure...");
idx = _menu.TrackPopupMenu(x, y);
switch(idx) {

case 9:
window.ShowProperties();
break;
case 10:
window.ShowConfigure();
break;

case 15:
case 16:
case 17:
case 18:
a.type = idx == 15 ? "centre" : idx == 16 ? "top" : idx == 17 ? "adjust" : "stretch";
window.SetProperty("artreader_image_type", a.type);
window.RepaintRect(a.x, a.y, a.w, a.h);
break;

case 21:
if (server=="last.fm") this.browser("http://www.last.fm/music/" + encodeURIComponent(p.artist));
else
if (server=="google")  this.browser("https://www.google.rs/search?&tbm=isch&q=" + encodeURIComponent(p.artist) + "+" + terms);
break;

case 400:
this.run("explorer /select,\"" + im.files[im.index] + "\"");
break;

case 403:
if (im.images.length < im.limit)
{
p.run("RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8");
//fix_limit = im.limit;
im.download();
im.update();
}
else
p.run("RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8");
im.update();
break;
case 404:
case 405:
case 406:
case 407:
im.type = idx == 404 ? "centre" : idx == 405 ? "top" : idx == 406 ? "adjust" : "stretch";
window.SetProperty("Image type", im.type);
window.Repaint();
break;
case 410:
case 415:
case 420:
case 425:
case 430:
cycle2 = idx - 410;
window.SetProperty("Image cycle", cycle2);
cicleTimer = undefined;
cicleTimerStarted = false;
stopTimer();
startTimer();
cicleTimerStarted = true;
break;

case 1200:
case 1201:
case 1202:
case 1203:
case 1204:
case 1205:
th.mode = idx == 1200 ? "grid" : idx == 1201 ? "left" : idx == 1202 ? "right" : idx == 1203 ? "top" : idx == 1204 ? "bottom" : "off";
window.SetProperty("Thumbs mode", th.mode);
th.nc = true;
on_size();
window.Repaint();
break;
case 1240:
case 1250:
case 1260:
case 1270:
case 1280:
case 1290:
case 1300:
case 1350:
case 1400:
case 1450:
case 1500:
th.px = idx - 1200;
window.SetProperty("Thumbs px", th.px);
th.nc = true;
on_size();
window.Repaint();
break;

case 1902:
case 1903:
case 1904:
server = idx == 1902 ? "last.fm" : idx == 1903 ? "google" : "google";
window.SetProperty("Download  source", server);
break; 

case 1905:
case 1906:
case 1907:
case 1908:
case 1909:
case 1910:
im.limit = idx - 1904;
window.SetProperty("Download limit", im.limit);
break;

case 1911:
case 1912:
case 1913:
size = idx == 1911 ? "low" : idx == 1912 ? "medium" : idx == 1913 ? "high" : "high";
window.SetProperty("Download quality", size);
break;
}
_menu.Dispose();

}

//Futures Init
this.features_init = function() {
for (i = 0; i < this.features.length; i++) {
switch(this.features[i]) {

case "metadb":
this.selection_mode = window.GetProperty("Selection mode", 1);
break;

case "remap":
this.artist_tf = window.GetProperty("Artist format", "%artist%");
break;
}}}

//Check Future
this.check_feature = function(f) {
for (i = 0; i < this.features.length; i++) {
if (this.features[i] == f) return true;
}
return false;
}

//Eval Title/Format
this.eval = function(tf) {
if (!this.metadb || tf == "") return "";
if (fb.IsPlaying && this.metadb.RawPath.indexOf("file://") != 0) {
return fb.TitleFormat(tf).Eval();
} else {
return fb.TitleFormat(tf).EvalWithMetadb(this.metadb);
}}

//Console
this.console = function(message) {
fb.trace(this.name + ": " + message);
}

//Msg Box
this.MsgBox = function(prompt, buttons, title) {
prompt = prompt.replace(/"/g, '" + Chr(34) + "').replace(/\n/g, '" + Chr(13) + "');
title = title.replace(/"/g, '" + Chr(34) + "');
return this.vb.eval('MsgBox' + '("' + prompt + '", "' + buttons + '", "' + title + '")');
}

//Open In Browser
this.browser = function(command) {
if (!this.run(command)) this.MsgBox("Unable to launch your default browser.", 0, this.name);
}

//Run Command
this.run = function(command) {
try {
  this.WshShell.Run(command);
  return true;
  } catch(e) {
  return false;
}}

//Display Image
this.draw_image = function(gr, img, pos_x, pos_y, width, height, type, border, alpha) {
if (!img) return;
gr.SetInterpolationMode(7);
  switch(type) {
case "centre":
case "top":
  {
var sr = img.Width / img.Height;
var dr = width / height;
if (sr < dr) {
var r = img.Width / width;
var ch = height * r;
var sy = Math.round((img.Height - ch) / (type == "top" ? 1000 : 2));
var cw = img.Width;
var sx = 0;
} else {
var r = img.Height / height;
var cw = width * r;
var sx = Math.round((img.Width - cw) / 2);
var ch = img.Height;
var sy = 0;
}
  {
gr.DrawImage(img, pos_x, pos_y, width, height, sx + 5, sy + 5, cw - 10, ch - 10, 0, alpha || 255);
if (border) gr.DrawRect(pos_x, pos_y, width - 1, height - 1, 1, border);
  }
}
break;
case "stretch":
//strech
gr.DrawImage(img, pos_x, pos_y, width, height, 5, 5, img.Width-10, img.Height-10, 0, alpha || 255);
if (border) gr.DrawRect(pos_x, pos_y, width - 1, height - 1, 1, border);

break;
case "adjust":
default:
//adjust
var s = Math.min(width / img.Width, height / img.Height);
var nw = Math.round(img.Width * s);
var nh = Math.round(img.Height * s);
pos_x += Math.round((width - nw) / 2);
pos_y += Math.round((height - nh) / 2);

gr.DrawImage(img, pos_x, pos_y, nw, nh, 5, 5, img.Width-10, img.Height-10, 0, alpha || 255);
if (border) gr.DrawRect(pos_x, pos_y, nw - 1, nh - 1, 1, border);
break;

}
}

//Remove false string from file names
this.clean_filename = function(filename) {
return filename.replace(/[\/\\|:]/g, '-').replace(/\*/g, 'x').replace(/"/g, "''").replace(/[?<>]/g, '_');
}

this.name = name;
this.features = features;
this.dui = window.InstanceType;
this.script_path = fb.ProfilePath;
this.w = 0;
this.h = 0;
this.mx = 0;
this.my = 0;
this.metadb = fb.GetFocusItem();
this.WshShell = new ActiveXObject("WScript.Shell");
this.fso = new ActiveXObject("Scripting.FileSystemObject");

this.data_folder = lfm_folder + "\\";
if (lfm_folder==fb.ProfilePath + "Artist_info") if (!this.fso.FolderExists(this.data_folder)) this.fso.CreateFolder(this.data_folder), this.data_folder=this.data_folder;
if (!this.fso.FolderExists(this.data_folder)) return; 
this.artist = "";
this.artist_tf = "%artist%";

this.metadb_func = typeof on_metadb_changed == "function";
this.features_init();
}

function artreader(x, y, w, h) {
this.draw = function(gr) {
if (!this.img) return;
p.draw_image(gr, this.img, this.x, this.y, this.w, this.h, this.type);
}

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

this.wheel = function(step) {
if (!this.trace(p.mx, p.my)) return false;
this.id -= step;
if (this.id < 0) this.id = 4;
if (this.id > 4) this.id = 0;
window.SetProperty("artreader_id", this.id);
this.metadb_changed();
return true;
}

this.move = function(x, y) {
if (this.trace(x, y)) {
if (this.img) p.tt("Original size: " + this.img.Width + "x" + this.img.Height + "px");
return true;
} else {
p.ttd();
return false;
}}

this.lbtn_dblclk = function(x, y) {
if (!this.trace(x, y)) return false;
if (this.img) p.run("explorer /select,\"" + this.path + "\"");
return true;
}

this.x = x;
this.y = y;
this.w = w;
this.h = h;
this.img = null;
this.path = null;
}

function images(x, y, w, h) {
this.playback_time = function(time) {
}

this.draw = function (gr) {
if (this.images.length == 0) return;
p.draw_image(gr, this.images[this.index], this.x, this.y, this.w, this.h, this.type);
}

//MetaDB
this.metadb_changed = function() {
if (!p.metadb) return false;
switch(this.mode) {
case "last.fm":
p.artist = p.eval(p.artist_tf);
if (this.artist == p.artist) return false;
this.artist = p.artist;
this.folder = p.data_folder + p.clean_filename(p.artist);
if (!p.fso.FolderExists(this.folder)) p.fso.CreateFolder(this.folder);
break;
}
this.update();
return true;
}

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

this.wheel = function(step) {
if (!p.metadb || this.images.length < 2 || !this.trace(p.mx, p.my) || (typeof th == "object" && th.mode == "grid" && !th.overlay)) return false;
this.index -= step;
if (this.index < 0) this.index = this.images.length - 1;
if (this.index >= this.images.length) this.index = 0;
window.RepaintRect(this.x, this.y, this.w, this.h);
return true;
}

//Db-Click
this.lbtn_dblclk = function(x, y) {
if (!this.trace(x, y)) return false;
p.run("\"" + this.files[this.index] + "\"");
return true;
}

//Download Image
this.download = function()
{
if (!p.fso.FolderExists(this.folder))  return;
{

if (server=="last.fm")
{{
this.working=true;
if (p.artist == "" || p.artist == "?") return;
var folder = this.folder + "\\";
if (!this.xmlhttp) this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
this.xmlhttp.open("GET", "http://www.last.fm/music/" + encodeURIComponent(p.artist) + "/+images", true);
this.xmlhttp.send();
this.xmlhttp.onreadystatechange = function() {
if (im.xmlhttp.readyState == 4) {
if (im.xmlhttp.status == 200) {
var text = im.xmlhttp.responsetext;
if (!im.doc) im.doc = new ActiveXObject("htmlfile");
im.doc.open();
var div = im.doc.createElement("div");
div.innerHTML = text;
var data = div.getElementsByTagName("img");
var urls = [];
for (i = 0; i < data.length; i++) {
if (data[i].src.indexOf("http://userserve-ak.last.fm/serve/126s") == 0) urls.push(data[i].src.replace("126s", size == "low" ? "252" : size == "medium" ? "500" : size == "high" ? "_" : "_"));
}
fix_limit = im.limit;
for (i = 0; i < Math.min(urls.length, fix_limit, 50); i++) {
p.WshShell.Run("cscript //nologo \"" + p.script_path + "bio_photos.vbs\" \"" + urls[i] + "\" \"" + [folder + p.clean_filename(p.artist) + "_" + i] + urls[i].substring(urls[i].lastIndexOf("/")+1000) + ".jpg" + "\"" , 0, true);
if (im.images.length == 0) {im.update(); fix_limit = im.limit+1;}
if (im.images.length == 0) {return;}
}
im.doc.close();
im.working=false;
im.update();
window.NotifyOthers("images", "update");
} else {
p.console("HTTP error: " + im.xmlhttp.status);
}}}}}

else

if (server=="google")
{{
this.working=true;  
if (p.artist == "" || p.artist == "?") return;
var folder = this.folder + "\\";
if (!this.xmlhttp) this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
this.xmlhttp.open("GET", "https://www.google." + g_domain + "/search?&tbm=isch&q=" + encodeURIComponent(p.artist) + terms + "&tbm=isch&tbs=isz:m", true);
this.xmlhttp.send();
this.xmlhttp.onreadystatechange = function() {
if (im.xmlhttp.readyState == 4) {
if (im.xmlhttp.status == 200) {
var text = im.xmlhttp.responsetext;
if (!im.doc) im.doc = new ActiveXObject("htmlfile");
im.doc.open();
var div = im.doc.createElement("div");
div.innerHTML = text;
var data = div.getElementsByTagName("a");
var urls = [];

  for (i = 0; i < data.length; i++) {
if (data[i].href.indexOf("imgurl=") > 0) urls.push(decodeURIComponent(data[i].href).replace("http://www.google.rs/imgres?imgurl=", "").split("&imgrefurl")[0]);
}
fix_limit = im.limit;
for (i = 0; i < Math.min(urls.length, fix_limit, 50); i++) {
p.console("HTTP: " + urls[i]);
p.WshShell.Run("cscript //nologo \"" + p.script_path + "bio_photos.vbs\" \"" + decodeURIComponent(urls[i]) + "\" \"" + [folder + p.clean_filename(p.artist) + "_" + i] + decodeURIComponent(urls[i]).substring(decodeURIComponent(urls[i]).lastIndexOf("d")+1000) + ".jpg" + "\"" , 0, true);
if (im.images.length == 0) {im.update(); fix_limit = im.limit+1;}
if (im.images.length == 0) {return;}
}
im.doc.close();
im.working=false;
im.update();
window.NotifyOthers("images", "update");
} else {
p.console("HTTP error: " + im.xmlhttp.status + urls);
}}}}}}}


this.update = function() {
this.index = 0;
for (i = 0; i < this.images.length; i++) {
try { this.images[i].Dispose(); } catch(e) {}
}
this.folders = this.folder.split("|");
this.files = [];
for (i = 0; i < this.folders.length; i++) {
if (p.fso.FolderExists(this.folders[i])) this.files = this.files.concat(utils.Glob(this.folders[i] + "\\*.jpg").toArray(), utils.Glob(this.folders[i] + "\\*.jpeg").toArray(), utils.Glob(this.folders[i] + "\\*.png").toArray(), utils.Glob(this.folders[i] + "\\*.gif").toArray());
}

this.images = [];
for (i = 0; i < this.files.length; i++) {
this.images[i] = gdi.Image(this.files[i]);
}
if (typeof th == "object") {
th.nc = true;
th.calc();
}
  window.Repaint();
}

//Delete Image
this.delete_image = function() {
if (!this.app) this.app = new ActiveXObject("Shell.Application");
this.app.Namespace(10).MoveHere(this.files[this.index]);
window.SetTimeout(function() {
im.update();
window.NotifyOthers("images", "update");
}, 100);
}

this.x = x;
this.y = y;
this.w = w;
this.h = h;
this.files = [];
this.images = [];
this.index = 0;
this.artist = "";
this.folder = "";
this.limit = window.GetProperty("Download limit", 6);
this.mode = ("last.fm");
this.type = window.GetProperty("Image type", "adjust");
this.auto_download = window.GetProperty("Download  [on/off]", "on");
}

//Thumbs
function thumbs() {
this.trace = function(x, y) {
return (x > this.x && x < this.x + this.w && y > this.y && y < this.y + this.h);
}

this.draw = function(gr) {
switch(true) {
case im.images.length == 0:
break;
case this.mode == "off":
p.draw_image(gr, im.images[im.index], im.x, im.y, im.w, im.h, im.type);
break;
case !this.img:
break;
case this.mode == "grid":
gr.DrawImage(this.img, this.x, this.y, this.w, this.h, 0, this.offset * this.px, this.w, this.h);
if (this.overlay) {
gr.FillSolidRect(this.x, this.y, this.w, this.h, RGBA(0, 0, 0, 126));
p.draw_image(gr, im.images[im.index], im.x, im.y, im.w, im.h, "adjust");
}
break;
case this.mode == "left":
case this.mode == "right":
gr.DrawImage(this.img, this.x, this.y, this.w, this.h, 0, this.offset * this.px, this.w, this.h);
p.draw_image(gr, im.images[im.index], im.x, im.y, im.w, im.h, im.type);
break;
case this.mode == "bottom":
case this.mode == "top":
gr.DrawImage(this.img, this.x, this.y, this.w, this.h, this.offset * this.px, 0, this.w, this.h);
p.draw_image(gr, im.images[im.index], im.x, im.y, im.w, im.h, im.type);
break;
}}

this.calc = function() {
this.offset = 0;
switch(true) {
case p.w < this.px || p.h < this.px || this.mode == "off":
this.nc = true;
this.img && this.img.Dispose();
this.img = null;
im.x = 0;
im.y = 0;
im.w = p.w;
im.h = p.h;
break;
case this.mode == "grid":
this.x = 0;
this.y = 0;
this.w = p.w;
this.h = p.h;
im.x = 40;
im.y = 40;
im.w = this.w - 80;
im.h = this.h - 80;
if (!this.nc && this.columns != Math.floor(this.w / this.px)) this.nc = true;
this.overlay = false;
this.rows = Math.ceil(this.h / this.px);
this.columns = Math.floor(this.w / this.px);
this.img_rows = Math.ceil(im.images.length / this.columns);
if (this.nc && im.images.length > 0) {
this.nc = false;
this.img && this.img.Dispose();
this.img = null;
this.img = gdi.CreateImage(Math.min(this.columns, im.images.length) * this.px, this.img_rows * this.px);
var temp_gr = this.img.GetGraphics();
temp_gr.SetInterpolationMode(7);
var ci = 0;
var row, col;
for (row = 0; row < this.img_rows; row++) {
for (col = 0; col < this.columns; col++) {
if (ci == im.images.length) continue;
p.draw_image(temp_gr, im.images[ci], col * this.px, row * this.px, this.px, this.px, "top");
ci++;
}}
this.img.ReleaseGraphics(temp_gr);
temp_gr = null;
}
break;
case this.mode == "left":
case this.mode == "right":
this.x = this.mode == "left" ? 0 : p.w - this.px;
this.y = 0;
this.w = this.px;
this.h = p.h;
im.x = this.mode == "right" ? 0 : this.px;
im.y = 0;
im.w = p.w - this.px;
im.h = p.h;
this.rows = Math.ceil(this.h / this.px);

if (this.nc && im.images.length > 0) {
this.nc = false;
this.img && this.img.Dispose();
this.img = null;
this.img = gdi.CreateImage(this.px, this.px * im.images.length);
var temp_gr = this.img.GetGraphics();
temp_gr.SetInterpolationMode(7);
for (i = 0; i < im.images.length; i++) {
p.draw_image(temp_gr, im.images[i], 0, i * this.px, this.px, this.px, "top");
}
this.img.ReleaseGraphics(temp_gr);
temp_gr = null;
}
break;
case this.mode == "bottom":
case this.mode == "top":
this.x = 0;
this.y = this.mode == "top" ? 0 : p.h - this.px;
this.w = p.w;
this.h = this.px;
im.x = 0;
im.y = this.mode == "bottom" ? 0 : this.px;
im.w = p.w;
im.h = p.h - this.px;
this.columns = Math.ceil(this.w / this.px);

if (this.nc && im.images.length > 0) {
this.nc = false;
this.img && this.img.Dispose();
this.img = null;
this.img = gdi.CreateImage(this.px * im.images.length, this.px);
var temp_gr = this.img.GetGraphics();
temp_gr.SetInterpolationMode(7);
for (i = 0; i < im.images.length; i++) {
p.draw_image(temp_gr, im.images[i], i * this.px, 0, this.px, this.px, "top");
}
this.img.ReleaseGraphics(temp_gr);
temp_gr = null;
}
break;
}}

this.wheel = function(step) {
switch(true) {
case !this.trace(p.mx, p.my):
case this.overlay:
return false;
case this.mode == "grid":
if (this.img_rows < this.rows) return true;
this.offset -= step;
if (this.offset < 0) this.offset = 0;
if (this.offset > this.img_rows - this.rows) this.offset = this.img_rows - this.rows + 1;
break;
case this.mode == "left":
case this.mode == "right":
if (im.images.length < this.rows) return true;
this.offset -= step;
if (this.offset < 0) this.offset = 0;
if (this.rows + this.offset > im.images.length) this.offset = im.images.length - this.rows + 1;
break;
case this.mode == "bottom":
case this.mode == "top":
if (im.images.length < this.columns) return true;
this.offset -= step;
if (this.offset < 0) this.offset = 0;
if (this.columns + this.offset > im.images.length) this.offset = im.images.length - this.columns + 1;
break;
}
window.RepaintRect(this.x, this.y, this.w, this.h);
return true;
}

this.move = function(x, y) {
switch(true) {
case !this.trace(x, y):
window.SetCursor(IDC_ARROW);
return false;
case this.overlay:
window.SetCursor(IDC_ARROW);
return true;
case this.mode == "grid":
this.index = Math.floor((x - this.x) / this.px) + (Math.floor((y - this.y) / this.px) * this.columns) + (this.offset * this.columns);
break;
case this.mode == "left":
case this.mode == "right":
this.index = Math.floor((y - this.y) / this.px) + this.offset;
break;
case this.mode == "bottom":
case this.mode == "top":
this.index = Math.floor((x - this.x) / this.px) + this.offset;
break;
}
window.SetCursor(this.index < im.images.length ? IDC_HAND : IDC_ARROW);
return true;
}

this.lbtn_up = function(x, y) {
switch(true) {
case !this.trace(x, y):
return false;
case this.mode == "grid" && this.overlay && im.trace(x, y):
this.overlay = false;
window.Repaint();
break;
case this.mode == "grid" && this.index < im.images.length && !this.overlay:
this.overlay = true;
im.index = this.index;
window.Repaint();
break;
case this.overlay:
break;
case this.index < im.images.length:
im.index = this.index;
window.Repaint();
}
return true;
}

this.lbtn_dblclk = function(x, y) {
if (!im.trace(x, y) || th.mode == "grid") return false;
p.run("\"" + im.files[im.index] + "\"");
return true;
}

this.nc = false;
this.mode = window.GetProperty("Thumbs mode", p.check_feature("now_playing") ? "off" : "off");
this.px = window.GetProperty("Thumbs px", 40);
this.img = null;
}

//START---->
var p = new panel("Thumbs", ["remap", "metadb"]);
var im = new images(0, 0, 0, 0);
var th = new thumbs();

on_item_focus_change();

function on_playback_time(time) {
im.playback_time(time);
}

function on_size() {
p.size();
th.calc();
}

function on_paint(gr) {
th.draw(gr);
}

function on_metadb_changed() {
im.metadb_changed();
if (im.images.length == 0 && im.auto_download=="on")
im.download();
}

function on_mouse_wheel(step) {
if (th.wheel(step)) return;
if (im.wheel(step)) return;
}

function on_mouse_move(x, y) {
p.move(x, y);
th.move(x, y);
}

function on_mouse_lbtn_up(x, y) {
th.lbtn_up(x, y);
}

function on_mouse_lbtn_dblclk(x, y) {
th.lbtn_dblclk(x, y);
}

//Auto Cycle Image
var cicleTimerStarted = false;
var cicleTimer = null;
 
(function startTimer(){
 
if(!cicleTimerStarted){

cicleTimer = window.CreateTimerInterval(cycle2+"000");
cicleTimerStarted = true;
}
 
})();
 
function stopTimer(){
 
if(!cicleTimerStarted) return;
window.KillTimer(cicleTimer);
cicleTimer = undefined;
cicleTimerStarted = false;
 
}
 
function on_timer(id) {
if(cicleTimer && id == cicleTimer.ID){
 
{
do{
im.index++
if (im.index == im.images.length) im.index=0;
window.Repaint();
}while (im.index==-1);
}}}

WSH Panel Mod script discussion/help

Reply #3473
@mire777, i'll take a look at your script later.

I've noticed other oddities with the volume control, too. If you hover over say themed buttons you can change the volume with the mouse wheel.


i only just discovered this bug. it has now been fixed.

right click>Update script.

i've also made improvements to how tooltips appear. although my "fix" last week sort of worked, it wasn't the best.

these changes may have broken small web links if anyone uses that. if so, it can be downloaded again here: https://dl.dropboxusercontent.com/u/2280132...web%20links.txt



WSH Panel Mod script discussion/help

Reply #3474
@marc2003,
How can we add two last.fm similar artists panels in same panel?
I created two objects but they have the same write click options so they both display the same thing(top tags ,similar artists).How to do this??

And following method you gave to me doesn't work with common8.js .I tried to make relevant changes but i failed :/ so please can you provide a new script
Quote
@samithaj, it's not possible to re-use an autoplaylist but when using a fixed name, it's possible to delete old ones first before creating a new one. obviously you'd want a playlist name that won't conflict with anything else. open the panel, scroll to the end and replace the entire last function with this....

Code: [Select]
function on_mouse_lbtn_up(x, y) {
switch(true) {
case li.up_btn.lbtn_up(x, y):
case li.down_btn.lbtn_up(x, y):
break;
case li.in_range && x > li.x + li.text_x && x < li.x + li.text_x + Math.min(li.names_widths[li.index], li.text_width):
switch(true) {
case li.lastfm_mode != 2 && li.lastfm_link == "autoplaylist":
var i = 0;
while(i < fb.PlaylistCount) {
if (fb.GetPlaylistName(i) == "Last.fm Similar") fb.RemovePlaylist(i);
else i++;
}
fb.CreateAutoPlaylist(fb.PlaylistCount, "Last.fm Similar", li.queries[li.index]);
fb.ActivePlaylist = fb.PlaylistCount - 1;
break;
default:
p.browser(li.urls[li.index]);
break;
}
break;
}
}




@mire777,
I tested your script and google images doesn't work even i put the Google domain,I think you need to provide bio_photos.vbs??