There is a function that allows one to change their media mesage.
Okay, you want to have the time in your media message. What you should do, is create a Date object like this:
code:
var CurDateTime = new Date();
Then you can retrieve a time string using toLocaleTimeString() like this:
code:
var Time = CurDateTime.toLocaleTimeString();
Then you should pass the
Time variable to the function below.
code:
/*
function SetNowPlaying([boolean] enabled: specifies whether to enable the message or not,
[string] type: the type of message, can be Music, Games, Office,
[string] format: the format, see below,
[string] title: title of the 'song',
[string] artist: artist of the 'song',
[string] album: album of the 'song',
[string] contentID: content ID of the 'song', can be anything);
ALL PARAMETERS OPTIONAL
FORMAT DESCRIPTION
The format is defined by 4 numbers: 0, 1, 2 and 3. These represent respectively Title, Artist, Album, ContentID. Enclose the numbers in { these brackets }. Valid format would be:
{3}: {0} - {1} (on "{2}")
This would result in:
<CONTENTID>: Proud mary - John Fogerty (on "The long road home")
Experiment with this.
*/
// Function by -dt-, modified slightly by myself
function SetNowPlaying(enabled, type, format, title, artist, album, contentID){
if(typeof(type) == "undefined")type = "Music";
if(typeof(format) == "undefined")format = "{0}";
if(typeof(title) == "undefined")title = "";
if(typeof(artist) == "undefined")artist = "";
if(typeof(album) == "undefined")album = "";
if(typeof(contentID) == "undefined")contentID = "";
enabled = Math.abs(enabled);
var WM_COPYDATA = 0x4A;
var MediaMessage = "FMD\\0" + type + "\\0" + enabled + "\\0" + format +"\\0" + title +"\\0" + artist + "\\0" + album + "\\0" + contentID + "\\0";
var song = Interop.Allocate((MediaMessage.length + 1) * 2);
song.WriteString(0, MediaMessage);
var copyDataStruct = Interop.Allocate(12);
copyDataStruct.WriteDWORD(0, 0x547); //dwData
copyDataStruct.WriteDWORD(4, song.Size); //cbData
copyDataStruct.WriteDWORD(8, song.DataPtr); //lpData
var hMSGRUI = 0;
do{
hMSGRUI = Interop.Call("User32", "FindWindowExW", 0, hMSGRUI, "MsnMsgrUIManager", 0);
if(hMSGRUI > 0){
Interop.Call("User32", "SendMessageW", hMSGRUI, WM_COPYDATA, 0, copyDataStruct);
}
}while(hMSGRUI != 0);
var listeningtoshouldbe = Messenger.MyCurrentMedia;
}
For further explanation about JScript, the scripting language of Plus!, please refer to Microsoft's
JScrit user's guide and
JScript language reference.
Furthermore, you may want to update your media message every once in a while. To do so, you need timers. You can use the following code to add a timer to your script:
code:
MsgPlus.AddTimer("TmrUpdateMedia",120000 /* 2 minutes is 120 seconds, is 120,000 milliseconds */);
Please refer to the scripting documentation about timers. Every time
OnEvent_Timer() is called by Plus!, you need to add the same timer again.