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 1371340 times) previous topic - next topic
0 Members and 3 Guests are viewing this topic.

WSH Panel Mod script discussion/help

Reply #1650
How do i determine when resizing is done?
Hello again. I hope i'm not too much of a PITA 
As there is no on_size_done() callback in WSH panel mod, I'm trying to write a function that will do it. I'd like to be able to call some methods for recalculating the layout of my panel, then repainting it after it has been resized rather than while it's being resized. I guess on_size is called many times while the user is resizing a panel, thus this note in callbacks.txt :
Code: [Select]
// NOTE: DO NOT Call window.Repaint() and such to repaint window in this function

As i don't have access to WScript object, i can't use WScript.sleep and i need some delay at some point to allow size to "stabilize" before calling "on_size_done", so i wrote this function :
Code: [Select]
function is_resizing(_callback,_timerId) {
       _timerId = true;
       __w1 = window.Width; __h1 = window.Height;
      
       function check_resizing() {
           __w2 = window.Width; __h2 = window.Height;
           if (__h2 == __h1 && __w2 == __w1) {
               _callback();
           } else {
               window.SetTimeout(is_resizing, 100);
           }
       }
       window.SetTimeout(check_resizing, 300);
   }

It's called using this statement in on_size function
Code: [Select]
function on_size() { // on_size will also run once when the script first starts.
       if (!($system.is_resizing) && ($system.panelW != window.Width || $system.panelH != window.Height))
           is_resizing(on_size_done,$system.is_resizing);
   }

And it will call on_size_done that resets $system.is_resizing back to false (and does other useful tasks).
However, some console output i added to on_size_done shows me that it will run many times, making it no better than using on_size directly. I guess i made some coding error here but really, i need better glasses to be able to see it (or a better brain) 

BTW, my first approach was to make a single function check this and call it repeatedly with window.SetInterval() but the script will crash when i try to stop it using window.ClearInterval().

If someone can help me debug my function, or give me another way of doing this, i would be grateful.

WSH Panel Mod script discussion/help

Reply #1651
Forget previous post
I can't edit it unfortunately 
I got the function working. I had to pass the functions as anonymous functions using an ugly construct rather than simply refer them by their variable. I still didn't fully understand the logic behind passing functions as arguments to other functions.
Here are the corrected functions in case anyone wants to use them.

How to build on_size_done() function


Current WSH panel mod includes on_size callback that's called each time the panel is resized. Unfortunately, "each time the panel is resized" means while resizing as well. Just test it using fb.trace("resize") in on_size function, resize the panel or the window for a couple seconds and then look at your console 

This means that to avoid wasting CPU cycles, it's best not to use ressource hungry methods like window.redraw() in on_size. However there are times when you want your panel to adapt to changes in size, and thus redraw after resizing. An on_size_done callback that would only trigger when resizing is actually finished is what we need, but there is no such callback. Here is how to build it.

In on_size, include the following statement :
Code: [Select]
function on_size() {
      if (!($system.is_resizing)) {
         $system.is_resizing = true
         is_resizing(function() {on_size_done();});
      }
  }

Define an is_resizing function :
Code: [Select]
function is_resizing(_callback) {
      __w1 = window.Width; __h1 = window.Height;
      
      function check_resizing(_callback) {
          __w2 = window.Width; __h2 = window.Height;
          if (__h2 == __h1 && __w2 == __w1) {
              _callback();
          } else {
              window.SetTimeout(function () {is_resizing(_callback);}, 100);
          }
      }
      window.SetTimeout(function () {check_resizing(_callback);}, 300);
  }

