WSH script conversion

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Scott (scott.69_at_dodgeit.com)
Date: 11/10/04


To: microsoft.public.scripting.wsh
Date: Tue, 09 Nov 2004 20:54:09 -0800


 firstly, i know nothing of javascript. well, that's not entirely true as i know a bit. anyway, my question is would it be possible to convert this script (found here or pasted below) to a version that i can run in a browser window? basically at the moment the script runs off windows xp (locally) and outputs a message in an alert box, which is great. but, what i'm looking for (or hoping someone might quickly code for me if it's not too hard) is to change the alert box output to "document.write", so that way i can just copy and paste the text from the browser window. i hope i've made myself clear. i'd really appreciate anyone's help with this.

note: rename file above to wmpblog.js from wmpblog.bmp.

// This is a simple JavaScript WSH script to display the currently playing media for
// Windows Media Player 9 Series when the Blogging Plug-in is installed.
// It's a pretty basic sketch of what you'd do, but it is fully functional on my Windows XP SP1,
// and should be easy to extend as you'd like.
//
//

Sh = new ActiveXObject("WScript.Shell");
key = "HKCU\\Software\\Microsoft\\MediaPlayer\\CurrentMetadata"

var strTrackInfo;
var strDisplayString;
var fHaveMetadata = false;

strDisplayString = "The current media is";

try
{
   strTrackInfo = Sh.RegRead( key + "\\Title" );

   if( 0 != strTrackInfo.length )
   {
       fHaveMetadata = true;
       strDisplayString += " " + strTrackInfo;
   }
}
catch( ex )
{
   try
   {
       strTrackInfo = Sh.RegRead( key + "\\Name" );

       if( 0 != strTrackInfo.length )
       {
           fHaveMetadata = true;
           strDisplayString += " " + strTrackInfo;
       }
   }
   catch( ex )
   {
   }
}

try
{
   strTrackInfo = Sh.RegRead( key + "\\DurationString" );

   if( 0 != strTrackInfo.length )
   {
       fHaveMetadata = true;
       strDisplayString += " (" + strTrackInfo + ")";
   }
}
catch( ex )
{
}

try
{
   strTrackInfo = Sh.RegRead( key + "\\Author" );

   if( 0 != strTrackInfo.length )
   {
       fHaveMetadata = true;
       strDisplayString += " by " + strTrackInfo;
   }
}
catch( ex )
{
}

try
{
   strTrackInfo = Sh.RegRead( key + "\\Album" );

   if( 0 != strTrackInfo.length )
   {
       fHaveMetadata = true;
       strDisplayString += " on the album " + strTrackInfo;
   }
}
catch( ex )
{
}

strDisplayString += ".";

if( !fHaveMetadata )
{
   strDisplayString = "No media playing currently.";
}

WScript.Echo( strDisplayString );

more info about what this script does can be found here .



Relevant Pages

  • help on removing element using yui
    ... just a basic question. ... i added an element on my page using javascript, ... var r=document.getElementById; ... k.setAttribute('standby','Loading Windows Media Player ...
    (comp.lang.javascript)
  • Re: help on removing element using yui
    ... and get its parent. ... var obj =document.getElementById; ... k.setAttribute('standby','Loading Windows Media Player ...
    (comp.lang.javascript)
  • pls help....media player wont play
    ... i wanted to embed on my page windows media player on run-time. ... browser is ie, and my code goes like this: ... var r=document.getElementById; ... video. ...
    (comp.lang.javascript)