Windows Live Script - Playlistname von Winamp und Co. ausles

Windows Live Script - Playlistname von Winamp und Co. ausles| Datum: 11.02.2010 - 17:02 | Author: SirZimt

Also hallöle...
Einige kennen vlt. Windows Live Messenger Plus! da kann man eigene Scripte für schreiben.
Aktuell habe ich eins laufen was mir ermöglicht die Infos von Winamp und anderen nicht Windows Standart Playern auszulesen (WinStandart=Windows Media Player).

Nun. Ich würde zugerne aber neben den Infos zum: Album, Interpret, Titel, Fortscritt, Paus/Play/Stop gerne noch den namen der Playlist einfügen. Aktuell sieht das Script so aus:

Code


/*
* ----------------------------------------------------------------------------
* "THE BEER-WARE LICENSE" (Revision 42):
* <darktempler@gmail.com> wrote this file. As long as you retain this notice you
* can do whatever you want with this stuff. If we meet some day, and you think
* this stuff is worth it, you can buy me a beer in return Matt Labrum (-dt-)
* ----------------------------------------------------------------------------
*/

/*
$LastChangedBy: dt $
$LastChangedDate: 2007-04-08 23:23:13 +0930 (Sun, 08 Apr 2007) $
$LastChangedRevision: 299 $
$HeadURL: http://version.thedt.net/scripts/plusscripts/musicNowplaying/_translationClass.js $
*/


var Translation = function(type){
this.xml = new ActiveXObject("Microsoft.XMLDOM");
this.translationFile = type + ".xml";
this.translationName = type
this.LoadTranslation();
}


Translation.prototype = {
"xml" : false,
"LanguageFolder" : MsgPlus.ScriptFilesPath + "\\languages\\",


"GetAuthor" : function(){
var author = this.xml.selectNodes("/Translation/Author");
return (author.length != 0) ? author[0].text : "Unknown";
},

"LoadTranslation" : function(){
this.xml.load(this.LanguageFolder + this.translationFile);
if(this.xml.parseError.errorCode){
var p = this.xml.parseError;
Debug.Trace("Error loading Translation: Error: " + p.reason + " (" + p.errorCode + ") " + " Line:" + p.line);
}

},

"TranslationList" : function(){
var fso = new ActiveXObject('Scripting.FileSystemObject');
var returns = [];
for(var enume = new Enumerator(fso.GetFolder(this.LanguageFolder).Files);!enume.atEnd();enume.moveNext()){
returns[returns.length] = String(enume.item()).match(/\\([^\\]*)\.xml$/)[1];
}
return returns;
},

"TranslateFile" : function(xmlFile){

var filePath = MsgPlus.ScriptFilesPath + "\\" + xmlFile;
var inter = new ActiveXObject("Microsoft.XMLDOM");
inter.load(filePath);

var windows = this.xml.selectNodes("//Window");


var wnd, id, twnd, controls, control, text, cControls, cElements, cControl, cElement, temp, title;
for(var i=0;i<windows.length;i++){
wnd = windows[i];
id = wnd.getAttribute('Id');

twnd = inter.selectSingleNode("//Window[@Id='" + id +"']");


if(temp = wnd.selectSingleNode("Caption")){
title = twnd.selectSingleNode("Attributes/Caption");

if(title){
title.text = temp.text;
}
}

if(temp = wnd.selectSingleNode("TitleBar")){
title = twnd.selectSingleNode("TitleBar/Title/Text");
if(title){
title.text = temp.text;
}
}


this.ChangeControlsText(wnd.selectNodes("Control|Element"), twnd);
}



inter.save(filePath);
return xmlFile;
},

"ChangeControlsText" : function(controls, twnd){
for(var x =0;x<controls.length;x++){
control = controls[x];
if(control.hasChildNodes){
text = control.selectSingleNode("Caption|DefaultText|Text");

if(text){
temp = twnd.selectNodes(".//Control[@Id='" + control.getAttribute('Id')+ "']|.//Element[@Id='" + control.getAttribute('Id')+ "']");

if(temp.length != 0){
for(var i=0;i<temp.length;i++){

var edit;
var nodestochange = ["Caption", "DefaultText", "Text"];
for(nodec in nodestochange){
if(edit = temp[i].selectSingleNode(nodestochange[nodec])){
edit.text = text.text;
}
}
}
}
}
var children = control.selectNodes("Element|Control");
if(children.length != 0){
//Debug.Trace("DEEP: " + control.getAttribute('Id') + " ");
this.ChangeControlsText(children, twnd.selectNodes(".//Control[@Id='" + control.getAttribute('Id')+ "']|Element[@Id='" + control.getAttribute('Id')+ "']")[0]);
}
}
}
},


"LoadWindow" : function(XmlFile,WindowId){
var wnd = MsgPlus.CreateWnd(XmlFile, WindowId,1);
var wndStrings = this.GetWindow(WindowId).ToObject();

for(x in wndStrings){
if(x == "Caption"){
Interop.Call("User32","SetWindowTextW",wnd.Handle, wndStrings[x]);
}else if(x == "Title"){
//api call to change the title here
//not a clue how to do this though... :P
}else{
wnd.SetControlText(x,wndStrings[x]);
}
}
wnd.Visible = true;
return wnd;
},

"GetMenu" : function(menuId){
var menu = this.xml.selectNodes("/Translation/ScriptMenu[@Id='" + menuId + "']");
return (menu.length != 0) ? new this.window(menu[0]) : false;
},

"GetWindow" : function(wndID){
var wnd = this.xml.selectNodes("/Translation/Window[@Id='" + wndID + "']");
return (wnd.length != 0) ? new this.window(wnd[0]) : false;
},

"GetSpecialString" : function(name){
var elements = this.xml.selectNodes("/Translation/" + name);
return (elements.length != 0) ? elements[0].text : false;
}

}