Finally, define an on_size_done function
Code: [Select]
function on_size_done() {
      $system.is_resizing = false;
      $system.panelW = window.Width; $system.panelH = window.Height;
      ...

You can add any statements you want in this function, including window.redraw(). This function will only be called when size is stable for 300 ms, which unless you are particularily slow means you have finished resizing your panel/window.
You can use different names. Especially $system.is_resizing in this example is a property of custom object $system that in my script holds every data needed for the script to run. Just be sure to define the variable you use to check if you already called is_resizing outside any function.

WSH Panel Mod script discussion/help

Reply #1652
Can I contribute a script?



Not very impressive I understand, but I'm pleased with how it looks. Mouse over and scroll wheel to change the volume with a digital readout. Double click on it and it goes to full volume. The font you need is called Letters Laughing (at their Execution).

Code: [Select]
var DT_TOP = 0x00000000;
var DT_CENTER = 0x00000001;
var DT_RIGHT = 0x00000002;
var DT_VCENTER = 0x00000004;
var DT_WORDBREAK = 0x00000010;
var DT_SINGLELINE = 0x00000020;
var DT_CALCRECT = 0x00000400;
var DT_NOPREFIX = 0x00000800;
var IDC_HAND = 32649;
function RGB(r, g, b) {
    return (0xff000000 | (r << 16) | (g << 8) | (b));
}


//-------------------------------- START
function on_paint(gr) {
    gr.SetTextRenderingHint(5);
    var ww = window.Width;
    var wh = window.Height;
    var text = Math.round(fb.Volume) + " dB  ";
    gr.FillSolidRect(0, 0, ww, wh, RGB(23,22,20));
    gr.GdiDrawText(text, gdi.Font("Letters Laughing", 18, 0), RGB(255,0,0), 0, 0, ww, wh, DT_RIGHT | DT_VCENTER | DT_SINGLELINE);
}
function on_volume_change(val) {
    window.Repaint();
    if (val < -60) fb.Volume = -60;
}
function on_mouse_lbtn_dblclk(x, y) {
    fb.Volume = 0;
}
function on_mouse_wheel(delta) {
    if (delta > 0) fb.VolumeUp();
    else fb.VolumeDown();
}
function on_mouse_move() {
    window.SetCursor(IDC_HAND);
}
//-------------------------------- END

WSH Panel Mod script discussion/help

Reply #1653
dates are now sorted in reverse order.

http://dl.dropbox.com/u/22801321/samples.zip


hi marc,

i tried to use your "last.fm-Similar artists" and i'm receiving this on the console:

"Error: WSH Panel Mod (Last.fm by marc2003): Microsoft JScript runtime error:
Invalid procedure call or argument
File: <main>
Ln: 73, Col: 4
<source text only available at compile time>
WSH Panel Mod: Warning: Obsolete: Please use AppendTo() method to create sub menu instead of AppendMenuItem()
"

any ideas?
thanks a lot




WSH Panel Mod script discussion/help

Reply #1657
a WSH VU-meter!? where can we find it ?


http://foobar2000.org.ru/forum/viewtopic.p...;p=40213#p40213


thanks, first try, it crashes foobar2000 (twice) but was when adjusting the script found at the adress above, i'd to complete the missing parts, but now it seems to work, great improvment from DRON, now easy to personalize it

EDIT: now, going to code a "good looking" VU Meter WSH panel based on this, and theme compliant to fit perfectly any VS

WSH Panel Mod script discussion/help

Reply #1658
a WSH VU-meter!? where can we find it ?


http://foobar2000.org.ru/forum/viewtopic.p...;p=40213#p40213


thanks, first try, it crashes foobar2000 (twice) but was when adjusting the script found at the adress above, i'd to complete the missing parts, but now it seems to work, great improvment from DRON, now easy to personalize it

EDIT: now, going to code a "good looking" VU Meter WSH panel based on this, and theme compliant to fit perfectly any VS


Yes, it deserves to be based on it to make a really beautiful thing. DRON is very knowledgeable and creative thinking programmer. I get the product from its great fun.




WSH Panel Mod script discussion/help

Reply #1662
@onv

yep, harder, but it's what i want to code first

The right decision, respect. But in this case it is desirable in my opinion to combine analog arrow with peak LED
P.S. It might be better to discuss it in the appropriate thread ? What do you think about this?

WSH Panel Mod script discussion/help

Reply #1663
any ideas?


are you using the latest WSH panel mod component? 1.5.3.1 i think...
if you've used previous versions of my scripts, did you extract the marc2003 folder from the latest zip over-writing all the old files?


WSH Panel Mod script discussion/help

Reply #1664
any ideas?


are you using the latest WSH panel mod component? 1.5.3.1 i think...
if you've used previous versions of my scripts, did you extract the marc2003 folder from the latest zip over-writing all the old files?


I did, actually i re-installed  the whole shebang;  win 7 64bit, all my software, new 1T hard drive... after my old one crashed, so it is all from scratch...

WSH Panel Mod script discussion/help

Reply #1665
I get a message that art.exe lacks a guilty digital signature, why is that? What changes has been made?

WSH Panel Mod script discussion/help

Reply #1666
I did, actually i re-installed the whole shebang; win 7 64bit, all my software, new 1T hard drive... after my old one crashed, so it is all from scratch...


that's odd then. i use windows 7 64bit myself and i can't make any sense of the error you posted because there's nothing on that line that would cause that.   

@sylla, art.exe hasn't changed in over 2 years and no one else has reported that problem.


WSH Panel Mod script discussion/help

Reply #1668
Falstaff,
does the WSH VU Meter script work with Mono (1 channel) audio as well as 2 channel (stereo)?
I am thinking of replacing the peakmeter from "foo_uie_vis_peakmeter_spectrum", but before I do I would like to know if your script can render mono audio too.
I like to collect as 1-channel Mono any albums which were originally produced as Mono, therefore I need the meter visualization to accept input from three channels:
Left-Front AND Right-Front AND Centre.

WSH Panel Mod script discussion/help

Reply #1669
WSH VU Meter v1.0.0 jscript


Congratulations, good job. The speed of your programming is comparable with a machine gun

WSH Panel Mod script discussion/help

Reply #1670
Falstaff,
does the WSH VU Meter script work with Mono (1 channel) audio as well as 2 channel (stereo)?
I am thinking of replacing the peakmeter from "foo_uie_vis_peakmeter_spectrum", but before I do I would like to know if your script can render mono audio too.
I like to collect as 1-channel Mono any albums which were originally produced as Mono, therefore I need the meter visualization to accept input from three channels:
Left-Front AND Right-Front AND Centre.


afaik, VU Meter component only provide Left, Right or Mixed to Mono Channels. My Scirpt use the ActiveX Object provided by the VU Meter component, it can display two VU meter for Left and Right Channels, or just one VU Meter, in this case, i calc the average value for level >> (Left level +Right level)/2 and for the Peak >> (Left Peak+Right Peak)/2. For mono tracks, Left and Right channels (level and Peak) provided by the component are the same.

HTH


WSH VU Meter v1.0.0 jscript


Congratulations, good job. The speed of your programming is comparable with a machine gun


thank you, it's just a first try, many things to adjust, and better skins to do now

WSH Panel Mod script discussion/help

Reply #1671
In the non-WSH version of Dron, you can easily switch between different skins on the fly by left- and right flips. Put 10 different skins - and choose the one that is now more like 
It would be useful to implement such a possibility in WSH - version


WSH Panel Mod script discussion/help

Reply #1673
Falstaff

I use your CoverFlow View v1.4 script in CoverFlow tab panel. 


Now I download new version  of this script - 1.4.2.
I replace text of script in wsh panel and that is what I see:


I could not change size of CoverFlow tab panel and I return in previous state only by deleting Coverflow tab and creating it again.