Translation.prototype.window = function(windowObj){
this.xml = windowObj;
}

Translation.prototype.window.prototype = {
"GetString" : function(id){
var str = this.xml.selectNodes("String[@Id='" + id + "']");
return (str.length != 0) ? str[0].text : false;
},

"GetStringBundle" : function(id){
var bundle = this.xml.selectNodes("StringBundle[@Id='" + id + "']");
return (bundle.length != 0) ? new this.StringBundle(bundle[0]) : false;
},

"ToObject" : function(){
var elements = this.xml.selectNodes("*");
var returns = {};
for(var i=0;i<elements.length;i++){
if(elements[i].nodeType == 1){

if(elements[i].tagName == "String"){
returns[elements[i].getAttribute('Id')] = elements[i].text;
}else if(elements[i].tagName == "StringBundle"){
var bundle = new this.StringBundle(elements[i]);
returns[elements[i].getAttribute('Id')] = bundle.GetDefault();
}else{
returns[elements[i].tagName] = elements[i].text;
}
}
}
return returns;
},

"StringBundle" : function(bundleObj){
this.xml = bundleObj;

}
}

Translation.prototype.window.prototype.StringBundle.prototype = {
"ToObject" : function(){
var nodes = this.xml.selectNodes("String");
var returns = {};
for(var i=0;i<nodes.length;i++){
if(nodes[i].nodeType == 1){
returns[nodes[i].getAttribute("Id")] = nodes[i].text;
}
}
return returns;
},

"GetDefault" : function(){
var str = this.xml.selectNodes("Default");
return (str.length != 0) ? str[0].text : false;
},

"GetString" : function(id){
var str = this.xml.selectNodes("String[@Id='" + id + "']");
return (str.length != 0) ? str[0].text : false;
}

}




Das Script darf man ändern falls es zu rechtlichen Fragen wieder kommt. Hoffe hier weis jmd. wie das gehen könnte.

MfG Choast (der hier noch SirZimt heißt)